iptables does not list rules i have created

24,009

Solution 1

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

Solution 2

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.

Share:
24,009

Related videos on Youtube

Stefan
Author by

Stefan

I like code, beer, rock climbing and travel.

Updated on September 17, 2022

Comments

  • Stefan
    Stefan over 1 year

    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?

  • Doctor
    Doctor almost 4 years
    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.
  • John Mitchell
    John Mitchell almost 4 years
    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
  • Adrián Jaramillo
    Adrián Jaramillo over 2 years
    Thanks, I was checking the wrong table, that worked