iptables ubuntu
Posted: Sat Jan 08, 2022 12:47 pm
https://upcloud.com/community/tutorials ... es-ubuntu/
Listing current rules
Iptables can track the state of the connection, so use the command below to allow established connections to continue.
ssh
default rule to drop will permit only specifically accepted connection
save
restore
Listing current rules
Code: Select all
iptables -L --line-numbers
Code: Select all
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
Code: Select all
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
Code: Select all
iptables -P INPUT DROP
Code: Select all
iptables-save > /etc/iptables/rules.v4
Code: Select all
iptables-restore < /etc/iptables/rules.v4
ip6tables-restore < /etc/iptables/rules.v6