红联Linux门户
Linux帮助

Arch Linux命令行配置WiFi网络连接

发布时间:2016-10-31 22:17:08来源:topspeedsnail.com作者:斗大的熊猫
安装完Arch Linux之后,最基本的任务就是连接网络。本帖介绍怎么在Arch Linux命令行终端中设置WiFi连接。
在开始配置wifi连接之前确保你有root权限(sudo)。
 
扫描wifi热点
查看wifi网络接口:
iwconfig  # 无线网卡接口的名字一般是wlan0/wlp2s0
开启网络接口(注意替换网络接口名):
ip link set wlan0 up
# 关闭网络接口:
ip link set wlan0 up
# 关闭网络接口:
ip link set wlan0 down
扫描周围的WiFi热点:
iwlist wlan0 scan | less
 
使用netctl设置wifi网络连接
在开始配置之前,确保Arch Linux已安装了兼容的无线网卡驱动。
lspci -k | less
查看内核是否加载了无线网卡驱动,示例输出:
02:00.0 Network controller: Qualcomm Atheros AR928X Wireless Network Adapter (PCI-Express)
Subsystem: Quanta Microsystems, Inc Em306 802.11bgn Wireless Half-size Mini PCIe Card
Kernel driver In use: ath9k
Kernel modules : ath9k
如果你的系统没有加载无线网卡驱动,你需要使用有线网络连接安装无线网卡驱动。参考:https://wireless.wiki.kernel.org。Linux一般都安装有兼容无线网卡驱动。
运行wifi-menu:
wifi-menu
Arch Linux命令行配置WiFi网络连接
选择要连接的wifi热点,输入密码连接。
ping测试:
ping -c 3 blog.topspeedsnail.com
wifi-menu是使用对话框的形式自动设置连接(配置一些网络连接信息),你还可以手动设置这些连接参数。设置方法如下:
创建Wi-Fi连接配置文件:
cd /etc/netctl/examples
cp /etc/netctl/examples/wireless-wpa /etc/netctl/your_profile
编辑这个配置文件:
vim /etc/netctl/your_profile
更改如下参数:
Interface: wlan0   # 无线网络接口
ESSID: <wifi热点名>
key: <wifi密码>
连接wifi热点:
ls /etc/netctl
netctl start your_profile
netctl enable your_profile   # 开机自动连接
 
使用iw
iw dev wlan0 link
iw dev wlan0 scan 
iw dev wlan0 connect your_essid
iw dev wlan0 connect your_essid key your_key   # WEP
 
其它方法
wpa_supplicant:https://wiki.archlinux.org/index.php/WPA_supplicant
Wicd:https://wiki.archlinux.org/index.php/wicd
NetworkManager:https://wiki.archlinux.org/index.php/NetworkManager
 
本文永久更新地址:http://www.linuxdiyf.com/linux/25593.html