]> git.ipfire.org Git - people/ms/strongswan.git/blob - testing/hosts/dave/etc/init.d/iptables
- import of strongswan-2.7.0
[people/ms/strongswan.git] / testing / hosts / dave / etc / init.d / iptables
1 #!/sbin/runscript
2 # Copyright 1999-2004 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 opts="start stop reload"
6
7 depend() {
8 before net
9 need logger
10 }
11
12 start() {
13 ebegin "Starting firewall"
14
15 # default policy is DROP
16 /sbin/iptables -P INPUT DROP
17 /sbin/iptables -P OUTPUT DROP
18 /sbin/iptables -P FORWARD DROP
19
20 # allow esp
21 iptables -A INPUT -i eth0 -p 50 -j ACCEPT
22 iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
23
24 # allow IKE
25 iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
26 iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
27
28 # allow crl fetch from winnetou
29 iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
30 iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
31
32 # allow ssh
33 iptables -A INPUT -p tcp --dport 22 -j ACCEPT
34 iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
35
36 eend $?
37 }
38
39 stop() {
40 ebegin "Stopping firewall"
41 for a in `cat /proc/net/ip_tables_names`; do
42 /sbin/iptables -F -t $a
43 /sbin/iptables -X -t $a
44
45 if [ $a == nat ]; then
46 /sbin/iptables -t nat -P PREROUTING ACCEPT
47 /sbin/iptables -t nat -P POSTROUTING ACCEPT
48 /sbin/iptables -t nat -P OUTPUT ACCEPT
49 elif [ $a == mangle ]; then
50 /sbin/iptables -t mangle -P PREROUTING ACCEPT
51 /sbin/iptables -t mangle -P INPUT ACCEPT
52 /sbin/iptables -t mangle -P FORWARD ACCEPT
53 /sbin/iptables -t mangle -P OUTPUT ACCEPT
54 /sbin/iptables -t mangle -P POSTROUTING ACCEPT
55 elif [ $a == filter ]; then
56 /sbin/iptables -t filter -P INPUT ACCEPT
57 /sbin/iptables -t filter -P FORWARD ACCEPT
58 /sbin/iptables -t filter -P OUTPUT ACCEPT
59 fi
60 done
61 eend $?
62 }
63
64 reload() {
65 ebegin "Flushing firewall"
66 for a in `cat /proc/net/ip_tables_names`; do
67 /sbin/iptables -F -t $a
68 /sbin/iptables -X -t $a
69 done;
70 eend $?
71 start
72 }
73