我发现我的ISP(verizon)正在拦截端口53上的所有DNS通信。
我想使用iptables将所有DNS查找流量重定向到特定的IP和端口(5353)。我的计算机在端口53上连接到另一台计算机的任何尝试都应重定向到23.226.230.72:5353。
为了验证我要使用的DNS服务器和端口,我已经运行了此命令。
~$ dig +short serverfault.com @23.226.230.72 -p5353
198.252.206.16
这是我要使用的iptables规则。
iptables -t nat -A OUTPUT -p udp -m udp --dport 53 -j DNAT --to-destination 23.226.230.72:5353
添加该规则后,未找到所有DNS查找。网站ping返回unknown host
。网页上说“找不到服务器”。
~$ mtr serverfault.com
Failed to resolve host: Name or service not known
我希望从23.226.230.72:5353提取DNS查询。如何使iptables规则起作用?
编辑
我的ISP演示了DNS(端口53)拦截。跟踪从dig的输出通过端口5353到端口23.226.230.72,然后通过端口53。
~$ dig +trace stackexchange.com @23.226.230.72 -p5353
; <<>> DiG 9.9.5-3-Ubuntu <<>> +trace stackexchange.com @23.226.230.72 -p5353
;; global options: +cmd
. 86395 IN NS ns7.opennic.glue.
. 86395 IN NS ns4.opennic.glue.
. 86395 IN NS ns3.opennic.glue.
. 86395 IN NS ns5.opennic.glue.
. 86395 IN NS ns2.opennic.glue.
. 86395 IN NS ns10.opennic.glue.
. 86395 IN NS ns1.opennic.glue.
. 86395 IN NS ns6.opennic.glue.
. 86395 IN NS ns8.opennic.glue.
dig: couldn't get address for 'ns8.opennic.glue': no more
~$ dig +trace stackexchange.com @23.226.230.72 -p53
; <<>> DiG 9.9.5-3-Ubuntu <<>> +trace stackexchange.com @23.226.230.72 -p53
;; global options: +cmd
. 7440 IN NS f.root-servers.net.
. 7440 IN NS d.root-servers.net.
. 7440 IN NS j.root-servers.net.
. 7440 IN NS i.root-servers.net.
. 7440 IN NS g.root-servers.net.
. 7440 IN NS k.root-servers.net.
. 7440 IN NS a.root-servers.net.
. 7440 IN NS h.root-servers.net.
. 7440 IN NS e.root-servers.net.
. 7440 IN NS m.root-servers.net.
. 7440 IN NS c.root-servers.net.
. 7440 IN NS b.root-servers.net.
. 7440 IN NS l.root-servers.net.
;; Received 239 bytes from 23.226.230.72#53(23.226.230.72) in 2948 ms
stackexchange.com. 215 IN A 198.252.206.16
;; Received 62 bytes from 192.228.79.201#53(b.root-servers.net) in 116 ms
我当前的iptables。 iptables-save
~# iptables-save
# Generated by iptables-save v1.4.21 on Tue Jul 15 23:06:52 2014
*mangle
:PREROUTING ACCEPT [79950528:41742899703]
:INPUT ACCEPT [78748282:41360159554]
:FORWARD ACCEPT [13:5427]
:OUTPUT ACCEPT [85455483:57472640071]
:POSTROUTING ACCEPT [85480442:57475512901]
-A POSTROUTING -o lxcbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
# Completed on Tue Jul 15 23:06:52 2014
# Generated by iptables-save v1.4.21 on Tue Jul 15 23:06:52 2014
*nat
:PREROUTING ACCEPT [71:18713]
:INPUT ACCEPT [7:474]
:OUTPUT ACCEPT [109:7855]
:POSTROUTING ACCEPT [109:7855]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.0/16 ! -d 172.17.0.0/16 -j MASQUERADE
-A POSTROUTING -s 10.0.3.0/24 ! -d 10.0.3.0/24 -j MASQUERADE
COMMIT
# Completed on Tue Jul 15 23:06:52 2014
# Generated by iptables-save v1.4.21 on Tue Jul 15 23:06:52 2014
*filter
:INPUT ACCEPT [78748139:41360144354]
:FORWARD ACCEPT [13:5427]
:OUTPUT ACCEPT [85454926:57472600172]
:fail2ban-ssh - [0:0]
:fail2ban-vsftpd - [0:0]
-A INPUT -p tcp -m multiport --dports 21,20,990,989 -j fail2ban-vsftpd
-A INPUT -p tcp -m multiport --dports 22,6622 -j fail2ban-ssh
-A INPUT -i lxcbr0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i lxcbr0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i lxcbr0 -p tcp -m tcp --dport 67 -j ACCEPT
-A INPUT -i lxcbr0 -p udp -m udp --dport 67 -j ACCEPT
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -o lxcbr0 -j ACCEPT
-A FORWARD -i lxcbr0 -j ACCEPT
-A fail2ban-ssh -j RETURN
-A fail2ban-vsftpd -j RETURN
COMMIT
iptables rules
位置
8.8.8.8
和8.8.4.4