iptables:implement_a_basic_firewall
This is an old revision of the document!
IPTables - Implement a basic firewall
Install iptables
sudo apt-get install iptables
Block all connections from the IP address 10.10.10.10.
iptables -A INPUT -s 10.10.10.10 -j DROP
Block all of the IP addresses in the 10.10.10.0/24 network range.
iptables -A INPUT -s 10.10.10.0/24 -j DROP
or
iptables -A INPUT -s 10.10.10.0/255.255.255.0 -j DROP
Block SSH connections from 10.10.10.10.
iptables -A INPUT -p tcp --dport ssh -s 10.10.10.10 -j DROP
Block SSH connections from any IP address.
iptables -A INPUT -p tcp --dport ssh -j DROP
Connection States
iptables -A INPUT -p tcp --dport ssh -s 10.10.10.10 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp --sport 22 -d 10.10.10.10 -m state --state ESTABLISHED -j ACCEPT
iptables/implement_a_basic_firewall.1475848137.txt.gz · Last modified: 2020/07/15 09:30 (external edit)