how to find out which chain in iptables in listing

8,156

with this command: iptables -L -t nat -n --line-numbers -t filter , you can see only filter table rules!

you must separate run :

iptables -L  -t nat -n --line-numbers 

for see nat table rules and

iptables -L  -n --line-numbers 

for see filter table rules

Share:
8,156

Related videos on Youtube

PersianGulf
Author by

PersianGulf

My God is Allah and my religious book is Quran.Up to now my life was based on my God's will and whatever I gained or lost is due to my God's want. My aspiration is to put my life in favour of my lord, Allah since I believe this would be a desirable life. I am a fan and supporter of Free Software and i do all my computer works based on Freesoftware. My other interests are Linux/GNU family and BSD. My main speciality is network administration but I also have decent knowledge in C/C++ and Python progmming. In general I love programming languages. My favorite sport is mountain climbing because I love outdoors and generaly I'm a nature lover. I truely love to increase my knowledge because I'm eager to know as much as possible. Not only I have this desire for myself, but also for every human being and I will do my best to help anyone who wishes to be on this path. (You can find everythinf about me at http://pahlevanzadeh.net)

Updated on September 18, 2022

Comments

  • PersianGulf
    PersianGulf over 1 year

    Suppose I have the following two entries line of iptables:

    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    iptables -A INPUT -s 192.168.1.0/24 -j DROP
    

    So, I have POSTROUTING and INPUT chains. Then I can get the result list with:

    iptables -L  -t nat -n --line-numbers -t filter
    

    My result is:

    Chain INPUT (policy ACCEPT)
    num  target     prot opt source               destination         
    1    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:70
    2    DROP       all  --  10.10.10.0/24        0.0.0.0/0           
    

    My quesion is, how can I find out which rule belongs to POSTROUTING and which belongs to INPUT ?

  • Stéphane Chazelas
    Stéphane Chazelas over 9 years
    See also iptables-save to see everything at once
  • PersianGulf
    PersianGulf over 9 years
    It's not my answer, i need to find out chain of each rule.