{"id":1714,"date":"2022-08-30T12:30:00","date_gmt":"2022-08-30T17:30:00","guid":{"rendered":"https:\/\/linuxhostsupport.com\/blog\/?p=1714"},"modified":"2022-08-30T10:18:28","modified_gmt":"2022-08-30T15:18:28","slug":"10-useful-iptables-commands-in-linux","status":"publish","type":"post","link":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/","title":{"rendered":"10 Useful iptables Commands in Linux"},"content":{"rendered":"\n<div id=\"linux-3857202605\" class=\"linux-before-1st-paragraph linux-entity-placement\" style=\"margin-top: 15px;margin-bottom: 15px;\"><a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting\/?mtm_campaign=blogs&#038;mtm_source=lhs&#038;mtm_medium=blog&#038;mtm_content=managed-vps&#038;mtm_cid=1339&#038;mtm_placement=inline\" aria-label=\"Untitled\"><img src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340090_NVMeGoogleAds_728x90_041322.jpg\" alt=\"\"  srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340090_NVMeGoogleAds_728x90_041322.jpg 728w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340090_NVMeGoogleAds_728x90_041322-300x37.jpg 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" width=\"728\" height=\"90\"  style=\"display: inline-block;\" \/><\/a><\/div><p>In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro.<\/p>\n\n\n\n<p>Iptables on <a href=\"https:\/\/linuxhostsupport.com\/\">Linux servers<\/a> are used for controlling the incoming and outgoing web traffic. The traffic is controlled by the iptables rules in the firewall written by system administrators or users familiar with Linux servers. The rules in iptables are stored in tables that have chains for every defined rule. In this blog post, we are going to use Ubuntu 22.04 as OS, but you can choose any distro if you want to try these iptables commands by yourself. Let&#8217;s get started!<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Fresh install of Ubuntu 22.04 OS<\/li><li>User privileges: root or non-root user with sudo privileges<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Update the System<\/h2>\n\n\n\n<p>Before we start with the basic iptables rules we are going to update the system packages to the latest versions available.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt update -y &amp;&amp; sudo apt upgrade -y<\/pre>\n\n\n\n<p>Once, the system is updated we are ready to show you the basic iptables commands in Linux.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install iptables service<\/h2>\n\n\n\n<p>To install the iptables service execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get install iptables -y<\/pre>\n\n\n\n<p>Once, the iptables service is installed we can proceed with the basic iptables rules in the next paragraphs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Check iptables rules<\/h2>\n\n\n\n<p>Since, we installed the iptables service and we did not add any rule, checking the iptables rules should give you empty output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -nvL<\/pre>\n\n\n\n<p>You should receive the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# iptables -nvL\nChain INPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n\nChain FORWARD (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n\nChain OUTPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Whitelist IP Address<\/h2>\n\n\n\n<p>Sometimes the users are not able to access the website, or the server thus we need to whitelist their IP address manually with the following command:<\/p>\n\n\n\n<p>iptables -A INPUT -s 192.168.1.1 -j ACCEPT<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Block IP Address<\/h2>\n\n\n\n<p>If there are continuous attacks on the server, or the owner do not want some IP addresses to have access on his server, we can easily block them with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -A INPUT -s 192.168.0.1 -j DROP<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. Block Host in iptables<\/h2>\n\n\n\n<p>Sometimes we need to block the whole host in the iptables rules. For example to block <strong>google.com<\/strong> in the iptables rules first you need to find the IP address and the CIDR with the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">host google.com<\/pre>\n\n\n\n<p>You should receive the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# host google.com\ngoogle.com has address 172.217.4.46\ngoogle.com has IPv6 address 2607:f8b0:4004:c07::64\ngoogle.com has IPv6 address 2607:f8b0:4004:c07::8b\ngoogle.com has IPv6 address 2607:f8b0:4004:c07::65\ngoogle.com has IPv6 address 2607:f8b0:4004:c07::71\ngoogle.com mail is handled by 10 smtp.google.com.\n<\/pre>\n\n\n\n<p>Now, to find the CIDR execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">whois 172.217.4.46 | grep CIDR<\/pre>\n\n\n\n<p>You should receive the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# whois 172.217.4.46 | grep CIDR\nCIDR:           172.217.0.0\/16<\/pre>\n\n\n\n<p>We have everything that we need to block the google network. Just execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -A OUTPUT -p tcp -d 172.217.0.0\/16 -j DROP<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. Block Specific Port<\/h2>\n\n\n\n<p>For example if we do not want some specific port to be accessible from outside, we can easily block it. To block outgoing connections on the MySQL <strong>3306<\/strong> port via iptables rules execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -A OUTPUT -p tcp --dport 3306 -j DROP<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">6. Grant Access to multiple ports<\/h2>\n\n\n\n<p>To allow multuple ports for incoming connections execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -A INPUT  -p tcp -m multiport --dports 80,443 -j ACCEPT<\/pre>\n\n\n\n<p>To allow multuple ports for outgoing connections execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -A OUTPUT -p tcp -m multiport --sports 80,443 -j ACCEPT<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">7. Port Forwarding<\/h2>\n\n\n\n<p>To set up port forwarding and forward for example port 80 to port 443 execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 443<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">8. Save iptables rules<\/h2>\n\n\n\n<p>For example to save all these iptables commands you need to execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables-save<\/pre>\n\n\n\n<p>You should receive the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# iptables-save\n# Generated by iptables-save v1.8.7 on Fri Jul 22 23:52:08 2022\n*filter\n:INPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n-A INPUT -s 192.168.0.1\/32 -j ACCEPT\n-A INPUT -s 192.168.0.1\/32 -j DROP\n-A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT\n-A OUTPUT -d 172.217.0.0\/16 -p tcp -j DROP\n-A OUTPUT -p tcp -m tcp --dport 3306 -j DROP\n-A OUTPUT -p tcp -m multiport --sports 80,443 -j ACCEPT\nCOMMIT\n# Completed on Fri Jul 22 23:52:08 2022\n# Generated by iptables-save v1.8.7 on Fri Jul 22 23:52:08 2022\n*nat\n:PREROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 443\nCOMMIT\n# Completed on Fri Jul 22 23:52:08 2022<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">9. Flush iptables rules<\/h2>\n\n\n\n<p>To flush all iptables rules we set in the previuous steps you need to execute the command <strong>iptables -F<\/strong> but first check the ouput of <strong>iptables -nvL<\/strong> to check the previously set up rules:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -nvL<\/pre>\n\n\n\n<p>If you followed the previous commands you should receive the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# iptables -nvL\nChain INPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n    0     0 ACCEPT     all  --  *      *       192.168.0.1          0.0.0.0\/0\n    0     0 DROP       all  --  *      *       192.168.0.1          0.0.0.0\/0\n    1    60 ACCEPT     tcp  --  *      *       0.0.0.0\/0            0.0.0.0\/0            multiport dports 80,443\n\nChain FORWARD (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n\nChain OUTPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n    0     0 DROP       tcp  --  *      *       0.0.0.0\/0            172.217.0.0\/16\n    0     0 DROP       tcp  --  *      *       0.0.0.0\/0            0.0.0.0\/0            tcp dpt:3306\n    1    40 ACCEPT     tcp  --  *      *       0.0.0.0\/0            0.0.0.0\/0            multiport sports 80,443<\/pre>\n\n\n\n<p>Now, you can flush the rules with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">iptables -F<\/pre>\n\n\n\n<p>Now, if you execute the command <strong>iptables -nvL<\/strong> to list the current rules you should receive an empty output similar in the first step above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# iptables -nvL\nChain INPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n\nChain FORWARD (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n\nChain OUTPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">10. Man command for iptables<\/h2>\n\n\n\n<p>If you want to know, everything about the iptables command and the parameters that can be used, execute the <strong>man iptables<\/strong> and you will receive the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@host:~# man iptables\nIPTABLES(8)                                                                iptables 1.8.7                                                               IPTABLES(8)\n\nNAME\n       iptables\/ip6tables \u2014 administration tool for IPv4\/IPv6 packet filtering and NAT\n\nSYNOPSIS\n       iptables [-t table] {-A|-C|-D} chain rule-specification\n\n       ip6tables [-t table] {-A|-C|-D} chain rule-specification\n\n       iptables [-t table] -I chain [rulenum] rule-specification\n\n       iptables [-t table] -R chain rulenum rule-specification\n\n       iptables [-t table] -D chain rulenum\n\n       iptables [-t table] -S [chain [rulenum]]\n\n       iptables [-t table] {-F|-L|-Z} [chain [rulenum]] [options...]\n\n       iptables [-t table] -N chain\n\n       iptables [-t table] -X [chain]\n\n       iptables [-t table] -P chain target\n\n       iptables [-t table] -E old-chain-name new-chain-name\n\n       rule-specification = [matches...] [target]\n\n       match = -m matchname [per-match-options]\n\n       target = -j targetname [per-target-options]\n\nDESCRIPTION\n       Iptables and ip6tables are used to set up, maintain, and inspect the tables of IPv4 and IPv6 packet filter rules in the Linux kernel.  Several different ta\u2010\n       bles may be defined.  Each table contains a number of built-in chains and may also contain user-defined chains.<\/pre>\n\n\n\n<p>Congratulations! You successfully practiced the 10 most used iptables in Linux. If you have difficulties understanding the commands all you need to do is sign up for one of our <a href=\"https:\/\/www.rosehosting.com\/nvme-hosting\/\">NVMe VPS plans<\/a> and submit a support ticket. Our admins are available 24\/7 and will help you with the request immediately.<\/p>\n\n\n\n<p>If you liked this about 10 useful iptables commands in Linux with an example, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below.<\/p><div id=\"linux-3832916496\" class=\"linux-after-8th-paragraph linux-entity-placement\" style=\"margin-top: 15px;margin-bottom: 15px;\"><a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting\/?mtm_campaign=blogs&#038;mtm_source=lhs&#038;mtm_medium=blog&#038;mtm_content=managed-vps&#038;mtm_cid=1340&#038;mtm_placement=inline\" aria-label=\"Untitled\"><img src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340095_VPSGoogleAds_728x90_042622.jpg\" alt=\"\"  srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340095_VPSGoogleAds_728x90_042622.jpg 728w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340095_VPSGoogleAds_728x90_042622-300x37.jpg 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" width=\"728\" height=\"90\"  style=\"display: inline-block;\" \/><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Iptables on Linux servers are used for controlling the incoming and outgoing web traffic. The traffic is controlled by the iptables rules in the firewall written by system administrators or users familiar with Linux servers. The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1715,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[226,225,45],"class_list":["post-1714","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-commands","tag-iptables","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>10 Useful iptables Commands in Linux | LinuxHostSupport<\/title>\n<meta name=\"description\" content=\"In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Let&#039;s get started\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"10 Useful iptables Commands in Linux | LinuxHostSupport\" \/>\n<meta property=\"og:description\" content=\"In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Let&#039;s get started\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxHostSupport\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/linuxhostsupport\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-30T17:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"372\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lnxhostsupport\" \/>\n<meta name=\"twitter:site\" content=\"@lnxhostsupport\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb\"},\"headline\":\"10 Useful iptables Commands in Linux\",\"datePublished\":\"2022-08-30T17:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\"},\"wordCount\":677,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp\",\"keywords\":[\"commands\",\"iptables\",\"linux\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\",\"url\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\",\"name\":\"10 Useful iptables Commands in Linux | LinuxHostSupport\",\"isPartOf\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp\",\"datePublished\":\"2022-08-30T17:30:00+00:00\",\"author\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb\"},\"description\":\"In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Let's get started\",\"breadcrumb\":{\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage\",\"url\":\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp\",\"contentUrl\":\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp\",\"width\":742,\"height\":372,\"caption\":\"10 useful iptables commands in linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/linuxhostsupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"10 Useful iptables Commands in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/#website\",\"url\":\"https:\/\/linuxhostsupport.com\/blog\/\",\"name\":\"LinuxHostSupport\",\"description\":\"Linux Tutorials and Guides\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/linuxhostsupport.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\/\/linuxhostsupport.com\/blog\/author\/r0s3admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"10 Useful iptables Commands in Linux | LinuxHostSupport","description":"In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Let's get started","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"10 Useful iptables Commands in Linux | LinuxHostSupport","og_description":"In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Let's get started","og_url":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/","og_site_name":"LinuxHostSupport","article_publisher":"https:\/\/www.facebook.com\/linuxhostsupport","article_published_time":"2022-08-30T17:30:00+00:00","og_image":[{"width":742,"height":372,"url":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_creator":"@lnxhostsupport","twitter_site":"@lnxhostsupport","twitter_misc":{"Written by":"admin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#article","isPartOf":{"@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/"},"author":{"name":"admin","@id":"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb"},"headline":"10 Useful iptables Commands in Linux","datePublished":"2022-08-30T17:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/"},"wordCount":677,"commentCount":0,"image":{"@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp","keywords":["commands","iptables","linux"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/","url":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/","name":"10 Useful iptables Commands in Linux | LinuxHostSupport","isPartOf":{"@id":"https:\/\/linuxhostsupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp","datePublished":"2022-08-30T17:30:00+00:00","author":{"@id":"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb"},"description":"In this tutorial we are going to explain to you 10 useful iptables commands applicable in any Linux distro. Let's get started","breadcrumb":{"@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#primaryimage","url":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp","contentUrl":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2022\/08\/10-useful-iptables-commands-in-linux.webp","width":742,"height":372,"caption":"10 useful iptables commands in linux"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxhostsupport.com\/blog\/10-useful-iptables-commands-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxhostsupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"10 Useful iptables Commands in Linux"}]},{"@type":"WebSite","@id":"https:\/\/linuxhostsupport.com\/blog\/#website","url":"https:\/\/linuxhostsupport.com\/blog\/","name":"LinuxHostSupport","description":"Linux Tutorials and Guides","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxhostsupport.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/linuxhostsupport.com\/blog\/author\/r0s3admin\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts\/1714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/comments?post=1714"}],"version-history":[{"count":1,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts\/1714\/revisions"}],"predecessor-version":[{"id":1716,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts\/1714\/revisions\/1716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/media\/1715"}],"wp:attachment":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/media?parent=1714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/categories?post=1714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/tags?post=1714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}