/etc/network/interfaces 在启动时未正确加载

/etc/network/interfaces 在启动时未正确加载

我正在尝试使用 Beagleboard Black 作为无线接入点(使用 hostapd 和 dnsmasq)。我发现我可以连接(我被分配了一个 IP 地址、一个 DNS 服务器和默认路由),但我无法 ping 我的 Beagleboard Black (BBB)。

为了调试,我通过 USB 接口将笔记本电脑与 BBB 连接起来,通过 ssh 连接并运行ifconfig:(剪掉了其他接口)

wlan0     Link encap:Ethernet  HWaddr c8:3a:35:c1:32:3e  
          inet6 addr: fe80::ca3a:35ff:fec1:323e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:576 (576.0 B)

我尝试重新启动网络服务以查看是否有帮助,结果确实如此。运行service networking restart,然后ifconfig

wlan0     Link encap:Ethernet  HWaddr c8:3a:35:c1:32:3e  
          inet addr:10.10.10.1  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::ca3a:35ff:fec1:323e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:576 (576.0 B)

之后,我可以拿起我的笔记本电脑并通过 WiFi 连接到 BBB,并能够联系它。

为什么我需要手动运行service networking restart才能正确加载我的配置?


cat /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 dhcp
# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

#Wifi Hosting
auto wlan0
iface wlan0 inet static
        address 10.10.10.1
        netmask 255.255.255.0

# 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

答案1

当我将文件中auto wlan0的行更改为时,它就起作用了。allow-hotplug wlan0/etc/network/interfaces

的答案这个问题帮助过我。

相关内容