Aim:
Learn about iptables in Linux and how to use it to control incoming and outgoing network traffic.
What is iptables?
Iptables is a user-space utility program that allows a system administrator to configure IP packet filter rules in the Linux kernel firewall, implemented as different Netfilter modules. It is a powerful tool for managing network security by defining rules for packet filtering, network address translation (NAT), and other packet mangling operations.
Blocking Incoming Packets for a Port
- Block incoming packets for a specific port (e.g., port 80):
sudo iptables -A INPUT -p tcp --dport 80 -j DROP
Blocking Outgoing Packets for a Port
- Block outgoing packets for a specific port (e.g., port 443):
sudo iptables -A OUTPUT -p tcp --dport 443 -j DROP
Blocking Tomcat Port Using iptables
- Assuming Tomcat is running on port 8080, block incoming packets for the Tomcat port:
sudo iptables -A INPUT -p tcp --dport 8080 -j DROP
Verification:
View the current iptables rules:
sudo iptables -L
Comments
Post a Comment