24

I'm using this guide to set-up a shared internet connection between two PC's.

At step 8 it says I should run the commands:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/etc/rc.d/iptables save
/etc/rc.d/iptables start

Doing this seems to have no effect on iptable's rules, if I run iptables -nvL my output is:

Chain INPUT (policy ACCEPT 2223 packets, 2330K bytes)
 pkts bytes target     prot opt in     out     source         destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
  pkts bytes target     prot opt in     out     source        destination

Chain OUTPUT (policy ACCEPT 2272 packets, 277K bytes)
  pkts bytes target     prot opt in     out     source        destination

Is that correct or am I doing something wrong?

2 Answers 2

39

The command iptables -nvL is displaying the contents of the filter table. The rule you are adding is in the nat table. Add -t nat to look at the nat table:

iptables -t nat -nvL
1
  • Thanks, I was checking the wrong table, that worked Oct 4, 2021 at 21:04
3

You can also run iptables-save and it'll dump all the contents to the screen if you just want to look at everything. I find it easy to look at everything that way when I feel lazy.

2
  • 1
    I don't get why my INPUT rule does not appear when I use iptables -L but does show up when using iptables-save. Makes no sense.
    – Doctor
    Jun 25, 2020 at 11:19
  • 1
    iptables-save just dumps everything but iptables -L (without the -t directive) defaults to JUST showing your filter table. There are 3 other tables which CAN be listed linux.die.net/man/8/iptables Jun 26, 2020 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.