27

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?

Stefan
  • 25,300

2 Answers2

43

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
camh
  • 39,069
4

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.

  • 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 '20 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 https://linux.die.net/man/8/iptables – John Mitchell Jun 26 '20 at 13:40