使用自定义 tun 接口时 OS X DNS 查询失败

使用自定义 tun 接口时 OS X DNS 查询失败

我有一个针对 OS X 10.10.5 的稍作修改的 tun/tap 版本正在运行。该接口由一个小型 Python 脚本启动,该脚本读取/dev/tun所有请求,然后通过临时连接转发这些请求。启动接口时,我手动将 IP 设置为10.0.0.1子网掩码:255.255.255.0和 DNS:。8.8.8.8但是,每当我尝试执行 DNS 请求时,它都会告诉我连接超时,而且我从未在 WireShark 中看到发出的 DNS 查询。我的目标是路由所有流量,/dev/tun但无法弄清楚 DNS 为何不起作用。以下是我当前的路由:

$ netstat -r
Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            10.0.0.1           UGSc            3        0    tun0
default            link#6             UCSI            2        0     en0
10.0.0.1           10.0.0.1           UHr             5        2    tun0
17.155.127.222     link#6             UHRLWI          0       60     en0     10
17.155.127.223     link#6             UHRLWIi         2       30     en0     10
127                localhost          UCS             0        0     lo0
localhost          localhost          UH              3   235135     lo0
169.254            link#6             UCS             3        0     en0
rivera.local       link#6             UHLSW           1        1     en0
iphone-2.local     b4:18:d1:5b:57:98  UHLSW           1       10     en0   1195
169.254.185.223/32 link#6             UCS             0        0     en0
169.254.255.255    ff:ff:ff:ff:ff:ff  UHLWb           0       23     en0

Internet6:
Destination        Gateway            Flags         Netif Expire
::                 link#6             UC              en0
default            tun0               USc            tun0
::                 fe80::62f8:1dff:fe UcI            tun0
localhost          localhost          UHL             lo0
::ffff:10.0.0.1    link#15            UHL             lo0
::ffff:10.0.0.1    link#6             UHLWI           en0
rivera.local       60:f8:1d:cc:24:14  UHL             lo0
fe80::%lo0         fe80::1%lo0        UcI             lo0
fe80::1%lo0        link#1             UHLI            lo0
fe80::%en0         link#6             UCI             en0
iphone-2.local     b4:18:d1:5b:57:98  UHLWIi          en0
rivera.local       60:f8:1d:cc:24:14  UHLI            lo0
fe80::%tun0        fe80::62f8:1dff:fe UcI            tun0
fe80::62f8:1dff:fe link#15            UHLI            lo0
fe80::%utun0       fe80::4570:eb3:1c6 UcI           utun0
fe80::4570:eb3:1c6 link#16            UHLI            lo0
ff01::%lo0         localhost          UmCI            lo0
ff01::%en0         link#6             UmCI            en0
ff01::%en6         link#11            UmCI            en6
ff01::%tun0        fe80::62f8:1dff:fe UmCI           tun0
ff01::%utun0       fe80::4570:eb3:1c6 UmCI          utun0
ff02::%lo0         localhost          UmCI            lo0
ff02::%en0         link#6             UmCI            en0
ff02::%en6         link#11            UmCI            en6
ff02::%tun0        fe80::62f8:1dff:fe UmCI           tun0
ff02::%utun0       fe80::4570:eb3:1c6 UmCI          utun0

我在“系统偏好设置”->“网络”下指定了 DNS 服务器(8.8.8.8),但运行时$ scutil --dns没有显示任何内容resolver #1

DNS configuration

resolver #1

resolver #2
  domain   : local
  options  : mdns
  timeout  : 5
  order    : 300000

resolver #3
  domain   : 254.169.in-addr.arpa
  options  : mdns
  timeout  : 5
  order    : 300200

resolver #4
  domain   : 8.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  order    : 300400

resolver #5
  domain   : 9.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  order    : 300600

resolver #6
  domain   : a.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  order    : 300800

resolver #7
  domain   : b.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  order    : 301000

有人能告诉我为什么 DNS 不工作吗?

相关内容