待连接的WIFI的ssid为“thm”,密码为12345678,认证方式为WPA2-PSK
1. 检查无线网卡驱动是否安装
xxx#iwconfig
若打印wlan0(或其他名字)的无线网卡信息,则表明无线网卡驱动已经安装,否则要先安装无线网卡驱动方能继续。
2. 配置/etc/sysconfig/network-scripts/ifcfg-wlan0
我的配置文件内容为:
DEVICE=wlan0
HWADDR=9C:4E::9A::
TYPE=Wireless
UUID=f017bd9c-eebf-46fc-823c-7f76cc8d5abf
ONBOOT=no
NM_CONTROLLED=yes
BOOTPROTO=dhcp
ESSID="thm"
3. 安装工具wpa_supplicant
xxx#yum install wpa_supplicant
4. 配置/etc/wpa_supplicant/wpa_supplicant.conf,写入相关ssid和对应的密码
xxx#wpa_passphrase thm >> /etc/wpa_supplicant/wpa_supplicant.conf
我的配置文件内容为:
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel network={
ssid="thm"
#psk=""
psk=eabb3e1572789c41a1600051b1235e03c0787c88fc527f6597cd29cb5a707822
5. 后台运行wpa_supplicant进程
xxx#wpa_supplicant -B -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
6. 搜索无线网络
xxx#iwlist wlan0 scan | grep ESSID
7. 连接无线网络
xxx#iwconfig wlan0 essid "thm"
8. dhcp方式获取ip
xxx#dhclient wlan0
9. 测试网络是否联通
xxx#ping www.baidu.com