iptables ubuntu

Let us talk about scripts, HTML, Perl, PHP, apache, etc.
Post Reply
User avatar
Stevyn
SysOp
Posts:1786
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:
iptables ubuntu

Post by Stevyn » Sat Jan 08, 2022 12:47 pm

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
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

User avatar
Stevyn
SysOp
Posts:1786
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:

Re: iptables ubuntu

Post by Stevyn » Sat Jan 08, 2022 12:49 pm

auto restore at boot

Code: Select all

apt-get install iptables-persistent
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

Post Reply