Using Firewalld instead of UFW for docker

When you use docker, you might need to move away from ufw. The good alternative seems to be firewalld.

The installation:

sudo apt update
sudo apt install firewalld
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd --state

To add things:

sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --add-port=5000/tcp --permanent
sudo firewall-cmd --reload

To list:

sudo firewall-cmd --list-all
sudo firewall-cmd --list-ports
sudo firewall-cmd --list-services

To remove things:

sudo firewall-cmd --remove-service=ssh --permanent
sudo firewall-cmd --remove-port=5000/tcp --permanent

Don’t forget to add ‘massquerade to allow outgoing trafic from docker containers , eg;
“`sudo firewall-cmd –zone=public –add-rich-rule=‘rule family=”ipv4″ source address=”172.17.0.0/16″ accept’ –permanent

sudo firewall-cmd –reload“`

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Puvox - Blog
Scroll to Top