OS环境: Centos-7.2-x86_64
无线网卡:EP-DB1608
1.系统环境准备
#关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
#安装一大堆库
yum -y install gcc gcc-c++ lib libtool glib2-devel glib* zlib*
2.进入安装
[root@p_w_picpath linux]# ls
android_ref_codes_JB_4.2 document install.sh readme.txt WiFi_Direct_User_Interface wpa_supplicant_hostapd
android_ref_codes_KK_4.4 driver mp_tools ReleaseNotes.pdf wireless_tools
[root@p_w_picpath linux]# chmod +x install.sh
[root@p_w_picpath linux]# ./install.sh
... ...
make: *** /lib/modules/3.10.0-327.el7.x86_64/build: 没有那个文件或目录
... ...
解决思路:
切换到其目录下:
[root@p_w_picpath linux]# cd /lib/modules/3.10.0-
3.10.0-327.el7.x86_64/ 3.10.0-514.2.2.el7.x86_64/
[root@p_w_picpath linux]# cd /lib/modules/3.10.0-514.2.2.el7.x86_64/
[root@p_w_picpath 3.10.0-514.2.2.el7.x86_64]# ls
build modules.alias modules.builtin modules.dep.bin modules.modesetting modules.softdep source weak-updates
extra modules.alias.bin modules.builtin.bin modules.devname modules.networking modules.symbols updates
kernel modules.block modules.dep modules.drm modules.order modules.symbols.bin vdso
[root@p_w_picpath 3.10.0-514.2.2.el7.x86_64]# ls -lhd build
lrwxrwxrwx 1 root root 42 12月 28 10:19 build -> /usr/src/kernels/3.10.0-514.2.2.el7.x86_64
解决办法:
[root@p_w_picpath linux]# ln -s /usr/src/kernels/3.10.0-514.2.2.el7.x86_64 /lib/modules/3.10.0-327.el7.x86_64/build
然后再次执行
[root@p_w_picpath linux]# ./install.sh
一切顺利,然后查看网卡,这里节省篇幅,就不显示全部了,
[root@p_w_picpath linux]# ip link
... ...
11: enp0s20u2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DORMANT qlen 1000
link/ether e8:4e:06:40:cc:10 brd ff:ff:ff:ff:ff:ff
... ...
假如是上面图片里型号的网卡,可以对比一下网卡的MAC地址(e8:4e:06)这个是每个厂商唯一的标识由专门的组织去规划,然后你就可以确认这个是你需要的无线网卡啦,我一开始也不知道这样装完就好了,直到我装第二遍。。。 。。。
3.扫描周围的wifi信号
再次进入到光盘提供的驱动目录下
[root@p_w_picpath linux]# ls
android_ref_codes_JB_4.2 document install.sh readme.txt WiFi_Direct_User_Interface wpa_supplicant_hostapd
android_ref_codes_KK_4.4 driver mp_tools ReleaseNotes.pdf wireless_tools
[root@p_w_picpath linux]# cd wireless_tools/
[root@p_w_picpath wireless_tools]# ls
wireless_tools.30.rtl.tar.gz
[root@p_w_picpath wireless_tools]# tar -xf wireless_tools.30.rtl.tar.gz
[root@p_w_picpath wireless_tools]# cd wireless_tools.30.rtl/
[root@p_w_picpath wireless_tools.30.rtl]# make && make install
注意下面红色的字体
... ...
install -m 755 -d /usr/local/lib
install -m 644 libiw.a /usr/local/lib
install -m 755 -d /usr/local/sbin
install -m 755 iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename /usr/local/sbin
install -m 755 -d /usr/local/include
install -m 644 iwlib.h /usr/local/include
install -m 644 wireless.h /usr/local/include
for lang in . cs fr.*; do \
install -m 755 -d /usr/local/man/$lang/man8/; \
install -m 644 $lang/iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8 /usr/local/man/$lang/man8/; \
install -m 755 -d /usr/local/man/$lang/man7/; \
install -m 644 $lang/wireless.7 /usr/local/man/$lang/man7/; \
install -m 755 -d /usr/local/man/$lang/man5/; \
install -m 644 $lang/iftab.5 /usr/local/man/$lang/man5/; \
done
记得返回下执行结果
[root@p_w_picpath wireless_tools.30.rtl]# echo $?
结果为 0 表示正确
[root@p_w_picpath wireless_tools.30.rtl]# cd /usr/local/sbin/
[root@p_w_picpath sbin]# ll
总用量 3172
-rwxr-xr-x 1 root root 57928 12月 28 11:17 ifrename
-rwxr-xr-x 1 root root 50864 12月 28 11:17 iwconfig
-rwxr-xr-x 1 root root 42456 12月 28 11:17 iwevent
-rwxr-xr-x 1 root root 37912 12月 28 11:17 iwgetid
-rwxr-xr-x 1 root root 55816 12月 28 11:17 iwlist
-rwxr-xr-x 1 root root 37688 12月 28 11:17 iwpriv
-rwxr-xr-x 1 root root 37664 12月 28 11:17 iwspy
扫描周围wifi信号
[root@p_w_picpath linux]# iwlist enp0s20u6 scanning
enp0s20u6 Scan completed :
Cell 01 - Address: 00:06:F4:BD:6E:F1
ESSID:"sspaas.com"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.412 GHz (Channel 1)
Encryption key:on
Bit Rates:130 Mb/s
Extra:wpa_ie=dd180050f20101000050f20401000050f20401000050f2020000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality=100/100 Signal level=100/100
Extra:fm=0003
... ...
这一步仅仅是扫描而已,并没有去连接
4.连接扫描到的wifi
[root@p_w_picpath linux]# cd wpa_supplicant_hostapd/
[root@p_w_picpath wpa_supplicant_hostapd]# ls
p2p_hostapd.conf wpa_0_8.conf wpa_supplicant_hostapd-0.8_rtw_r7475.20130812
rtl_hostapd_2G.conf wpa_supplicant_8_jb_4.2_rtw_r8680.20130821.tar.gz wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz
rtl_hostapd_5G.conf wpa_supplicant_8_kk_4.4_rtw_r11967.20140818.tar.gz
[root@p_w_picpath wpa_supplicant_hostapd]# tar -xf wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz
[root@p_w_picpath wpa_supplicant]# cd wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/wpa_supplicant/
[root@p_w_picpath wpa_supplicant]# make && make install
[root@p_w_picpath wpa_supplicant]# echo $?
连接wifi
[root@p_w_picpath wpa_supplicant]# wpa_passphrase sspaas.com >> /etc/wpa_supplicant/wpa_supplicant.conf 回车 然后再输入密码
88888888
[root@p_w_picpath wpa_supplicant]# cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
# reading passphrase from stdin
network={
ssid="sspaas.com"
#psk="88888888"
psk=c88b2e4bc1a75fe6accbe5713acd3410c61d71fc02572083d7b7510d9f325772
}
现在驱动和秘钥文件全部都形成了,就可以进行wifi连接啦!!!
[root@p_w_picpath wpa_supplicant]#wpa_supplicant -i enp0s20u2 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext -B
wpa_supplicant 参数含义:
-i 指明网卡
-c 指明秘钥存放位置
-D 指明驱动类型为通用型
-B 放到后台运行
只做到这,还不够,一重启系统,就需要重新执行上面的命令啦,所以只要将上面的命令存放到/etc/rc.local 中就ok啦,以后每次重新启动系统就可以自动上网啦
底下给一点儿注意的事项:
这个网卡的驱动模块在这个目录下
/usr/lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/net/wireless/8821au.ko
查看系统已经加载的驱动模块
[root@p_w_picpath wireless]# lsmod | grep 8821
8821au 1968224 0
一般情况下,只要重新启动系统后,就会自动加载新安装的模块,但是今天我遇到了二般情况。。。。
重启系统后没有加载新模块,可以使用 insmod + 模块的具体路径 就可以啦,或者试一下modprobe,但是这个我并没有成功过。。。
insmod /usr/lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/net/wireless/8821au.ko
参考博文:http://jiangkun08.blog.51cto.com/6266992/1284327
转载于:https://blog.51cto.com/readshlinux/1887187