下载吧电脑学习

分类分类

CentOS7怎么用命令行链接wifi

2017-05-10 20:00作者:下载吧

 CentOS7怎么用命令行链接wifi?来看看步骤吧

CentOS7怎么用命令行链接wifi

  1、首先,切换到超级管理用户

  [user@localhost]$ su root

  2、检查当前可用的网卡,红色标记的就是网卡,这个并不是都是相同的

  [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就是广播信道名称,也就是你的无线网络信号,广播信道就是最后一个

  3、查看连接前的初始状态

  [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、测试是否已经链接网络

  [root@ localhost]# iw wlp2s0 link

  Not connected.

  5、获取SSID

  [root@ localhost]# iw wlp2s0 scan | grep SSID

  command failed: Network is down (-100)

  无线网络未激活,先激活。

  [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、查看所有可用的无线网络信号

  [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、连接无线网

  [root@localhost]# wpa_supplicant -B -i wlp2s0 -c <(wpa_passphrase "Tenda_17BEF8" "useradmin")

  Successfully initialized wpa_supplicant

  Tenda_17BEF8是你想链接的SSID,useradmin为链接密码。

  8、分配IP地址(通过dhclient控制网卡进行网络操作获取IP)

  [root@localhost]# dhclient wlp2s0

  9、最后,查看无线网卡地址信息,有ip地址表示网络连接成功了

  [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

展开全部

相关教程