Curl 返回 ststus 6(DNS 名称错误地址错误)

Curl returned ststus 6 (DNS name bad address error)

当我的两个接口中的一个(3g-cell)打开时,我无法解析主机名。一个接口是 WAN(以太网),而另一个是 3g-Cell。

当 WAN 关闭时,我尝试执行手动 curl 请求,我可以使用 3g-cell 接口执行此操作,但无法使用主机名执行此操作。 (同样发生在 ping - 使用的终端命令

ping -I 3g-cell www.google.com

我认为这是 dns 服务器或 dhcp 的问题。在这里,WAN 似乎可以正确解析 DNS 名称,而小区不能。

(我也在研究 OpenWRT(Linux))

我认为这与其中一些配置文件有关。

如果您知道这个问题,请告诉我。

谢谢。

/etc/config/dhcp:

config dnsmasq 'setup'
       option domainneeded '1'
       option boguspriv '1'
       option filterwin2k '0'
       option localise_queries '1'
       option rebind_protection '1'
       option rebind_localhost '1'
       option local '/lan/'
       option expandhosts '1'
       option nonegcache '0'
       option readethers '1'
       option leasefile '/tmp/dhcp.leases'
       option resolvfile '/tmp/resolv.conf.auto'
       option authoritative '0'
       option dhcpleasemax '40'
       option domain 'iobot-net'

config dhcp 'lan'
       option interface 'lan'
       option leasetime '120m'
       option start '200'
       option limit '40'
       option dhcp_option '1,255.255.255.0  3,10.130.1.1  6,8.8.8.8,8.8.4.4'
       option dhcpv6 'disabled'

config dhcp 'wan'
       option interface 'wan'
       option ignore '1'

config odhcpd 'odhcpd'
       option maindhcp '0'
       option leasefile '/tmp/hosts/odhcpd'
       option leasetrigger '/usr/sbin/odhcpd-update'

/etc/resolv.conf:

 nameserver 8.8.8.8
 nameserver 8.8.4.4

/etc/config/network:

 config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

 config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option dns '8.8.8.8'
        option ifname 'eth0'
        option netmask '255.255.255.0'
        option ipaddr '10.130.1.1'
        option gateway '255.255.255.255'

 config interface
        option ifname 'bat0'

 config interface 'mesh_0'
        option proto 'static'
        option mtu '1528'
        option ipaddr '10.10.1.20'
        option netmask '255.255.255.0'

 config interface 'wan'
        option ifname 'eth1'
        option proto 'dhcp'
        option defaultroute '1'

 config interface 'cell'
        option ifname 'ppp0'
        option proto '3g'
        option device '/dev/ttyACM0'
        option apn 'api.devicewise.com/api'
        option service 'umts'
        option defaultroute '0'

/etc/config/firewall

我相信那是因为您在 interface 'cell' 配置部分设置了 defaultroute '0' 选项。因此,当 wan 关闭时,您不再有默认路由(通过在控制台中发出 ip route 命令来检查它)。

要使用两个接口(wan 和 cell),您需要安装 mwan3 软件包 - 当其中一个出现故障时,它会在接口之间切换。

我找到路了。 /etc/config/network 文件在 wan 和 cell 接口中缺少以下行。

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config interface 'lan'
    option type 'bridge'
    option proto 'static'
    option dns '8.8.8.8'
    option ifname 'eth0'
    option netmask '255.255.255.0'
    option ipaddr '10.130.1.1'
    option gateway '255.255.255.255'

config interface
    option ifname 'bat0'

config interface 'mesh_0'
    option proto 'static'
    option mtu '1528'
    option ipaddr '10.10.1.20'
    option netmask '255.255.255.0'

config interface 'wan'
    option ifname 'eth1'
    option proto 'dhcp'
    option metric '40'

config interface 'cell'
    option ifname 'ppp0'
    option proto '3g'
    option device '/dev/ttyACM0'
    option apn 'api.devicewise.com/api'
    option service 'umts'
    option metric '50'

您需要为不同的界面使用不同的metric_number。 metric_number 取决于您的优先级。 在这里,我希望以太网接口一直工作,但如果它出现故障,那么网络应该继续使用 3g-cell,这就是为什么我的 metric_number 用于 WAN 的原因很低。