summaryrefslogtreecommitdiffstats
path: root/target/device/Atmel/atngw100/target_skeleton/etc/init.d/S22iptables
blob: 2ccadde6cdb6c616ad3de6e786a37745bcb8e880 (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
39
40
41
42
43
#!/bin/sh

IPTABLES=`which iptables`

echo "Enable NAT:"
echo -n "  IPv4 forwarding: "
if echo 1 > /proc/sys/net/ipv4/ip_forward; then
	echo "done"
else
	echo "failed"
	return 1
fi

echo -n "  iptables postrouting: "
if [ ! -x "${IPTABLES}" ]; then
	echo "missing"
	exit 1
fi

if ${IPTABLES} -t nat -A POSTROUTING -o eth0 -j MASQUERADE; then
	echo "done"
else
	echo "failed"
	exit 1
fi

echo -n "  iptables incoming trafic: "
if ${IPTABLES} -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT; then
	echo "done"
else
	echo "failed"
	exit 1
fi

echo -n "  iptables outgoung trafic: "
if ${IPTABLES} -A FORWARD -i eth1 -o eth0 -j ACCEPT; then
	echo "done"
else
	echo "failed"
	exit 1
fi

exit 0