Commands useful for debugging iptables

 

 

 


It is a very popular utility firewall. With this tool, firewall rules can be configured very easily and for enhanced security. You can use these commands to debug IP tables, which we will cover in this tutorial.

 


 

 

 

Let’s start,




 

1. To view the current firewall rules:



 

iptables -L -v

 

 

 

2. You can temporarily disable the firewall by flushing all rules. Use this command.

 

 

sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F

 

 

 

3. If you want to block everything, drop all packets on all chains. Execute the following command.

 

 

 

sudo iptables -P INPUT DROP
sudo iptables -P OUTPUT DROP
sudo iptables -P FORWARD DROP

 

 

 

 

 

Here’s an example of allowing SSH, HTTP, and HTTPS access.

 

 

 

 

 

Step 1: The INPUT chain should include the following rule:

 

 

sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT

 



If you wish, you can add the following rule to the INPUT chain to Drop everything else, Use the following command.



sudo iptables -A INPUT -j DROP

 




We hope this tutorial is informative for you!.









Try VPSie for free today!

 



 

 

Get the most out of learning with VPSie.com