ubuntu命令行下无线上网

1、启动wifi模

ifconfig -a
ifconfig wlan0 up
ifconfig

2、扫描热点

iwlist wlan0 scanning

3、建立wpa_supplicant.conf

  $ vim /etc/wpa_supplicant.conf
  1 ctrl_interface=/var/run/wpa_supplicant
  2 update_config=1
  3 ctrl_interface_group=root
  4 ap_scan=1
  5 network={
  6         ssid="Mingdu"
  7         key_mgmt=WPA-PSK
  8         pairwise=TKIP CCMP
  9         group=CCMP TKIP
 10         psk="mdzh170518"
 11 }

4、连接到路由器

sudo wpa_supplicant -Dwext -iwlp2s0 -c /etc/wpa_supplicant.conf

5、给模块分配ip

自动分配

udhcpc -i wlp2s0

手动分配

ifconfig wlp2s0 192.168.20.80
1、 如果使用静态ip,注意dns设置,能ping通网关不能上网一般都是dns未设置好

2、若第4步出现问题,删除/run/wpa_supplicant 目录下的网口模块

猜你喜欢

转载自blog.csdn.net/weixin_42205011/article/details/88343726