]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/networking/any
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
26 if [ "$(basename $0)" == "green" ]; then
28 ADDRESS
="${GREEN_ADDRESS}"
29 NETADDRESS
="${GREEN_NETADDRESS}"
30 NETMASK
="${GREEN_NETMASK}"
33 elif [ "$(basename $0)" == "blue" ]; then
35 ADDRESS
="${BLUE_ADDRESS}"
36 NETADDRESS
="${BLUE_NETADDRESS}"
37 NETMASK
="${BLUE_NETMASK}"
40 elif [ "$(basename $0)" == "orange" ]; then
41 DEVICE
="${ORANGE_DEV}"
42 ADDRESS
="${ORANGE_ADDRESS}"
43 NETADDRESS
="${ORANGE_NETADDRESS}"
44 NETMASK
="${ORANGE_NETMASK}"
45 DEVICE
="${ORANGE_DEV}"
49 if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then
50 PREFIX
=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-`
51 args
="${args} ${ADDRESS}/${PREFIX}"
53 boot_mesg
"ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
61 boot_mesg
"Bringing up the ${DEVICE} interface..."
64 # Check if an interface is there...
65 if ip link show
${DEVICE} > /dev
/null
2>&1; then
66 link_status
=`ip link show ${DEVICE} 2> /dev/null`
67 if [ -n "${link_status}" ]; then
68 if ! echo "${link_status}" |
grep -q UP
; then
69 ip link
set ${DEVICE} up
73 boot_mesg
"Interface ${DEVICE} doesn't exist." ${FAILURE}
79 if [ -n "${MTU}" ]; then
80 if ! ip link
set dev
"${DEVICE}" mtu
"${MTU}" &>/dev
/null
; then
81 boot_mesg
"Could not set MTU of ${MTU} to ${DEVICE}..."
86 if [ ! "${ADDRESS}" == "1.1.1.1" ]; then
87 boot_mesg
"Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..."
88 ip addr add
${args} dev
${DEVICE}
94 if [ ! "${ADDRESS}" == "1.1.1.1" ]; then
95 boot_mesg
"Removing IPv4 addresses from the ${DEVICE} interface..."
96 ip addr flush dev
${DEVICE}