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 # boot_mesg "Setting up traffic accounting"
45 # /etc/rc.d/helper/writeipac.pl || failed=1
46 # /usr/sbin/fetchipac -S || failed=1
50 boot_mesg
"Setting up DMZ pinholes"
51 /usr
/local
/bin
/setdmzholes
; evaluate_retval
53 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
54 boot_mesg
"Setting up wireless firewall rules"
55 /usr
/local
/bin
/wirelessctrl
; evaluate_retval
58 /etc
/rc.d
/init.d
/dnsmasq start
59 /etc
/rc.d
/init.d
/static-routes start
65 if [ -n "${1}" ]; then
67 for i
in green red blue orange
; do
72 for i
in green red blue orange
; do
77 while [ ! $# = 0 ]; do
78 for i
in green red blue orange
; do
79 if [ "${i}" == "${1}" ]; then
88 [ "${ALL}" == "1" ] && init_networking
90 # Starting interfaces...
92 [ "$green" == "1" ] && /etc
/rc.d
/init.d
/networking
/green start
95 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
96 /etc
/rc.d
/init.d
/networking
/blue start
99 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
100 /etc
/rc.d
/init.d
/networking
/orange start
103 if [ "$red" == "1" ]; then
104 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
105 # Remove possible leftover files
106 rm -f /var
/ipfire
/red
/{active
,device
,dial-on-demand
,dns1
,dns2
,local-ipaddress
,remote-ipaddress
,resolv.conf
}
107 [ "$AUTOCONNECT" == "off" ] ||
/etc
/rc.d
/init.d
/networking
/red start
113 # Stopping interfaces...
115 [ "$green" == "1" ] && /etc
/rc.d
/init.d
/networking
/green stop
118 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
119 /etc
/rc.d
/init.d
/networking
/blue stop
122 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
123 /etc
/rc.d
/init.d
/networking
/orange stop
126 if [ "$red" == "1" ]; then
127 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
128 /etc
/rc.d
/init.d
/networking
/red stop
132 # Stopping dnsmasq if network all networks shutdown
133 [ "${ALL}" == "1" ] && /etc
/rc.d
/init.d
/dnsmasq stop
139 for i
in green red blue orange
; do
140 if [ "${!i}" == "1" ]; then
150 echo "Usage: ${0} {start|stop|restart} [device(s)]"
155 # End /etc/rc.d/init.d/network