I have one server where iptables configured with all chains DROP in filter table
eth0 :- 10.0.0.2 [ Intranet assume as LAN ]
eth2 :- 172.16.0.2 [ External clients assume as WAN ]
Now What I am trying to achieving is , when client[172.16.0.1] HIT Port 80 On 172.16.0.2 then it should be nat to internal LAN IP that is 10.0.0.100.
What I have configured to achieve the same [INPUT,OUTPUT,FORWARD Policy is Drop in Filter Chains]
iptables -A INPUT -s 172.16.0.1/32 -d 172.16.0.2/32 -i eth2 -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A FORWARD -s 172.16.0.1/32 -j LOG --log-prefix "** TRACING FORWARD CHAIN **"
iptables -A FORWARD -s 172.16.0.1/32 -d 10.0.0.100/32 -i eth2 -o eth0 -j ACCEPT
iptables -A OUTPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
iptables -t nat -A PREROUTING -s 172.16.0.1/32 -d 172.16.0.2/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.100:80
net.ipv4.ip_forward = 1
in sysctl.conf
In Logs:
[17385.347409] ** TRACING FORWARD CHAIN **IN=eth2 OUT=eth0 MAC=xxxxxxxx SRC=172.16.0.1 DST=10.0.0.100 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=9864 DF PROTO=TCP SPT=52874 DPT=80 WINDOW=8192 RES=0x00 SYN URGP=0
Now When I Set FORWARD POLICY ACCEPT then it is working but not working with Forward Drop Policy.
So can anyone help me to understand forward policy and which rules should be added in forward policy.