通过 iptables 阻止路由器的 DNS 服务器

通过 iptables 阻止路由器的 DNS 服务器

我正在尝试阻止 Google DNS 服务器(8.8.8.8) 从我的路由器,因此网络中的任何机器都无法访问此 DNS 服务器。

这是我的iptables表格:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  anywhere             dns.google
DROP       all  --  dns.google           anywhere
ACCEPT     all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  anywhere             dns.google
DROP       all  --  dns.google           anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  anywhere             dns.google
DROP       all  --  dns.google           anywhere
ACCEPT     all  --  anywhere             anywhere

我是新手iptables,首先我添加了INPUTOUTPUT规则,但没有任何作用。然后FORWARD在 ping 时起作用了(我猜是因为路由器将请求转发到了互联网?):

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

没有 ping 通8.8.8.8. 但仍然可以使用8.8.8.8作为 DNS 服务器:

$ nslookup superuser.com 8.8.8.8
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   superuser.com
Address: 104.18.43.79
Name:   superuser.com
Address: 172.64.144.177

问题是什么?另外,我仍然无法弄清楚每个链中的source和之间的区别destination(如果网络上的机器发起连接到8.8.8.8例如路由器看到8.8.8.8作为目的地,当路由器收到来自8.8.8.8它看到8.8.8.8作为来源?

谢谢。

相关内容