]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/network-vlans
2 ############################################################################
4 # This file is part of the IPFire Firewall. #
6 # IPFire is free software; you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation; either version 2 of the License, or #
9 # (at your option) any later version. #
11 # IPFire is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with IPFire; if not, write to the Free Software #
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
20 # Copyright (C) 2012 IPFire Team <info@ipfire.org> #
22 ############################################################################
24 CONFIG_FILE
="/var/ipfire/ethernet/vlans"
26 # Skip immediately if no configuration file has been found.
27 [ -e "${CONFIG_FILE}" ] ||
exit 0
29 eval $
(/usr
/local
/bin
/readhash
${CONFIG_FILE})
31 # This is start or stop.
34 for interface
in green0 blue0 orange0
; do
35 case "${interface}" in
37 PARENT_DEV
=${GREEN_PARENT_DEV}
38 VLAN_ID
=${GREEN_VLAN_ID}
39 MAC_ADDRESS
=${GREEN_MAC_ADDRESS}
42 PARENT_DEV
=${BLUE_PARENT_DEV}
43 VLAN_ID
=${BLUE_VLAN_ID}
44 MAC_ADDRESS
=${BLUE_MAC_ADDRESS}
47 PARENT_DEV
=${ORANGE_PARENT_DEV}
48 VLAN_ID
=${ORANGE_VLAN_ID}
49 MAC_ADDRESS
=${ORANGE_MAC_ADDRESS}
55 # If no parent device has been configured, we assume
56 # that this interface is not set up for VLANs and
58 [ -z "${PARENT_DEV}" ] && continue
60 # Check if the interface does already exists.
61 # If so, we skip creating it.
62 if [ -d "/sys/class/net/${interface}" ]; then
63 echo "Interface ${interface} already exists." >&2
67 # Check if the parent interface exists.
68 if [ ! -d "/sys/class/net/${PARENT_DEV}" ]; then
69 echo "${interface}: Parent device is not set or does not exist: ${PARENT_DEV}" >&2
73 if [ -z "${VLAN_ID}" ]; then
74 echo "${interface}: You did not set the VLAN ID." >&2
78 echo "Creating VLAN interface ${interface}..."
79 vconfig add
${PARENT_DEV} ${VLAN_ID}
80 ip link
set ${PARENT_DEV}.${VLAN_ID} name ${interface}
82 if [ -n "${MAC_ADDRESS}" ]; then
83 ip link
set ${interface} address
${MAC_ADDRESS}
86 # Bring up the parent device.
87 ip link
set ${PARENT_DEV} up
91 if [ ! -e "/proc/net/vlan/${interface}" ]; then
92 echo "${interface} is not a VLAN interface. Skipping."
96 echo "Removing VLAN interface ${interface}..."
97 ip link
set ${interface} down
98 vconfig rem
${interface}
102 echo "Invalid action: ${action}"