]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/network
iptables: Replace state module by conntrack module.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / network
CommitLineData
3fd5feeb
MT
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/network
4#
5# Description : Network Control Script
6#
d1e90efc 7# Authors : Michael Tremer - mitch@ipfire.org
3fd5feeb 8#
9c16cd92 9# Version : 01.00
3fd5feeb
MT
10#
11# Notes : Written for IPFire by its team
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
bf7c473f 17eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
bf7c473f 18
6fc15159 19init_networking() {
6fc15159
MT
20 boot_mesg "Loading firewall modules into the kernel"
21 modprobe iptable_nat || failed=1
5e0f55e7 22 for i in $(find /lib/modules/$(uname -r) -name nf_conntrack*); do
50418f38 23 modprobe $(basename $i | cut -d. -f1) || failed=1
6fc15159 24 done
5e0f55e7 25 for i in $(find /lib/modules/$(uname -r) -name nf_nat*); do
50418f38 26 modprobe $(basename $i | cut -d. -f1) || failed=1
6fc15159
MT
27 done
28 (exit ${failed})
29 evaluate_retval
3a90a80c 30
e1c97b8a
AF
31 # Enable netfilter accounting
32 sysctl net.netfilter.nf_conntrack_acct=1 > /dev/null
33
3a90a80c
AF
34 if [ -e /var/ipfire/main/disable_nf_sip ]; then
35 rmmod nf_nat_sip
36 rmmod nf_conntrack_sip
adc91020
MT
37 rmmod nf_nat_h323
38 rmmod nf_conntrack_h323
3a90a80c
AF
39 fi
40
6fc15159
MT
41 boot_mesg "Setting up firewall"
42 /etc/rc.d/init.d/firewall start; evaluate_retval
43
c130ab12
AF
44# boot_mesg "Setting up traffic accounting"
45# /etc/rc.d/helper/writeipac.pl || failed=1
46# /usr/sbin/fetchipac -S || failed=1
47# (exit ${failed})
48# evaluate_retval
6fc15159 49
111c99dd 50
6fc15159
MT
51 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
52 boot_mesg "Setting up wireless firewall rules"
900832fa 53 /usr/local/bin/wirelessctrl; evaluate_retval
6fc15159
MT
54 fi
55
56 /etc/rc.d/init.d/dnsmasq start
b5c30aea 57 /etc/rc.d/init.d/static-routes start
6fc15159
MT
58}
59
37263bc1
MT
60DO="${1}"
61shift
069680ac 62
37263bc1 63if [ -n "${1}" ]; then
d1e90efc
MT
64 ALL=0
65 for i in green red blue orange; do
66 eval "${i}=0"
67 done
37263bc1 68else
d1e90efc
MT
69 ALL=1
70 for i in green red blue orange; do
71 eval "${i}=1"
72 done
37263bc1 73fi
069680ac 74
37263bc1 75while [ ! $# = 0 ]; do
d1e90efc
MT
76 for i in green red blue orange; do
77 if [ "${i}" == "${1}" ]; then
78 eval "${i}=1"
79 shift
80 fi
81 done
37263bc1 82done
3fd5feeb 83
37263bc1 84case "${DO}" in
d1e90efc
MT
85 start)
86 [ "${ALL}" == "1" ] && init_networking
87
88 # Starting interfaces...
89 # GREEN
90 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
91
92 # BLUE
93 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
94 /etc/rc.d/init.d/networking/blue start
95
96 # ORANGE
97 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
98 /etc/rc.d/init.d/networking/orange start
99
100 # RED
101 if [ "$red" == "1" ]; then
102 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
103 # Remove possible leftover files
104 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
105 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
106 fi
107 fi
108 ;;
109
110 stop)
111 # Stopping interfaces...
112 # GREEN
113 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
114
115 # BLUE
116 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
117 /etc/rc.d/init.d/networking/blue stop
118
119 # ORANGE
120 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
121 /etc/rc.d/init.d/networking/orange stop
122
123 # RED
124 if [ "$red" == "1" ]; then
125 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
126 /etc/rc.d/init.d/networking/red stop
127 fi
128 fi
7be0be70
AF
129
130 # Stopping dnsmasq if network all networks shutdown
131 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
a4109682
AF
132
133 exit 0
d1e90efc
MT
134 ;;
135
136 restart)
137 for i in green red blue orange; do
138 if [ "${!i}" == "1" ]; then
139 ARGS+=" ${i}"
140 fi
141 done
142 ${0} stop ${ARGS}
143 sleep 1
144 ${0} start ${ARGS}
145 ;;
146
147 *)
148 echo "Usage: ${0} {start|stop|restart} [device(s)]"
149 exit 1
150 ;;
3fd5feeb
MT
151esac
152
153# End /etc/rc.d/init.d/network