How to check PREROUTING list from iptable in linux?

John Doyle picture John Doyle · Jan 5, 2017 · Viewed 28.7k times · Source

I added packet forwarding rule in my iptable
sudo iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination 10.0.3.126:80
and I can see that the packet coming to port 1111 is correctly forwarded to 10.0.3.126:80. However if I list up the rules, I cannot see the rule that I added.

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

How can I view the rule I added? Thank you in advance.

Answer

Yuriy Zhigulskiy picture Yuriy Zhigulskiy · Jan 5, 2017

Use iptables -L -n -t nat command
Because PREROUTING chain is a part of NAT rules