Resolved: Arch Linux WiFi issue

When I connected my laptop running Arch Linux to a new WiFi this morning, it worked for a brief moment then all connections were dropped. Connecting to the same WiFi with phone or Macbook works fine so the problem is at Arch LInux(AL)’s end.

Then I noticed if I do a route it actually showed 2 entries for the LAN. I took a closer look and saw there were 2 IPs for the wireless interface!

Strange enough if I connect to the hotspot of my phone, AL will also have 2 IPs but the connection is still working.

So I googled a bit why there will be 2 IPs, here’s what I got:

https://raspberrypi.stackexchange.com/questions/13359/where-does-my-secondary-ip-come-from

Finally, after I shutdown and disabled the dhcpcd service with

sudo systemctl disable dhcpcd
sudo systemctl stop dhcpcd

and restarted NetworkManager, the problem is fixed. Guess some WiFi AP is more tolerant than others.

🙂

Ubuntu Server 11.04 + TP-LINK WN821N

用Ubuntu Desktop版, 连接wifi非常容易, 甚至比Windows还容易: 因为你基本不用去找wifi无线网卡的驱动了. 但如果是只有CLI命令行的Server版呢?

当然有人会反问, 谁会用无线方式连接一台服务器呢? 我有一套旧的Atom330, 闲着也是闲着, 就拿它做个测试服务器玩玩. 但是我又不能容忍它在身边的嗡嗡声(风扇不够高级呵呵). 于是我把它放到阳台上, 只连上电源线, 网络就靠wifi了.

首先要看看Ubuntu Server是否支持WN821N这个USB-wifi适配器. 接好后, 运行:

$ifconfig -a

如果结果里有’wlan0’的一段, 说明系统已支持. 我安装的Ubuntu Server 11.04版无需修改已支持WN821N. 下一步是修改网络接口配置文件/etc/network/interfaces. 未经过配置的interfaces文件大致是这样吧:

auto lo
iface lo inet loopback

修改后的如下(修改需要sudo):

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address		192.168.1.18
gateway		192.168.1.1
netmask		255.255.255.0
network		192.168.1.0
broadcast	192.168.1.255
wpa-driver	wext
wpa-ssid	<your wifi essid>
wpa-ap-scan 	1
wpa-proto	RSN
wpa-pairwise	CCMP
wpa-group	CCMP
wpa-key-mgmt	WPA-PSK
wpa-psk		<your hex key>

其中<your wifi essid>就是你的无线路由的id, 例如TP-LINK123什么的. 由于WEP加密方式早就被破解了(听说过蹭网对吧), 所以我这只针对WPA2加密方式. 例子中的RSN/CCMP对应的是无线路由里的WPA2/AES, 如果你那没有WPA2/AES只有WPA/TKIP, 就要写成

wpa-proto	WPA
wpa-pairwise	TKIP
wpa-group	TKIP

<your hex key>这个的获得方法是:

$wpa_passphrase <your wifi essid> <your WPA key>
network={
ssid=”<your wifi essid>”
#psk=”<your WPA key>”
psk=fe727aa8b64ac9b3f54c72432da14faed933ea511ecab1 5bbc6c52e7522f709a
}

上面加重的那段hex就是<your hex key>. 然后重启一下网络组件:

$sudo invoke-rc.d networking restart

如果没有报错, 就基本成功了. 可以用iwconfig看看状态:

$iwconfig

lo        no wireless extensions.

eth1      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"<your wifi essid"
          Mode:Managed  Frequency:2.422 GHz  Access Point: 94:0C:6D:11:A6:00
          Bit Rate=270 Mb/s   Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=70/70  Signal level=-34 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

完成 🙂

参考链接: http://ubuntuforums.org/showthread.php?t=318539