如何使用命令行设置Wifi?


9

如何使用命令行设置Wifi?

我需要进行以下设置,但失败:

目标:

Security: WEP
Network name: wifi59/7
Key/password: xyz

尝试并失败:

sudo iwconfig wlan0 mode managed
sudo iwconfig wlan0 channel 11
sudo iwconfig wlan0 essid wifi59/7
sudo iwconfig wlan0 key xyz
Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.

Answers:


7

WEP密钥应为十六进制,长度为10或26个字符(5或13个ASCII字节)。

如果要使用ASCII进行指定,则必须在其s:前面加上前缀-我不确定iwconfig是否会填充ASCII密码,但是请尝试使用5或13的长度。

请参阅man iwconfig并向下滚动到以key/enc[ryption]获取一些示例。


1
没有人能告诉我为什么s:选项永远行不通。语法有问题,堆栈溢出现在有3个未解决的问题,但没有一个得到回答。
猫头鹰

1

我认为使用networkmanager的默认命令行实用程序nm-cli更容易,更可靠。请查看nm-cli以熟悉nm-cli语法。


1

这是我的解决方案:

$sudo vi /etc/network/interfaces

#The primary network interface
auto wlan0
iface wlan0 inet static
# wireless-* options are implemented by the wireless-tools package
wireless-mode managed
wireless-essid YOUR_SSID
wireless-key1 s:YOUR_PASS
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 200.48.225.130 200.48.225.146
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.