Page 1 of 1

iptables ubuntu

Posted: Sat Jan 08, 2022 12:47 pm
by Stevyn
https://upcloud.com/community/tutorials ... es-ubuntu/

Listing current rules

Code: Select all

iptables -L --line-numbers
Iptables can track the state of the connection, so use the command below to allow established connections to continue.

Code: Select all

iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
ssh

Code: Select all

iptables -A INPUT -p tcp --dport ssh -j ACCEPT
default rule to drop will permit only specifically accepted connection

Code: Select all

iptables -P INPUT DROP
save

Code: Select all

iptables-save > /etc/iptables/rules.v4
restore

Code: Select all

iptables-restore < /etc/iptables/rules.v4
ip6tables-restore < /etc/iptables/rules.v6

Re: iptables ubuntu

Posted: Sat Jan 08, 2022 12:49 pm
by Stevyn
auto restore at boot

Code: Select all

apt-get install iptables-persistent