Linux iptables | How Linux Iptables Works with Examples?

Ask questions Research chat →

https://www.educba.com/linux-iptables/ · scraped

terminal

Scraped Content

— 611 words · 2026-06-11 17:18:07 UTC ·

Excerpt

![](https://prod-files-secure.s3.us-west-2.amazonaws.com/871f1661-80b8-4d0c-ac3b-2adfc6ff4c66/8a5b079d-ca03-42af-86bd-4818e7633488/Linux-iptables.jpg.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIAZI2LB466RGI3JBRJ%2F20260611%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20260611T171806Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDgaCXVzLXdlc3QtMiJIMEYCIQCk9yCPqkWZa8tLv0hEGFH%2FiW8nZbP%2BQKrxXYVroKfFiQIhAJL3mxgyy9%2FUIqraRdFEA6mB0%2BVIBssYupQwrPIUwWWmKv8DCAEQABoMNjM3NDIzMTgzODA1IgyVSHuK569YG3l34hsq3AOHgVh4%2FAClCaDFf544T0h6ZoLkU7fWS%2BBizEg%2F5BREgxfRpgTHMDof2LhAXFzQ%2Bj00G28N8ELvylyuWEMkIMk5ZHQOPZTZY4eTSEmvtt5H6jXqcSkbig%2BaTQBTE2quwzcvEKDig6k8GOmuBPIlj0%2FEgsrl8rh%2B4tDrW1lkiM0FDqIT1PhDlxsSVnMTTpzeCJcsV1byRa0DNn3ncP57Htd8bw%2BlrhUJ%2BcrwjcKasm550FCanrpLto888cP%2BV8YtFrWprPRemg7vAp3kKxxoU5%2FqhQt53eq6roPcuCnRdBS3%2FFTeBnsQQDucDO6Xb4Rr4wIUeA0XQ0ckhnCkSSRuFnbtKWFenufZxhc0lxTM7o2%2Bp8CiDI5auA74zmNbsFZMOkeCCNsLbspixvSPMQ5mT2onaor
![](https://prod-files-secure.s3.us-west-2.amazonaws.com/871f1661-80b8-4d0c-ac3b-2adfc6ff4c66/8a5b079d-ca03-42af-86bd-4818e7633488/Linux-iptables.jpg.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIAZI2LB466RGI3JBRJ%2F20260611%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20260611T171806Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDgaCXVzLXdlc3QtMiJIMEYCIQCk9yCPqkWZa8tLv0hEGFH%2FiW8nZbP%2BQKrxXYVroKfFiQIhAJL3mxgyy9%2FUIqraRdFEA6mB0%2BVIBssYupQwrPIUwWWmKv8DCAEQABoMNjM3NDIzMTgzODA1IgyVSHuK569YG3l34hsq3AOHgVh4%2FAClCaDFf544T0h6ZoLkU7fWS%2BBizEg%2F5BREgxfRpgTHMDof2LhAXFzQ%2Bj00G28N8ELvylyuWEMkIMk5ZHQOPZTZY4eTSEmvtt5H6jXqcSkbig%2BaTQBTE2quwzcvEKDig6k8GOmuBPIlj0%2FEgsrl8rh%2B4tDrW1lkiM0FDqIT1PhDlxsSVnMTTpzeCJcsV1byRa0DNn3ncP57Htd8bw%2BlrhUJ%2BcrwjcKasm550FCanrpLto888cP%2BV8YtFrWprPRemg7vAp3kKxxoU5%2FqhQt53eq6roPcuCnRdBS3%2FFTeBnsQQDucDO6Xb4Rr4wIUeA0XQ0ckhnCkSSRuFnbtKWFenufZxhc0lxTM7o2%2Bp8CiDI5auA74zmNbsFZMOkeCCNsLbspixvSPMQ5mT2onaordcsb22SkQQy31oByK1zQvwbAxa4Owcwq1tKUwyZONBuWAF7%2F7XIbRs4y35qYFdr6VbQYJMur6FdcDHtejsGzglMe%2BsmBts5RdQYKnsvURsHgXiZ0qRJPQ%2FFfmm99Gf4Y4pZ00BZvM81oly13sH3EbJfoKx6Ra5%2BObLrBgMPO7zPRbTrSvwgeqfvGdrEMOTqwKr%2FvPJBnukj5kw9HKZxH5CAlZEQFa7%2BdGEjDavqvRBjqkAcnE%2Fd1ksQlZneBY4LKD7hfkSWls2ZUr5NbVkjVj3a40lSAD23F7gCiDlZTCa%2BdfB%2BHlBiBtbUAYXgJ%2FbDS8Ly2ewO70FrmUzIRDmI8Kdev%2FKZHgdjCYat%2BC1tcQ8yPwwVxF%2Fx3Rd69fZ%2BzJ9ozihjazJRlkGY1f60gbBcWWOKjyPc%2FymT%2F81vDHwaPdINPK2aOH6qOSeaN%2BgQr7Y%2B1d4Ab%2BQlIZ&X-Amz-Signature=47c8d892f712100e1d671667eb33b6457ca45cc17cff8c250e4e48269db3f9c0&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject) ## Introduction to Linux iptables In the Linux operating system, iptables is a utility or tool to manage the firewall rules in the environment. Similarly, we have one more tool to manage the firewall rules on the Linux, i.e., firewalld. The iptables are used to manage setup and examine the IP packets in the Linux kernel. It will help to restrict unwanted packets in the environment. It will hold the number of built-in chains known as the system chain and user-defined chain. Rusty Russell originally wrote the iptables in early consultation with Michael Neuling. The man page of the iptables was originally written by Herve Eychenne (email ID: rv@wallfire.org). Syntax of the Linux Iptables iptables [-t table] {-A|-C|-D} chain rule-specification - iptables: We can use the “iptables” keyword in the syntax or command. It will take different arguments like table name, options, system or user chain, set of specific rules, etc. As per the provided arguments, it will manage the setup and examine the IP table. - OPTIONS: We can provide the different flags as the option that is compatible with the “iptables” command. - Chain: As per the condition or requirement, we can use the system chain or the user-defined chain. ### How Linux Iptables Works? Linux is a multi-user support operating system. It will support multiple servers or applications. While running these servers or applications, it is very important to manage the packet securities. The iptables have the capability to manage it. It will create a set of rules in the environment, and as per the rules, the flowing packets will allow or restrict. Below are the lists of options that are compatible with the iptables command. ### Examples of implementing Linux Iptables Below are the examples of Linux Iptables: ### Example #1 – Check IP Tables Rule In the Linux environment, we can check the list of iptables rules available in the environment. Command : iptables -L -n -v Explanation : As per the above command, we are listing the number of rules available in the working environment. Output: ### Example #2 – Block the IP Address In the iptables, we have the functionality to block the specific IP address in the environment. Command : Explanation : As per the above command, we are blocking the 10.10.189.57 IP address. Output : ### Example #3 – Unblock the IP Address While working with the Linux iptables, we can also unblock the IP address. Command : iptables -D INPUT -s 10.10.189.57 -j DROP Explanation : As per the above command, we are unblocking the 10.10.189.57 IP address. Output : ### Example #4 – Block Outgoing Port In Linux, we can disable the outgoing port traffic. Command : iptables -A OUTPUT -p tcp --dport 80 -j DROP Explanation : We are blocking the outgoing traffic of the environment and blocking port no 80. Output : ### Example #5 – Block Incoming Port In the iptables, we have the functionality to block the incoming port traffic. Command : iptables -A INPUT -p tcp --dport 80 -j ACCEPT Explanation : We are blocking the incoming traffic of the environment and blocking port no 80. Output : ### Conclusion We have seen the uncut concept of “Linux Iptables” with the proper example, explanation, and command with different outputs. As per the requirement, we can create or drop the iptables or firewall rules. We can block or unblock the IP address or port as well. ### Recommended Articles This is a guide to Linux iptables. Here we discuss How Linux Iptables Works and Examples along with the commands and outputs. You may also have a look at the following articles to learn more –

Visibility

Visible to everyone

Reading Status

Related Bookmarks

My Note


Saved!

Annotations

Export as Markdown

Attachments

+ Annotate selection

Add Annotation