{"id":23227,"date":"2020-12-09T10:13:21","date_gmt":"2020-12-09T02:13:21","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&p=23227"},"modified":"2022-09-08T20:00:14","modified_gmt":"2022-09-08T12:00:14","slug":"how-to-check-if-ip-is-blocked-from-iptables-2","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/how-to-check-if-ip-is-blocked-from-iptables-2","title":{"rendered":"HOW TO: Check if IP is blocked from IPtables"},"content":{"rendered":"\t\t
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\tChecking if an IP is blocked in IPTABLES<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
Iptables<\/strong> is a program that utilizes policy chains to configure the IP packet filter rules<\/strong> of Linux kernel firewall in order to allow or block traffic. For instance,\u00a0this firewall can be installed to your Linux Dedicated<\/a> or Virtual Server<\/a>\u00a0to secure your server workloads. Let’s say if a user attempts to SSH into your server, iptables\u00a0<\/strong>will try to match the IP address and port to a rule in the input chain.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Check if IP is blocked:<\/strong><\/p> iptables -L -n \u2013line | grep [IP Address]<\/p> If IP appear as DROP or REJECT, the IP in the IPTable has been blocked<\/p> Therefore, you would need to unblock<\/strong> the IP Address:<\/p> iptables -I INPUT -s [IP Address] -j ACCEPT<\/p> And this is how to block back an IP Address:<\/p> iptables -A INPUT -d [IP Address] -j DROP<\/p> service iptables save<\/p> ===============================================================<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Step 1<\/strong> of 3<\/p> Firstly, to check if the CSF has blocked the IP, please execute the following command:<\/p> csf -g IP_address<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Note: IP_address being the specific IP you wish to check.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Step\u00a02<\/strong> of 3<\/p> Secondly, if the IP is denied and you wish to remove it, please execute the following command:<\/p> csf -dr IP_address<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Step 3<\/strong> of 3<\/p> Lastly, to complete the process, you will need to restart CSF for the changes to take effect:<\/p> csf -r<\/p> ==============================================================<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Note: The ull path to IPTABLES is \/sbin\/iptables, but you can replace command # iptables with \/sbin\/iptables<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Click to read-> HOW TO: Block all ports in IPtables<\/em><\/a><\/p>To unblock an IP from the CSF from SSH, please follow the steps below:<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t