| 1 |
iptables -t nat -F |
| 2 |
nic # |
| 3 |
iptables -F |
| 4 |
nic # |
| 5 |
# NAT |
| 6 |
nic # |
| 7 |
iptables -t nat -A POSTROUTING -s 192.1.3.0/24 -p udp --sport 4500 -j SNAT --to-source 192.1.2.254:3500-3700 |
| 8 |
nic # |
| 9 |
iptables -t nat -A POSTROUTING -s 192.1.3.0/24 -p udp --sport 500 -j SNAT --to-source 192.1.2.254:2500-2700 |
| 10 |
nic # |
| 11 |
iptables -t nat -A POSTROUTING --source 192.1.3.0/24 --destination 0.0.0.0/0 -j SNAT --to-source 192.1.2.254 |
| 12 |
nic # |
| 13 |
# make sure that we never acidentially let ESP through. |
| 14 |
nic # |
| 15 |
# |
| 16 |
nic # |
| 17 |
iptables -I FORWARD 1 --proto 50 -j DROP |
| 18 |
nic # |
| 19 |
iptables -I FORWARD 2 --destination 192.0.2.0/24 -j DROP |
| 20 |
nic # |
| 21 |
iptables -I FORWARD 3 --source 192.0.2.0/24 -j DROP |
| 22 |
nic # |
| 23 |
# route |
| 24 |
nic # |
| 25 |
iptables -I INPUT 1 --destination 192.0.2.0/24 -j DROP |
| 26 |
nic # |
| 27 |
# Display the table, so we know it is correct. |
| 28 |
nic # |
| 29 |
iptables -t nat -L -n |
| 30 |
Chain PREROUTING (policy ACCEPT) |
| 31 |
target prot opt source destination |
| 32 |
Chain INPUT (policy ACCEPT) |
| 33 |
target prot opt source destination |
| 34 |
Chain OUTPUT (policy ACCEPT) |
| 35 |
target prot opt source destination |
| 36 |
Chain POSTROUTING (policy ACCEPT) |
| 37 |
target prot opt source destination |
| 38 |
SNAT udp -- 192.1.3.0/24 0.0.0.0/0 udp spt:4500 to:192.1.2.254:3500-3700 |
| 39 |
SNAT udp -- 192.1.3.0/24 0.0.0.0/0 udp spt:500 to:192.1.2.254:2500-2700 |
| 40 |
SNAT all -- 192.1.3.0/24 0.0.0.0/0 to:192.1.2.254 |
| 41 |
nic # |
| 42 |
iptables -L -n |
| 43 |
Chain INPUT (policy ACCEPT) |
| 44 |
target prot opt source destination |
| 45 |
DROP all -- 0.0.0.0/0 192.0.2.0/24 |
| 46 |
Chain FORWARD (policy ACCEPT) |
| 47 |
target prot opt source destination |
| 48 |
DROP esp -- 0.0.0.0/0 0.0.0.0/0 |
| 49 |
DROP all -- 0.0.0.0/0 192.0.2.0/24 |
| 50 |
DROP all -- 192.0.2.0/24 0.0.0.0/0 |
| 51 |
Chain OUTPUT (policy ACCEPT) |
| 52 |
target prot opt source destination |
| 53 |
nic # |
| 54 |
echo "initdone" |
| 55 |
initdone |
| 56 |
|