1.6 KiB
1.6 KiB
Linux+ 3.2.1: firewalld and ufw
Runtime and permanent firewalld rules, a rich rule for one source address, and ufw.
Before you start
The peer, at 10.99.0.2 (name peer), stands in for the other VM. It sits
on this VM's second network, 10.99.0.0/24 (this VM is 10.99.0.1 there,
on interface le-host). It also has a second address, 10.99.0.3, which
stands in for "anywhere else". Get a shell there with
sudo ip netns exec lepeer bash; from it, curl --interface 10.99.0.3
sends from the second address.
On this VM, the lab runs web services on ports 8080 and 9000. On the RHEL family it installs and starts firewalld, allowing SSH. Keep a console open: a firewall mistake can cut off SSH.
Tasks
- RHEL family: allow HTTP in firewalld at runtime, reload and see it gone, then allow it permanently, in the zone of the main interface.
- RHEL family: with a rich rule, allow port 8080/tcp only from the peer's
address
10.99.0.2, persistently. From the peer,curl http://10.99.0.1:8080/works, and from10.99.0.3it fails. - Ubuntu: turn on ufw, allowing OpenSSH first.
- Ubuntu: allow port 9000/tcp only from the peer's address
10.99.0.2. From the peer,curl http://10.99.0.1:9000/works, and from10.99.0.3it fails. Look at the rules withufw status numbered.
Hints
firewall-cmd --add-service,--permanent,--reload,--list-services,--get-active-zones.--add-rich-rule='rule family="ipv4" source address="..." port port="8080" protocol="tcp" accept',--list-rich-rules.ufw allow OpenSSH,ufw enable,ufw status verbose.ufw allow from ADDRESS to any port PORT proto tcp,ufw delete N.