]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/firewall/files/etc/init.d/iptables.sh
64fd5c1820d1e536e071984994ae3c12f19022c7
[ansible.git] / playbooks / debian / roles / firewall / files / etc / init.d / iptables.sh
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          iptables.sh
4 # Required-Start: $remote_fs $network
5 # Required-Stop:  $remote_fs
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: iptables firewall
9 ### END INIT INFO
10
11 # Setup ip firewall
12
13 . /etc/network/functions.phd
14
15 case "$1" in
16    start)
17       /etc/init.d/fail2ban stop
18
19       # Start afresh
20       $IPTABLES -F
21       $IPTABLES -F -t nat
22       $IPTABLES -F -t mangle
23
24       # Default policies
25       $IPTABLES -P INPUT DROP
26       $IPTABLES -P OUTPUT ACCEPT
27       $IPTABLES -P FORWARD DROP
28
29       start_firewall
30       /etc/init.d/rc.masq
31       /etc/init.d/fail2ban start
32    ;;
33
34    stop)
35       /etc/init.d/fail2ban stop
36
37       $IPTABLES -F
38       $IPTABLES -F -t nat
39       $IPTABLES -F -t mangle
40       $IPTABLES -P INPUT DROP
41       $IPTABLES -P OUTPUT DROP
42       $IPTABLES -P FORWARD DROP
43    ;;
44
45    clear)
46       /etc/init.d/fail2ban stop
47
48       # Flush (delete) all rules
49       $IPTABLES -F
50       $IPTABLES -F -t nat
51       $IPTABLES -F -t mangle
52       $IPTABLES -P INPUT ACCEPT
53       $IPTABLES -P OUTPUT ACCEPT
54       $IPTABLES -P FORWARD ACCEPT
55    ;;
56
57    *)
58       echo "Usage: firewall {start|stop|clear}"
59       exit 1
60 esac
61
62 exit 0