第一步:编辑网络配置
root@beaglebone:/home/debian# vim /etc/network/interfaces
有线网络配置为固定IP,无线网络配置为动态IP
# 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
#热插拔配置
allow-hotplug eth0
#静态IP
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
gateway 192.168.0.1
##connman: ethX static config
#connmanctl services
#Using the appropriate ethernet service, tell connman to setup a static IP address for that service:
#sudo connmanctl config <service> --ipv4 manual <ip_addr> <netmask> <gateway> --nameservers <dns_server>
##connman: WiFi
#
#connmanctl
#connmanctl> tether wifi off
#connmanctl> enable wifi
#connmanctl> scan wifi
#connmanctl> services
#connmanctl> agent on
#connmanctl> connect wifi_*_managed_psk
#connmanctl> quit
auto wlan0
iface wlan0 inet dhcp
pre-up ip link set wlan0 up
pre-up iwconfig wlan0 essid WIFI名称
wpa-ssid WIFI名称
wpa-psk WIFI密码
# Ethernet/RNDIS gadget (g_ether)
# Used by: /opt/scripts/boot/autoconfigure_usb0.sh
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.252
network 192.168.7.0
gateway 192.168.7.1
保存退出
第二步:关闭NetworkManager,否则网络无法更新配置,并且报错
root@beaglebone:/home/debian# systemctl stop NetworkManager.service
root@beaglebone:/home/debian# systemctl disable NetworkManager.service
第三步:关闭connman,否则无线网络无法连接,并且报错
root@beaglebone:/home/debian# /etc/init.d/connman stop
[ ok ] Stopping connman (via systemctl): connman.service.
第四步:重启系统
root@beaglebone:/home/debian# reboot
完成。
过程记录:网络配置完成也可以执行networking restart生效(必须关闭connman)。
root@beaglebone:/home/debian# /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.
未关闭connman时如下结果:
root@beaglebone:/home/debian# /etc/init.d/networking restart
[....] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.
failed!
WIFI配置后可以使用ifup命令启动连接(必须关闭connman):
root@beaglebone:/home/debian# ifup wlan0
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
parse_option_param: Bad format d
Listening on LPF/wlan0/60:ee:5c:22:e5:53
Sending on LPF/wlan0/60:ee:5c:22:e5:53
Sending on Socket/fallback
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.3.1
bound to 192.168.3.20 -- renewal in 34724 seconds.
未关闭connman时如下结果:
root@beaglebone:/home/debian# ifup wlan0
wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
Failed to bring up wlan0.
其他:
WIFI驱动正常时执行扫描,iwlist wlan0 scan,是可以扫描到WiFi的
root@beaglebone:/home/debian# iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: xx:xx:xx:xx:xx:xx
ESSID:"xx"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:144 Mb/s
Extra:rsn_ie=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Quality=0/100 Signal level=2/100
Cell 02 - Address: xx:xx:xx:xx:xx:xx
ESSID:"xxxxxx"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.412 GHz (Channel 1)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality:0 Signal level:0 Noise level:0
WIF配置的另一种方法,执行WIFI密码配置
wpa_passphrase WIFI名称 WIFI密码 > /etc/wpa_supplicant.conf
生成的wpa_supplicant.conf内容
network={
ssid="WIFI名称"
#psk="WIFI密码"
psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
执行链接WIFI
wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B