summaryrefslogtreecommitdiffstats
path: root/iptables.pkg/iptables.init
blob: 31a9311ad4810d4f70fc1804031b5b960f635c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh /etc/rc.common

START='25'
STOP='75'

start()
{
	[ -r /etc/iptables ] || return 0

	log 'Loading iptables rules'

	/bin/sh /etc/iptables
}

stop()
{
	local table=
	local chains=
	local chain=

	[ -r /etc/iptables ] || return 0

	log 'Flushing iptables rules'

	# For each table (raw, nat, mangle, filter, etc.):
	for table in $(cat /proc/net/ip_tables_names); do
		# Flush all the rules in all the chains and delete all the
		# user-defined chains.
		/usr/sbin/iptables -t "${table}" -F
		/usr/sbin/iptables -t "${table}" -X
		chains="$(/usr/sbin/iptables -t "${table}" -L -n | \
			sed -n 's/^Chain \([^ ]*\).*$/\1/p')"
		for chain in ${chains}; do
			# Set the chain's policy to the "ACCEPT" target.
			iptables -t "${table}" -P "${chain}" ACCEPT
		done
	done
}