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) 2015 IPFire Team <info@ipfire.org> #
22 ############################################################################
24 [ -n "${INTERFACE}" ] ||
exit 2
26 CONFIG_FILE
="/var/ipfire/ethernet/vlans"
28 # Skip immediately if no configuration file has been found.
29 [ -e "${CONFIG_FILE}" ] ||
exit 0
31 eval $
(/usr
/local
/bin
/readhash
${CONFIG_FILE})
33 for interface
in green0 red0 blue0 orange0
; do
34 case "${interface}" in
36 PARENT_DEV
=${GREEN_PARENT_DEV}
37 VLAN_ID
=${GREEN_VLAN_ID}
38 MAC_ADDRESS
=${GREEN_MAC_ADDRESS}
41 PARENT_DEV
=${RED_PARENT_DEV}
42 VLAN_ID
=${RED_VLAN_ID}
43 MAC_ADDRESS
=${RED_MAC_ADDRESS}
46 PARENT_DEV
=${BLUE_PARENT_DEV}
47 VLAN_ID
=${BLUE_VLAN_ID}
48 MAC_ADDRESS
=${BLUE_MAC_ADDRESS}
51 PARENT_DEV
=${ORANGE_PARENT_DEV}
52 VLAN_ID
=${ORANGE_VLAN_ID}
53 MAC_ADDRESS
=${ORANGE_MAC_ADDRESS}
57 # If the parent device does not match the interface that
58 # has just come up, we will go on for the next one.
59 [ "${PARENT_DEV}" = "${INTERFACE}" ] ||
continue
61 # Check if the interface does already exists.
62 # If so, we skip creating it.
63 if [ -d "/sys/class/net/${interface}" ]; then
64 echo "Interface ${interface} already exists." >&2
68 if [ -z "${VLAN_ID}" ]; then
69 echo "${interface}: You did not set the VLAN ID." >&2
74 command="ip link add link ${PARENT_DEV} name ${interface}"
75 if [ -n "${MAC_ADDRESS}" ]; then
76 command="${command} address ${MAC_ADDRESS}"
78 command="${command} type vlan id ${VLAN_ID}"
80 echo "Creating VLAN interface ${interface}..."
83 # Bring up the parent device.
84 ip link
set ${PARENT_DEV} up