]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/networking/any
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / src / initscripts / networking / any
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . ${rc_functions}
24 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
25
26 if [ "$(basename $0)" == "green" ]; then
27 DEVICE="${GREEN_DEV}"
28 ADDRESS="${GREEN_ADDRESS}"
29 NETADDRESS="${GREEN_NETADDRESS}"
30 NETMASK="${GREEN_NETMASK}"
31 DEVICE="${GREEN_DEV}"
32 MTU="${GREEN_MTU}"
33 elif [ "$(basename $0)" == "blue" ]; then
34 DEVICE="${BLUE_DEV}"
35 ADDRESS="${BLUE_ADDRESS}"
36 NETADDRESS="${BLUE_NETADDRESS}"
37 NETMASK="${BLUE_NETMASK}"
38 DEVICE="${BLUE_DEV}"
39 MTU="${BLUE_MTU}"
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}"
46 MTU="${ORANGE_MTU}"
47 fi
48
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}"
52 else
53 boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
54 echo_failure
55 exit 1
56 fi
57
58 case "${1}" in
59
60 start)
61 boot_mesg "Bringing up the ${DEVICE} interface..."
62 boot_mesg_flush
63
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
70 fi
71 fi
72 else
73 boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE}
74 echo_failure
75 exit 1
76 fi
77
78 # Set the MTU
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}..."
82 echo_warning
83 fi
84 fi
85
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}
89 evaluate_retval
90 fi
91 ;;
92
93 stop)
94 if [ ! "${ADDRESS}" == "1.1.1.1" ]; then
95 boot_mesg "Removing IPv4 addresses from the ${DEVICE} interface..."
96 ip addr flush dev ${DEVICE}
97 evaluate_retval
98 fi
99
100 exit 0;
101 ;;
102 esac