Change QOS of incoming traffic to match local Nat IP Addresses
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / network
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/network
4 #
5 # Description : Network Control Script
6 #
7 # Authors : Michael Tremer - mitch@ipfire.org
8 #
9 # Version : 01.00
10 #
11 # Notes : Written for IPFire by its team
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
18
19 init_networking() {
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 ip_conntrack*); do
23 modprobe $(basename $i | cut -d. -f1) || failed=1
24 done
25 for i in $(find /lib/modules/$(uname -r) -name ip_nat*); do
26 modprobe $(basename $i | cut -d. -f1) || failed=1
27 done
28 (exit ${failed})
29 evaluate_retval
30
31 boot_mesg "Setting up firewall"
32 /etc/rc.d/init.d/firewall start; evaluate_retval
33
34 # boot_mesg "Setting up traffic accounting"
35 # /etc/rc.d/helper/writeipac.pl || failed=1
36 # /usr/sbin/fetchipac -S || failed=1
37 # (exit ${failed})
38 # evaluate_retval
39
40 boot_mesg "Setting up DMZ pinholes"
41 /usr/local/bin/setdmzholes; evaluate_retval
42
43 if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
44 boot_mesg "Setting up wireless firewall rules"
45 /usr/local/bin/wirelessctrl; evaluate_retval
46 fi
47
48 /etc/rc.d/init.d/dnsmasq start
49 }
50
51 DO="${1}"
52 shift
53
54 if [ -n "${1}" ]; then
55 ALL=0
56 for i in green red blue orange; do
57 eval "${i}=0"
58 done
59 else
60 ALL=1
61 for i in green red blue orange; do
62 eval "${i}=1"
63 done
64 fi
65
66 while [ ! $# = 0 ]; do
67 for i in green red blue orange; do
68 if [ "${i}" == "${1}" ]; then
69 eval "${i}=1"
70 shift
71 fi
72 done
73 done
74
75 case "${DO}" in
76 start)
77 [ "${ALL}" == "1" ] && init_networking
78
79 # Starting interfaces...
80 # GREEN
81 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
82
83 # BLUE
84 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
85 /etc/rc.d/init.d/networking/blue start
86
87 # ORANGE
88 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
89 /etc/rc.d/init.d/networking/orange start
90
91 # RED
92 if [ "$red" == "1" ]; then
93 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
94 # Remove possible leftover files
95 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
96 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
97 fi
98 fi
99 ;;
100
101 stop)
102 # Stopping interfaces...
103 # GREEN
104 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
105
106 # BLUE
107 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
108 /etc/rc.d/init.d/networking/blue stop
109
110 # ORANGE
111 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
112 /etc/rc.d/init.d/networking/orange stop
113
114 # RED
115 if [ "$red" == "1" ]; then
116 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
117 /etc/rc.d/init.d/networking/red stop
118 fi
119 fi
120
121 # Stopping dnsmasq if network all networks shutdown
122 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
123
124 exit 0
125 ;;
126
127 restart)
128 for i in green red blue orange; do
129 if [ "${!i}" == "1" ]; then
130 ARGS+=" ${i}"
131 fi
132 done
133 ${0} stop ${ARGS}
134 sleep 1
135 ${0} start ${ARGS}
136 ;;
137
138 *)
139 echo "Usage: ${0} {start|stop|restart} [device(s)]"
140 exit 1
141 ;;
142 esac
143
144 # End /etc/rc.d/init.d/network