Quote:
Originally Posted by satish
I want some explanation for the iptables which is given below.
1)
iptables -A FORWARD -i eth2 -o eth3 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth3 -o eth2 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
|
The first rule says: all packets that come in eth2 and go out of eth3 and that are established should be accepted
The 2nd rule says: all packets going in eth3 and going out eth2 should be accepted
3rd rule: all traffic that goes out eth2 should be natted.
Quote:
Originally Posted by satish
2)
iptables -A FORWARD -i eth3 -o eth2 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth2 -o eth3 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth3 -j MASQUERADE
|
Same except eth2<->eth3 swapped.
Quote:
Originally Posted by satish
3)
iptables -A FORWARD -i eth1 -o eth0 -p tcp --sport 1024:65535 -d 192.168.1.249 --dport 4899 -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -p tcp ! --syn -s 192.168.1.249 --sport 4899 --dport 1024:65535 -j ACCEPT
iptables -t nat -A PREROUTING -i eth1 -p tcp --sport 1024:65535 -d 114.143.28.204 --dport 4899 -j DNAT --to-destination 192.168.1.249
|
1st rule: all packets that go in eth1 and go out eth2 and proto is tcp and source port is in range 1024-65535 and destination is 192.168.1.249 and destination port is 4899 should be accepted.
2nd: all packets coming in eth0 and going out eth2 and proto is tcp and it's not syn (connection estabilishing) packet, and source is 192.168.1.249 and source port is 4899 and destination port is range 1024-65535 should be accepted.
3: nat all packets coming in eth1 with tcp proto and source port 1024-65535 and going to 114.143.28.204:4899, nat them all to 192.168.1.249.