1.切换到超级用户
# su root
2.查询可用的无线网卡,加粗为网卡名称
# iw dev
phy#0
Interfacewls1
ifindex 2
wdev 0x1
addr 00:26:c6:c8:a1:96
type managed
3.启用无线卡
# ip link set wls1 up
4.查看无线网卡连接情况
# iw wls1 link
Not connected. (表示没有任何连接)
(以下连接成功)
Connected to 2e:f0:a2:c7:2a:aa (on wls1)
SSID: Huawei
freq: 2437
RX: 1349315 bytes (12110 packets)
TX: 21864 bytes (169 packets)
signal: -38 dBm
tx bitrate: 65.0 MBit/s MCS 7
bss flags: short-slot-time
dtim period: 3
beacon int: 100
5.查看所有可用的无线网络信号
# iw wls1 scan | grep SSID
6.连接无线网
# wpa_supplicant -B -i wls1 -c <(wpa_passphrase "ssid" "password")
7.分配IP地址(通过dhclient控制网卡进行网络操作获取IP)
# dhclient wls1
8.查看无线网卡地址信息,有ip地址表示网络连接成功了
# ip addr show wls1
9.设置开机自动连接WiFi
9.1设置NetworkManager自动启动
# chkconfig NetworkManager on
报错的话,用下面的命令
# systemctl enable NetworkManager.service
9.2 安装NetworkManager-wifi
yum -y install NetworkManager-wifi
9.3 开启WiFi
nmcli r wifi on
9.4查看有信号的WiFi【需要先断开WiFi,在无连接的情况下,下面的命令才会有效果】
nmcli dev wifi
9.5连接(无线网ssid,密码psk)
nmcli d wifi connect "ssid" password "psk" wls1
9.6reboot
重启,就会发现自动连接WiFi了。