I made my computer a dual system before and added a centos7 server. Now I can't connect to the Internet at home when I go home for the holidays, and I'm all worried. .
After some investigation, I finally connected, leaving a note for future reference, haha.
1. First, switch to the super administrative user
[user@localhost]$ su root
2. Check the currently available network cards. The network cards marked in red are not all the same.
[root@localhost]$ iw dev
phy#0
Interface wlp2s0
ifindex 3
wdev 0x1
addr a4:db:30:84:4b:1c
type managed
[root@localhost]# iw dev
phy#0
Interface wlp2s0
ifindex 3
wdev 0x1
addr a4:db:30:84:4b:1c
ssid liylr
type managed
channel 11 (2462 MHz), width: 40 MHz, center1: 2452 MHz
ssid is the name of the broadcast channel, which is your wireless network signal, and the broadcast channel is the last
3. View the initial state before connection
[root@ localhost]# ifconfig wlp2s0
wlp2s0: flags=4098 < BROADCAST,MULTICAST> mtu 1500
ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet)
RX packets 13547 bytes 13381624 (12.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12659 bytes 1974514 (1.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
4. Test whether the network is connected
[root@ localhost]# iw wlp2s0 link
Not connected.
5. Get SSID
[root@ localhost]# iw wlp2s0 scan | grep SSID
command failed: Network is down (-100)
The wireless network is not activated, please activate it first.
[root@ localhost]# ifconfig wlp2s0 up
[root@ localhost]# ifconfig wlp2s0
wlp2s0: flags=4099 < UP,BROADCAST,MULTICAST> mtu 1500
ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet)
RX packets 13547 bytes 13381624 (12.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12659 bytes 1974514 (1.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
6. View all available wireless network signals
[root@localhost]# iw wlp2s0 scan | grep SSID
SSID: USER-20150101NS_Network_2
SSID: Tenda_17BEF8
SSID: PC-20140723DBVC_Network_1
SSID: 123
SSID: Tenda_0A6410
SSID: xiaohui
SSID: Tenda_51E4F0
SSID: Nobody Can
SSID: TP-LINK_3C479
7. Connect to wireless network
[root@localhost]# wpa_supplicant -B -i wlp2s0 -c <(wpa_passphrase "Tenda_17BEF8" "useradmin")
Successfully initialized wpa_supplicant
Tenda_17BEF8 is the SSID you want to connect to, and useradmin is the link password.
8. Assign IP address (obtain IP through network card control through dhclient)
[root@localhost]# dhclient wlp2s0
9. Finally, check the wireless network card address information. If there is an IP address, it means the network connection is successful
[root@ localhost]# ifconfig wlp2s0
wlp2s0: flags=4163< UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.168.139 netmask 255.255.255.0 broadcast 192.168.168.255
inet6 fe80::62d8:19ff:fecc:7484 prefixlen 64 scopeid 0x20
ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet)
RX packets 13567 bytes 13386147 (12.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12682 bytes 1979923 (1.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The above is the detailed content of CentOS7 command line tutorial for connecting to wireless network. For more information, please follow other related articles on the PHP Chinese website!