在 beaglebone black 中设置 ip 静态后无法访问互联网

在 beaglebone black 中设置 ip 静态后无法访问互联网

我正在尝试将我的 Beaglebone black 中的 IP 设为静态。为此我遵循本教程。根据教程进行更改后,我的 /etc/network/interfaces 文件如下所示:-

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo

iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static

address 192.168.24.38
network 192.168.24.0
broadcast 192.168.24.255
netmask 255.255.252.0
gateway 192.168.25.10

# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

# The secondary network interface
#auto eth1
#iface eth1 inet dhcp

# WiFi Example
#auto wlan0
#iface wlan0 inet dhcp
#    wpa-ssid "essid"
#    wpa-psk  "password"

# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
# Note on some boards, usb0 is automaticly setup with an init script
iface usb0 inet static
    address 192.168.7.2
    netmask 255.255.255.0
    network 192.168.7.0
    gateway 192.168.7.1

重新启动我的 Beaglebone black 后,我可以使用命令看到我的 IP 是静态 IP ifconfig。这是命令的输出ifconfig

eth0      Link encap:Ethernet  HWaddr d0:39:72:3b:da:e8  
          inet addr:192.168.24.38  Bcast:192.168.24.255  Mask:255.255.252.0
          inet6 addr: fe80::d239:72ff:fe3b:dae8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3352 errors:0 dropped:63 overruns:0 frame:0
          TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:329055 (321.3 KiB)  TX bytes:10701 (10.4 KiB)
          Interrupt:40 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:79 (79.0 B)  TX bytes:79 (79.0 B)

usb0      Link encap:Ethernet  HWaddr 66:b8:b3:7a:c3:19  
          inet addr:192.168.7.2  Bcast:192.168.7.3  Mask:255.255.255.252
          inet6 addr: fe80::64b8:b3ff:fe7a:c319/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:88 errors:0 dropped:0 overruns:0 frame:0
          TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13642 (13.3 KiB)  TX bytes:17130 (16.7 KiB)

但现在我无法访问互联网。所以。请告诉我我的设置哪里有错误。谢谢

根据建议,命令的输出ip route是:-

  default via 192.168.25.10 dev eth0 
    192.168.7.0/30 dev usb0  proto kernel  scope link  src 192.168.7.2 
    192.168.24.0/22 dev eth0  proto kernel  scope link  src 192.168.24.38

命令的输出ping -c1 google.com

ping:未知主机 google.com

命令的输出 netstat -nr

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.7.0     0.0.0.0         255.255.255.252 U         0 0          0 usb0

答案1

输出 ping 和 netstat 命令确认路由一切正常。然而 DHCP 还提供 DNS/解析器设置数据。 DNS解析失败。

请编辑您的 /etc/resolv.conf 并将其填写为:

nameserver 8.8.8.8

此时 ping google.com 应该可以正常工作。

稍后与您的公司交谈,询问他们的内部域(yourdomain.xx)和他们的名称服务器的IP(localnameserver)

并将其更改为:

search yourdomain.xx
nameserver localnameserver

相关内容