2007/05/27

iptables setting

PC1 in NAT
eth0: 192.168.1.1
run HTTP server on 80 port

PC2 in NAT and Public Domain
eth0: 140.138.243.124
eth1: 192.168.1.2

If you want to use PC2 as Firewall and to provide HTTP service,
set iptables in PC2 as follows:

Clear old setting:


sudo iptables -F
sudo iptables -X
sudo iptables -Z
sudo iptables -F -t nat
sudo iptables -X -t nat
sudo iptables -Z -t nat



Set POSTROUTING for NAT -> Public Domain connection:


sudo iptables -t nat -A POSTROUTING -s 0.0.0.0/0 -j SNAT \\
--to 140.138.243.124



Set PREROUTING for Public Domain -> NAT connection:


sudo iptables -t nat -A PREROUTING -p tcp -d 140.138.243.124 \\
--dport 80 -j DNAT --to 192.168.1.1:80



※ For the setting, PC2 can't use HTTP service through Public IP of PC2.
:$

No comments:

Post a Comment