常用的查询命令
ifconfig 查询网卡信息(仅查询启动的接口)
ifconfig -a 查询所有的网卡信息
lsusb :查看系统中的USB设备 ——需要安装usbutils:apt install usbutils
iwconfig 查看无线网络 (查看哪一个接口支持无线连接) ——需要安装iw:apt install iw
sudo iwconfig wlanX up 启动无线网络:
ip link set wlanx up
ifup wlanx
sudo iwconfig wlanX down 关闭无线网络:
ip link set wlanx down
ifdown wlanx
sudo iw dev wlan0 scan | less 扫描附近的无线网络
lspci | grep -i ethernet 查看网卡型号
lsmod 查看当前系统加载的模块信息
rfkill list 查看无线网络
rfkill unblock all 启动无线网络
rfkill block all 取消无线网络
iwlist scaningn 查看所有可用的wifi接入点
安装network-mannager管理网络使用以下命令
首先使用命令:sudo killall wpa_supplicant 结束使用的wpa_supplicant进程
apt-get install network-manager 安装network-mannager
nmcli dev wifi 查看附近的无线网络(根据信号强度)
ifdown eth0 关闭网卡
ifup eth0 开启网卡
注意使用ifdown 和 ifup 时需要将网卡加入到目录 /etc/network/interface 中
方法一 :运行wpa_supplicant程序;
执行:wpa_supplicant -d -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
其中:
-d :增加调试信息
-D wext :wext,nl80211驱动名称
-i wlan0 :wlan0,网络接口名称
/system/sbin/wpa_supplicant :wpa_supplicant可执行程序path
/da
注意事项:
安全设置:None
安全设置:WPA-PSK
| WPA-PSK & TKIP | WPA-PSK & AES | WPA-PSK & TKIP+AES |
SSID | **** | **** | **** |
proto | WPA | WPA | WPA |
key_mgmt | WPA-PSK | WPA-PSK | WPA-PSK |
pairwise | TKIP | CCMP | TKIP CCMP |
psk | **** | **** | **** |
安全设置:WPA2-PSK
| WPA2-PSK & TKIP | WPA2-PSK & AES | WPA2-PSK & TKIP+AES |
SSID | **** | **** | **** |
proto | RSN | RSN | RSN |
key_mgmt | WPA-PSK | WPA-PSK | WPA-PSK |
pairwise | TKIP | CCMP | TKIP CCMP |
psk | **** | **** | **** |
安全设置:WPA-PSK/WPA2-PSK
| WPA-PSK/WPA2-PSK & TKIP | WPA-PSK/WPA2-PSK & AES | WPA-PSK/WPA2-PSK & AES+TKIP |
SSID | **** | **** | **** |
proto | WPA RSN | WPA RSN | WPA RSN |
key_mgmt | WPA-PSK | WPA-PSK | WPA-PSK |
pairwise | TKIP | CCMP | TKIP CCMP |
psk | **** | **** | **** |
方法二:运行命令行工具wpa_cli ;
执行 :wpa_cli -i wlan0 -p /var/run/wpa_supplicant
注,--p /var/run/wpa_supplicant中的wpa_supplicant并不是可执行程序,而是个控制套接字。
此时会进入交互模式。其中交互模式的命令如下表:
Full command Short command | Description | |
status | stat | displays the current connection status |
disconnect | disc | prevents wpa_supplicant from connecting to any access point |
quit | q | exits wpa_cli |
terminate | term | kills wpa_supplicant |
reconfigure | recon | reloads wpa_supplicant with the configuration file supplied (-c parameter) |
scan | scan | scans for available access points (on |
scan_result | scan_r | displays the results of the last scan |
list_networks | list_n | displays a list of configured networks and their status (active or not, enabled or disabled) |
select_network | select_n | select a network among those defined to initiate a connection (ie select_network 0) |
enable_network | enable_n | makes a configured network available for selection (ie enable_network 0) |
disable_network | disable_n | makes a configured network unavailable for selection (ie disable_network 0) |
remove_network | remove_n | removes a network and its configuration from the list (ie remove_network 0) |
add_network | add_n | adds a new network to the list. Its id will be created automatically |
set_network | set_n | shows a very short list of available options to configure a network when supplied with no parameters. See next section for a list of extremely useful parameters to be used with set_network and get_network. |
get_network | get_n | displays the required parameter for the specified network. See next section for a list of parameters |
save_config | save_c | saves the configuration |
如果您想连接的网络是没有加密的,您可以用下面的命令直接连接:
- $ sudo iw dev wlan0 connect [网络 SSID]
如果网络是用 WEP 加密的,也非常容易:
- $ sudo iw dev wlan0 connect [网络 SSID] key 0:[WEP 密钥]