Configure firewalld
to restrict loopback traffic to the lo
interface.
The loopback traffic must be trusted by assigning the lo
interface to the
firewalld
trusted
zone. However, the loopback traffic must be restricted
to the loopback interface as an anti-spoofing measure.
To configure firewalld
to restrict loopback traffic to the lo
interface,
run the following commands:
sudo firewall-cmd --permanent --zone=trusted --add-rich-rule='rule family=ipv4 source address="127.0.0.1" destination not address="127.0.0.1" drop'
sudo firewall-cmd --permanent --zone=trusted --add-rich-rule='rule family=ipv6 source address="::1" destination not address="::1" drop'
To ensure firewalld
settings are applied in runtime, run the following command:
firewall-cmd --reload