3 # source application-specific settings
4 [ -f /etc
/conf.d
/iptables
] && .
/etc
/conf.d
/iptables
6 # Set defaults if settings are missing
7 [ -z "$IPTABLES" ] && IPTABLES
=/usr
/sbin
/iptables
8 [ -z "$IPTABLES_CONF" ] && IPTABLES_CONF
=/etc
/iptables
/iptables.rules
15 if [ ! -f $IPTABLES_CONF ]; then
16 echo "Cannot load iptables rules: $IPTABLES_CONF is missing!" >&2
19 stat_busy
"Starting IP Tables"
20 if [ "$IPTABLES_FORWARD" = "1" ]; then
21 echo 1 >/proc
/sys
/net
/ipv
4/ip_forward
23 if ck_daemon iptables
; then
24 /usr
/sbin
/iptables-restore
< $IPTABLES_CONF
36 stat_busy
"Stopping IP Tables"
37 echo 0 >/proc
/sys
/net
/ipv
4/ip_forward
38 if ! ck_daemon iptables
; then
40 for table
in $
(cat /proc
/net
/ip_tables_names
); do
41 $IPTABLES -t $table -F &>/dev
/null
&& \
42 $IPTABLES -t $table -X &>/dev
/null
&& \
43 $IPTABLES -t $table -Z &>/dev
/null
44 [ $?
-gt 0 ] && fail
=1
46 if [ $fail -gt 0 ]; then
51 for table
in filter nat mangle raw
; do
52 if grep -qw $table /proc
/net
/ip_tables_names
; then
53 $IPTABLES -t $table -P OUTPUT ACCEPT
56 for table
in filter mangle
; do
57 if grep -qw $table /proc
/net
/ip_tables_names
; then
58 $IPTABLES -t $table -P INPUT ACCEPT
59 $IPTABLES -t $table -P FORWARD ACCEPT
62 for table
in nat mangle raw
; do
63 if grep -qw $table /proc
/net
/ip_tables_names
; then
64 $IPTABLES -t $table -P PREROUTING ACCEPT
67 for table
in nat mangle
; do
68 if grep -qw $table /proc
/net
/ip_tables_names
; then
69 $IPTABLES -t $table -P POSTROUTING ACCEPT
84 stat_busy
"Saving IP Tables"
85 /usr
/sbin
/iptables-save
>$IPTABLES_CONF
93 echo "usage: $0 {start|stop|restart|save}"