]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/network
firewall: Initialize basic ruleset before entering runlevel 3.
[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 41 /etc/rc.d/init.d/dnsmasq start
b5c30aea 42 /etc/rc.d/init.d/static-routes start
6fc15159
MT
43}
44
37263bc1
MT
45DO="${1}"
46shift
069680ac 47
37263bc1 48if [ -n "${1}" ]; then
d1e90efc
MT
49 ALL=0
50 for i in green red blue orange; do
51 eval "${i}=0"
52 done
37263bc1 53else
d1e90efc
MT
54 ALL=1
55 for i in green red blue orange; do
56 eval "${i}=1"
57 done
37263bc1 58fi
069680ac 59
37263bc1 60while [ ! $# = 0 ]; do
d1e90efc
MT
61 for i in green red blue orange; do
62 if [ "${i}" == "${1}" ]; then
63 eval "${i}=1"
64 shift
65 fi
66 done
37263bc1 67done
3fd5feeb 68
37263bc1 69case "${DO}" in
d1e90efc
MT
70 start)
71 [ "${ALL}" == "1" ] && init_networking
72
73 # Starting interfaces...
74 # GREEN
75 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
76
77 # BLUE
78 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
79 /etc/rc.d/init.d/networking/blue start
80
81 # ORANGE
82 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
83 /etc/rc.d/init.d/networking/orange start
84
85 # RED
86 if [ "$red" == "1" ]; then
87 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
88 # Remove possible leftover files
89 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
90 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
91 fi
92 fi
93 ;;
94
95 stop)
96 # Stopping interfaces...
97 # GREEN
98 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
99
100 # BLUE
101 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
102 /etc/rc.d/init.d/networking/blue stop
103
104 # ORANGE
105 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
106 /etc/rc.d/init.d/networking/orange stop
107
108 # RED
109 if [ "$red" == "1" ]; then
110 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
111 /etc/rc.d/init.d/networking/red stop
112 fi
113 fi
7be0be70
AF
114
115 # Stopping dnsmasq if network all networks shutdown
116 [ "${ALL}" == "1" ] && /etc/rc.d/init.d/dnsmasq stop
a4109682
AF
117
118 exit 0
d1e90efc
MT
119 ;;
120
121 restart)
122 for i in green red blue orange; do
123 if [ "${!i}" == "1" ]; then
124 ARGS+=" ${i}"
125 fi
126 done
127 ${0} stop ${ARGS}
128 sleep 1
129 ${0} start ${ARGS}
130 ;;
131
132 *)
133 echo "Usage: ${0} {start|stop|restart} [device(s)]"
134 exit 1
135 ;;
3fd5feeb
MT
136esac
137
138# End /etc/rc.d/init.d/network