I need to block all outgoing traffic to a domain with all its subdomains.
I tried to do something like this:
sudo ufw deny out from any to *.domain.com
but of course it doesn't work because it needs an IP number.
How can I do this?
I need to block all outgoing traffic to a domain with all its subdomains.
I tried to do something like this:
sudo ufw deny out from any to *.domain.com
but of course it doesn't work because it needs an IP number.
How can I do this?
You can do this more reliably with hosts.deny
in just a few seconds:
hosts.deny
as root
:
sudo vi /etc/hosts.deny
ALL : .domain.com
The preceding dot in .domain.com
is important. Do not forget it
iptables
are domain-aware - they are only IP aware. They are not built to do base-domain filtration, you would need something more akin to a customized DNS server with RPZ zones to deny lookups from succeeding for that domain, and then point your system's DNS to that. I am writing instructions to do this myself for my blog, but no idea when I'll have a complete answer for that. – Thomas Ward Jan 31 '23 at 15:30