呃,管理/设置网络需要root权限就不说了……NetworkManager的无线也是要关掉的……
- 无密码或wep验证的wifi
- 很简单,直接用iwconfig设置就可以了
iwconfig wlp3s0 essid "YOUR_SSID" [ key "YOUR_PASS" ];
- wpa验证的wifi(同样可以用于无密码和wep验证的wifi,见具体内容)
- 首先得运行wpa_supplicant,大概像这样:
(以上是最基本的参数,加上-B则后台运行,加上-d则输出debug信息,-D指定驱动)wpa_supplicant -iwlp3s0 -c/etc/wpa_supplicant/wpa_supplicant.conf;
- 然后就要运行wpa_cli了
添加网络,执行后会返回网络号 NID,后面会用到,对应的是remove_network
add_network
设置网络属性,对应的是 get_network,属性列表见下面的表格
set_network NID ssid “YOUR_SSID”;#设置网络ssid
#set_network NID key_mgmt "WPA-PSK";#wep或无验证时这里需要设置为NONE,wpa-psk可以省略
set_network NID psk “YOUR_PASS”;#设置密码,wep验证时把psk换成wep_key0,无密码时省略- 启用网络,成功后会有类似CONNECT TO "YOUR_SSID"的提示,对应的是disable_network
enable_network NID
然后就可以退出了quit
- 退出后使用dhclient获取一下网络地址,没问题的话就可以使用了
dhclient wlp3s0;
======华丽的分割线======
wpa_cli中set_network/get_network的相应的参数如下表:
Key | Description | Parameters |
ssid | Access point name | string |
id_str | String identifying the network | string |
priority | Connection priority over other APs | number (0 being the default low priority) |
bssid | Mac address of the access point | mac address |
scan_ssid | Enable/disbale ssid scan | 0, 1, 2 |
key_mgmt | Type of key management | WPA-PSK, WPA_EAP, None |
pairwise | Pairwise ciphers for WPA | CCMP, TKIP |
group=TKIP | Group ciphers for WPA | CCMP, TKIP, WEP104, WEP40 |
psk | Pre-Shared Key (clear or encrypted) | string |
wep_key0 | WEP key (up to 4: wep_key[0123]) | string |
eap | Extensible Authentication Protocol | MD5, MSCHAPV2, OTP, GTC, TLS, PEAP, TTLS |
identity | EAP identity string | string |
password | EAP password | string |
ca_cert | Pathname to CA certificate file | /full/path/to/certificate |
client_cert | Pathname to client certificate | /full/path/to/certificate (PEM/DER) |
private_key | Pathname to a client private key file | /full/path/to/private_key (PEM/DER/PFX) |
======华丽的分割线======