linux无线网卡连接网络

涉及命令

命令 说明
ifconfig eth0 up/down 网卡的启用/禁用
service network restart 重新启动网卡。如果刚插上网卡需要重启获取ip
dhclient eth0 自动分配ip
wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant.conf -B 启动wpa server

正文

  1. 启动wpa_supplicant服务
wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant.conf -B
  1. 启动wpa_cli
> scan
OK
<3>CTRL-EVENT-SCAN-RESULTS 
> scan_result
bssid / frequency / signal level / flags / ssid
6c:59:40:ec:7d:b4    2422  -66    [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]    [lizhiyong](http://www.uplooking.club/)
50:fa:84:25:9b:72    2472  -82    [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]    \xe4\xbd\xa0\xe6\x98\xaf\xe8\x83\x86\xe5\xb0\x8f\xe9\xac\xbc
> add_net 
1
> set_net 1 ssid "lizhiyong"
OK
> set_net 1 psk "[lzylgq12345678](http://www.uplooking.club/)​"
OK
> select_net 1
OK
> enable_net 1
OK
> q
  1. dhcpcd wlan0或dhclient wlan0
  2. 开机自动连接wifi
[root@linux:~] vi /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
update_config=1

network={
        ssid="lizhiyong"
        psk="lzylgq12345678"
} 

[root@linux:~] vi /etc/init.d/rcS
ifconfig wlan0 up
/usr/sbin/wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -B
dhcpcd wlan0 
[root@linux:~] chkconfig --add rcS
[root@linux:~] chkconfig rcS on

你可能感兴趣的:(linux无线网卡连接网络)