到本地主机的DNS查找给networking错误

我在FreeBSD的一个监狱里运行一个recursion的DNS服务器,使用pf作为防火墙。 在本地计算机上运行drill @xxx.xxx.xxx.xxx example.com (其中xxx.xxx.xxx.xxx是服务器IP)使我成功查找。

但是,如果我在服务器上同样尝试,无论是在监狱和主机…

 # drill @localhost example.com Error: error sending query: Could not send or receive, because of network error # drill @xxx.xxx.xxx.xxx example.com Error: error sending query: Could not send or receive, because of network error # drill @127.0.0.1 example.com Error: error sending query: Could not send or receive, because of network error # drill @10.0.0.1 example.com Error: error sending query: Could not send or receive, because of network error 

我已经在我的pf.conf中pass quick on lo0 all

这是我的相关ifconfig:

 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6> inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 inet 127.0.0.1 netmask 0xff000000 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6> inet 10.0.0.1 netmask 0xffffff00 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> 

DNS监狱正在10.0.0.1下运行

从我这边来的一些想法:没有限制的确实configuration正确。 该接口已经是0.0.0.0,我有访问控制规则10.0.0.0/16和127.0.0.0/8(当然我的本地机器的IP)。 另外,如果出现任何错误,试图进行钻取将产生一个简单的“拒绝”。 所以我认为这与pf有关系? 我可能错过了一些小而明显的东西,但我不知道是什么。

我想要达到的目标是在服务器上成功执行# drill @localhost example.com ,因此我可以用127.0.0.1replace我的resolv.conf名称服务器

编辑:我用netcat做了一些testing,做# nc -4 -vv localhost 53给我一个超时。 但是,使用udp作为# nc -4 -w 10 -vv -u localhost 53的协议不会。 运行# pfctl -vnf /etc/pf.conf ,这里是监狱的两个redirect:

 rdr pass on vtnet0 inet proto udp from any to any port = domain -> 10.0.0.1 port 53 rdr pass on vtnet0 inet proto tcp from any to any port = domain -> 10.0.0.1 port 53 

经过多次testingpf规则之后,我简单地让所有的stream量都通过了,并且意识到错误是当我在pf.conf中pass quick on lo0 all ,监狱正在lo1下运行。

pass quick on lo1 all添加了pass quick on lo1 all现在可以工作了。

另外请注意,从一个监狱内,你应该查询监狱IP而不是本地主机。 所以,在监狱resolv.conf中:

 nameserver 10.0.0.1