What is iptables in Linux? Introduction to iptables

What is iptables in Linux?

What is iptables in Linux? We can call, it’s the basics of Firewall for Linux. Iptables is a rule based firewall system and it is normally pre-installed on a Unix operating system which is controlling the incoming and outgoing packets. By-default the iptables is running without any rules, we can create, add, edit rules into it.

In this article I am trying to explain the basics of iptables with some common practices.

Hope, this topic will give you the basics of iptables.

Basic structure of iptables

The default structure of  iptables is like, Tables which has Chains and the Chains which contains Rules.

Tables —> Chains —> Rules. The rules are defined to control the packets for Input/Output.

what is iptables in linux
what is iptables in linux

List of different Tables in iptables structure

Here is list of iptables Tables and corresponding Chains.

Allow/deny ping on Linux server – iptables rules for icmp


1. Filter Table

It is the default table in iptables. There is no need to specify the table name for defining the Rules. Different inbuilt chains in this table.

1.1 INPUT Chain

INPUT Chain is for managing packets input to the server. Here we can add Rules to control INPUT connections from remote to the server.

1.2 FORWARD Chain

To add Rules to manage packet connections from one network interface(NIC) to another on the same machine.

1.3 OUTPUT Chain

The OUTPUT Chain control packets from the server to outside. Here we can add different rules to manage outbound connection from the server.

2. NAT table

Network address translation (NAT) is a methodology of modifying network address information in Internet Protocol (IP) datagram packet headers while they are in transit across a traffic routing device for the purpose of remapping one IP address space into another. The default inbuilt chains for NAT tables are;

2.1 PREROUTING chain

As the name indicates its translate packets before routing.


Translate packets after routing completes.

2.3 OUTPUT chain

Introduction to IAAC [Infrastructure As A Code] tools

It’s time that I had to write an article on IAAC. All giant’s infra are now set and manage as IAAC.

I hope you guys are already aware of these tools and you are already started working on that. This is a simple, straight intro to those tools. This will help you to start your journey as an automation engineer.

3. Mangle table

This table is used for packet alternation. Different inbuilt chains are;

3.1 PREROUTING chain
3.2 OUTPUT chain
3.3 FORWARD chain
3.4 INPUT chain

A graphical view:

what is iptables in linux
what is iptables in linux

IPtables command to list Rules in all tables (Filter, NAT, Mangle)

Hope you got the idea of “What is iptables in Linux.” Yes, it is very important to find the current rules in the chains of the iptables tables. The iptables has a wide verity of switches to manage this via CLI. For listing rules in different tables we can use the switch “–list” along with switch “-t” to select the iptables tables. Here is some usages and examples are listed.

-t : For define tables.
–list : For list all rules from the selected table.

How to list all rules from the Filter table of iptables?

As I mentioned, the filter table is the default Iptables table. We can simply mange this table with out specifying the table name. See the examples pasted.


iptables -t filter --list
iptables -t filter -L

Or simply;

iptables --list
iptables -L

Sample output:

root@test [~]# iptables -t filter --list
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
acctboth   all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

How/command to list all rules from the NAT table of iptables?

We need to mention the table name with the help of the switch “-t” to manage the rules excluded the Filter table.

Use -t followed by the table name “nat” to mange rules in the NAT table.


iptables -t nat --list
iptables -t nat -L


root@test [~]# iptables -t nat -L
target     prot opt source               destination

target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

How/command to list all rules from the Mangle table of iptables?

Replace the -t section with “mangle” to mange the Mangle table of iptables.


iptables -t mangle --list
iptables -t mangle -L


root@test [~]# iptables -t mangle --list
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

target     prot opt source               destination

That’s it.

Related Topics:

1. How to save/backup existing iptables rules to a file
2. How to allow/block PING on Linux server – IPTables rules for icmp

How to block incoming/outgoing network access for a single user using iptables?

Hmm… Every SysAdmin, who love to play with Linux iptables must know, how iptables deal networking for a single user. You need to dig more on Linux iptables to get this option. Yeah, it’s possible!! Linux iptables has a special module to deal with this operation. This iptables module is called “owner” (ipt_owner).

Before starting, you must have the basics of iptables.. Please read the post added below to get a clear intro on Linux iptables: Read more..


Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

22 thoughts on “What is iptables in Linux? Introduction to iptables

  1. Very Good and valuable notes written by the Respected Author. Certainly, obviously he/she has read and studied a lot to preparing this valuable notes, which may be very useful to the 6th semester of my B.Sc. Major in Computer Science as well as the B.C.A. students.

    Thanks a lot and best wishes for your kind effort !

  2. Recently while in the middle of doing performance testing, one day my weblogic cluster stopped working. Admin node was not able to communicate with different managed nodes on different machine. I got an error saying “java.net.NoRouteToHostException”. After spending almost a day, i cleared the iptables rules and everything started working. You mentioned that by default iptables is running without any rules. I don’t know how rules got added to the iptables(maybe someone from network team or other team members…. Do not know).

    Later i wanted to read more about iptables and came across this article. This article is very simple to understand. You have placed couple of diagrams which summarizes everything. And very important basic commands. Thanks a lot Arunlal.

  3. Hello
    I need to your help in interdiuse iptables .I have presen of MUM in dubai at 18 Oct and Im not ready .I FROM IRAN

  4. Well done. Good strugle on this.actually i wslas searching like these information.i got very good information from this article.


  5. Loved the information you shared with us Ashok. I am from non technical background and still I am able to understand the information and terms and they are very clear to me. Really thankful to you Ashok, and keep posting such valuable information

Leave a Reply

Your email address will not be published. Required fields are marked *