1.切换到超级用户
[root@study ~]# su root
2.查询可用的无线网卡,其中Interface 后接的为网卡号
[root@study ~]# iw dev
phy#0
Interface wlo1
ifindex 23
wdev 0x1
addr xx:xx:xx:xx:xx:xx
type managed
3.启用无线卡
[root@study ~]# ip link set wlo1 up
4.查看无线网卡连接情况
[root@study ~]# iw wlo1 link
Not connected. (表示没有任何连接)
(以下连接成功)
Connected to 2e:f0:a2:c7:2a:aa (on wlo1)
SSID:CMCC-Tj22
freq: 24372
RX: 35615 bytes (263 packets)
TX: 1159 bytes (11 packets)
signal: -45 dBm
tx bitrate: 65.0 MBit/s MCS 7
bss flags: short-slot-time
dtim period: 1
beacon int: 100
5.查看所有可用的无线网络信号
[root@study ~]# iw wls1 scan | grep SSID
SSID: TP-LINK_F5BC
SSID:CMCC-Tj22
SSID: Chinanet-UUUU
SSID: Chinanet-sM2j
SSID: 504
SSID: CMCC-9G32
SSID: clarence
SSID: Tenda_0B6E78
6.连接无线网
[root@study ~]# wpa_supplicant -B -i wlo1 -c <(wpa_passphrase "CMCC-Tj22" "123456")
Successfully initialized wpa_supplicant
注意:其中CMCC-Tj22为要连接到的wifi信号SSID,123456为无线网络的密码,请替换掉
7.分配IP地址(通过dhclient控制网卡进行网络操作获取IP)
[root@study ~]# dhclient wlo1
8.查看无线网卡地址信息,有ip地址表示网络连接成功了,可以上网冲浪咯
[root@centos-servce ~]# ip addr show wlo1
2: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 11:11:11:11:11:11 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.9/24 brd 192.168.1.1 scope global dynamic wlo1
valid_lft 86386sec preferred_lft 86386sec
inet6 fe80::5eac:c4ff:fec6:e194/64 scope link
valid_lft forever preferred_lft forever
7
备注:修改文件后可以采用以下命令行打开无线网
wpa_supplicant -i wlo1 -c /etc/wpa_supplicant/wpa_supplicant.conf
dhcpcd wlo1