I am trying to get my firewalld to block an ip
address with the rules:
sudo firewall-cmd --zone=block --add-source=<ip_address/submask> --permanent
, and also adding thisrichrule
to the default zone (public)sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address=<ip_address> reject
, then finally I reload the rule withsudo firewall-cmd --reload
But still I can navigate to the sites in my browser. Obviously I am doing some thing wrong. How can I block access to any webpage using firewalld
.
These are my zone rules set:
block (active)
interfaces: enp0s3
sources: 172.217.5.110/32 216.49.176.33/32
services:
ports:
protocols:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
public (default, active)
interfaces: docker0
sources:
services: dhcpv6-client ssh
ports: 993/tcp 995/udp 995/tcp 22161/udp 4243/tcp 22/tcp 22/udp 465/tcp
protocols:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
Ok after a lot of digging I finally got it to work. It requires I add what is called a
direct rule
, so to block an ip like216.49.176.33
the rule to add would be:Then reload with:
To see the added rules:
Now remove the interface from the default zone which in my case was
public
as the rule says if:To remove I used;
NOTE:
After this you will have to clear browsing data from the browser(s) involved and after that you will be unable to access that ip address and note I also used the
mask
32 to make sure those ip's that have with multiple ip's pointing to their domain will be block.I also Of course the
CHAIN
option can beINPUT
to prevent in ward bound traffic as well. The option--dport=<80|443>
is used to catch bothhttp
andhttps
traffics.Usage: