{"id":333,"date":"2014-08-10T14:47:21","date_gmt":"2014-08-10T08:47:21","guid":{"rendered":"http:\/\/hasibul.info\/blog\/?p=333"},"modified":"2014-08-10T14:47:21","modified_gmt":"2014-08-10T08:47:21","slug":"how-to-block-ip-address-in-linux-using-iptables-rule","status":"publish","type":"post","link":"https:\/\/hasibul.info\/blog\/2014\/08\/10\/how-to-block-ip-address-in-linux-using-iptables-rule\/","title":{"rendered":"How to block IP address in Linux &#8211; Using IPTables Rule"},"content":{"rendered":"<p>Using <strong>IPTables<\/strong> rules we can block a Single IP address or a block of IP Addresses.<\/p>\n<p>The following command (via ssh) will drop any packet coming from the IP address 1.2.3.4\u00a0:<\/p>\n<blockquote><p># <strong>iptables -I INPUT -s 1.2.3.4 -j DROP<\/strong><\/p><\/blockquote>\n<p>or you can use append<\/p>\n<blockquote><p># <strong>iptables -A INPUT -s 1.2.3.4 -j DROP<\/strong><\/p><\/blockquote>\n<h2><strong>How To\u00a0Block Subnet (ip.Add.re.ss\/subnet):<\/strong><\/h2>\n<p>If your Machines public interface card name is eth1 and if you&#8217;d like to block the subnet 10.0.0.0\/8 -Use the following syntax:<\/p>\n<blockquote><p># <strong>iptables -i eth1 -A INPUT -s 10.0.0.0\/8 -j DROP<\/strong><\/p><\/blockquote>\n<h2><strong>How to\u00a0View Blocked IP Address(es):<\/strong><\/h2>\n<p>Simply use the following command:<\/p>\n<blockquote><p># <strong>iptables -L -v<\/strong><\/p><\/blockquote>\n<h2><strong>How to\u00a0Save Blocked IP Address(es) in IPTables:<\/strong><\/h2>\n<blockquote><p># <strong>service iptables save<\/strong><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Using IPTables rules we can block a Single IP address or a block of IP Addresses. The following command (via ssh) will drop any packet coming from the IP address 1.2.3.4\u00a0: # iptables -I INPUT -s 1.2.3.4 -j DROP or you can use append # iptables -A INPUT -s 1.2.3.4 -j DROP How To\u00a0Block Subnet&hellip;<\/p>","protected":false},"author":1,"featured_media":335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,6,12,1],"tags":[123,109,111,112,122,113,95,119,120,121],"how-to":[],"_links":{"self":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/posts\/333"}],"collection":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/comments?post=333"}],"version-history":[{"count":0,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/media\/335"}],"wp:attachment":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/tags?post=333"},{"taxonomy":"how-to","embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/how-to?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}