I would like to block all outgoing traffic to any domain or subdomain using IPTables. It would appear that the -d
option allows one to reference a domain. I found the following through a Google search that suggests it can be referenced this way: Allow HTTP traffic only to specific domain(s)
Similarly, we can use the above method to filter other ports and protocols as well, such as standard web traffic operating on tcp port 80.
iptables -I FORWARD 1 -p tcp -d dd-wrt.com --dport 80 -j ACCEPT
iptables -I FORWARD 2 -p tcp --dport 80 -j DROP
Which would accept all http traffic to dd-wrt.com, while blocking outgoing http traffic to anywhere else. If you wish to allow multiple sites, insert additional rules before the DROP (making sure to order and number them correctly).
However what I would like to do is reference *.domain.com (e.g. block all outgoing traffic to *.youtube.com or similar).
Does anyone know if this is possible and if so, what is the syntax for the -d
option in IPTables to support a wildcard subdomain?