2 ########################################################################
3 # Begin $rc_base/init.d/network
5 # Description : Network Control Script
7 # Authors : Michael Tremer - mitch@ipfire.org
11 # Notes : Written for IPFire by its team
13 ########################################################################
17 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
20 boot_mesg
"Loading firewall modules into the kernel"
21 modprobe iptable_nat || failed
=1
22 for i
in $
(find /lib
/modules
/$
(uname
-r) -name nf_conntrack
*); do
23 modprobe $
(basename $i | cut
-d.
-f1) || failed
=1
25 for i
in $
(find /lib
/modules
/$
(uname
-r) -name nf_nat
*); do
26 modprobe $
(basename $i | cut
-d.
-f1) || failed
=1
31 # Enable netfilter accounting
32 sysctl net.netfilter.nf_conntrack_acct
=1 > /dev
/null
34 if [ -e /var
/ipfire
/main
/disable_nf_sip
]; then
36 rmmod nf_conntrack_sip
38 rmmod nf_conntrack_h323
41 boot_mesg
"Setting up firewall"
42 /etc
/rc.d
/init.d
/firewall start
; evaluate_retval
44 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
45 boot_mesg
"Setting up wireless firewall rules"
46 /usr
/local
/bin
/wirelessctrl
; evaluate_retval
49 /etc
/rc.d
/init.d
/dnsmasq start
50 /etc
/rc.d
/init.d
/static-routes start
56 if [ -n "${1}" ]; then
58 for i
in green red blue orange
; do
63 for i
in green red blue orange
; do
68 while [ ! $# = 0 ]; do
69 for i
in green red blue orange
; do
70 if [ "${i}" == "${1}" ]; then
79 [ "${ALL}" == "1" ] && init_networking
81 # Starting interfaces...
83 [ "$green" == "1" ] && /etc
/rc.d
/init.d
/networking
/green start
86 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
87 /etc
/rc.d
/init.d
/networking
/blue start
90 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
91 /etc
/rc.d
/init.d
/networking
/orange start
94 if [ "$red" == "1" ]; then
95 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
96 # Remove possible leftover files
97 rm -f /var
/ipfire
/red
/{active
,device
,dial-on-demand
,dns1
,dns2
,local-ipaddress
,remote-ipaddress
,resolv.conf
}
98 [ "$AUTOCONNECT" == "off" ] ||
/etc
/rc.d
/init.d
/networking
/red start
104 # Stopping interfaces...
106 [ "$green" == "1" ] && /etc
/rc.d
/init.d
/networking
/green stop
109 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
110 /etc
/rc.d
/init.d
/networking
/blue stop
113 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
114 /etc
/rc.d
/init.d
/networking
/orange stop
117 if [ "$red" == "1" ]; then
118 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
119 /etc
/rc.d
/init.d
/networking
/red stop
123 # Stopping dnsmasq if network all networks shutdown
124 [ "${ALL}" == "1" ] && /etc
/rc.d
/init.d
/dnsmasq stop
130 for i
in green red blue orange
; do
131 if [ "${!i}" == "1" ]; then
141 echo "Usage: ${0} {start|stop|restart} [device(s)]"
146 # End /etc/rc.d/init.d/network