您的位置:首页 > 运维架构 > Linux

linux无线网卡的安装

2014-04-29 10:38 453 查看
linux无线网卡的安装 环境:centos
插上无线网卡
查看usblsusb
[root@CentOS ~]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 001 Device 002: ID 0bda:8172 Realtek Semiconductor Corp. RTL8191SU 802.11n WLAN Adapte
挂载光驱
[root@CentOS ~]# mount /dev/sr1 /media/cdrom
mount: block device /dev/sr1 is write-protected, mounting read-only
然后进入/media/cdrom/Packages
[root@CentOS ~]# cd /media/cdrom/Packages/
ll |grep usb查询与usb相关的rpm包
[root@CentOS Packages]# ll |grep usb
-r--r--r--. 3 root root 91160 Jul 3 2011 libertas-usb8388-firmware-5.110.22.p23-3.1.el6.noarch.rpm
-r--r--r--. 2 root root 27992 Jul 3 2011 libusb-0.1.12-23.el6.i686.rpm
-r--r--r--. 3 root root 28268 Jul 3 2011 libusb-0.1.12-23.el6.x86_64.rpm
-r--r--r--. 2 root root 77956 Jul 3 2011 libusb-devel-0.1.12-23.el6.i686.rpm
-r--r--r--. 2 root root 77960 Jul 3 2011 libusb-devel-0.1.12-23.el6.x86_64.rpm
-r--r--r--. 2 root root 82240 Feb 24 2013 libusb1-1.0.9-0.6.rc1.el6.i686.rpm
-r--r--r--. 2 root root 82188 Feb 24 2013 libusb1-1.0.9-0.6.rc1.el6.x86_64.rpm
-r--r--r--. 3 root root 7104 Jul 3 2011 rt73usb-firmware-1.8-7.el6.noarch.rpm
-r--r--r--. 2 root root 59784 Jul 3 2011 usbmuxd-1.0.2-1.el6.i686.rpm
-r--r--r--. 2 root root 60472 Jul 3 2011 usbmuxd-1.0.2-1.el6.x86_64.rpm
-r--r--r--. 2 root root 41116 Feb 24 2013 usbredir-0.5.1-1.el6.i686.rpm
-r--r--r--. 2 root root 40780 Feb 24 2013 usbredir-0.5.1-1.el6.x86_64.rpm
-r--r--r--. 2 root root 73000 Dec 9 2011 usbutils-003-4.el6.x86_64.rpm
-r--r--r--. 2 root root 41356 Feb 24 2013 xorg-x11-drv-sisusb-0.9.6-2.el6.x86_64.rpm
我们要用的就是这个usbutils-003-4.el6.x86_64.rpm
查看详细信息
[root@CentOS Packages]# rpm -qlp usbutils-003-4.el6.x86_64.rpm
/usr/bin/lsusb
/usr/bin/lsusb.py
/usr/bin/usb-devices
/usr/bin/usbhid-dump
/usr/sbin/lsusb
/usr/share/doc/usbutils-003
/usr/share/doc/usbutils-003/AUTHORS
/usr/share/doc/usbutils-003/COPYING
/usr/share/doc/usbutils-003/ChangeLog
/usr/share/doc/usbutils-003/NEWS
/usr/share/doc/usbutils-003/README
/usr/share/man/man1/usb-devices.1.gz
/usr/share/man/man8/lsusb.8.gz
/usr/share/pkgconfig/usbutils.pc
安装
[root@CentOS Packages]# rpm -ivh usbutils-003-4.el6.x86_64.rpm
查看:
[root@CentOS Packages]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 001 Device 002: ID 0bda:8172 Realtek Semiconductor Corp. RTL8191SU 802.11n WLAN Adapter
[root@CentOS Packages]# cd /boot
[root@CentOS boot]# ll
total 19704
-rw-r--r--. 1 root root 2407466 Feb 22 2013 System.map-2.6.32-431.el6.i686
-rw-r--r--. 1 root root 104081 Feb 22 2013 config-2.6.32-431.el6.i686
drwxr-xr-x. 3 root root 1024 Mar 29 21:27 efi
drwxr-xr-x. 2 root root 1024 Mar 29 21:28 grub
-rw-r--r--. 1 root root 13410049 Mar 29 21:28 initramfs-2.6.32-431.el6.i686.img
drwx------. 2 root root 12288 Mar 29 21:22 lost+found
-rw-r--r--. 1 root root 185734 Feb 22 2013 symvers-2.6.32-431.el6.i686.gz
-rwxr-xr-x. 1 root root 4043888 Feb 22 2013 vmlinuz-2.6.32-431.el6.i686
在配置文件中查找与rtl有关的
[root@CentOS boot]# grep -i rtl config-2.6.32-431.el6.i686
CONFIG_RTL8180=m
CONFIG_RTL8187=m
CONFIG_RTL8187_LEDS=y
CONFIG_USB_RTL8150=m
# CONFIG_RTL8187SE is not set
# CONFIG_RTL8192SU is not set
# CONFIG_RTL8192E is not set
m代表模块
去网上下载相应的驱动并安装,安装后会形成模块
模块一般放在/lib/modules/2.6.32-431.el6.i686/kernel/drivers/net/wireless/
[root@CentOS modules]# cd /lib/modules/`uname -r`/
进入2.6.32-431.el6.i686
[root@CentOS 2.6.32-431.el6.i686]#
进入kernel/drivers/net/wireless/
[root@CentOS 2.6.32-431.el6.i686]# cd kernel/drivers/net/wireless/
查看这个目录下的文件
[root@CentOS wireless]# ls
rtl818x
去官网下载网卡驱动解压
[root@CentOS ~]# tar -zxvf rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100601.tar.gz -C /usr/local/src/rtl
进入解压后的目录
[root@CentOS ~]# cd /usr/local/src/rtl
查看当前文件
[root@CentOS rtl]# ls
Makefile led
autoconf_rtl8712_usb_linux.h mlme
clean mp
cmd os_dep
config os_intf
crypto pwrctrl
debug recv
eeprom rf
efuse rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100601
hal runwpa
ifcfg-wlan0 sta_mgt
include wlan0dhcp
io wpa1.conf
ioctl xmit
有makefile文件,可以直接make
[root@CentOS rtl]# make
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/2.6.32-431.el6.i686/build M=/usr/local/src/rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100601 modules
make: *** /lib/modules/2.6.32-431.el6.i686/build: No such file or directory. Stop.
make: *** [modules] Error 2
你会发现不能安装,这是因为没有开发环境
[root@CentOS rtl]# yum grouplist|less
安装开发工具
[root@CentOS rtl]# yum groupinstall "Development tools" -y
[root@CentOS rtl]# make
生成了8712u.ko
[root@CentOS rtl]# cp 8712u.ko /lib/modules/2.6.32-431.el6.i686/kernel/drivers/net/wireless
[root@CentOS rtl]# make install
查看是否存在这个模块
[root@CentOS rtl]# ll /lib/modules/2.6.32-431.el6.i686/kernel/drivers/net/wireless/8712u.ko
加载模块
[root@CentOS rtl]# modprobe 8712u
查看是否加载上刚才的模块
[root@CentOS rtl]# lsmod |grep 8712u
8712u 329674 0
查看无线网卡有命令iwconfig
[root@CentOS rtl]# iwconfig
-bash: iwconfig: command not found
提示没有这个指令
需要安装无线网卡工具
[root@CentOS rtl]# cd /media/cdrom/Packages/
[root@CentOS Packages]# ll |grep -i wireless
-r--r--r--. 2 root root 94584 Jul 3 2011 wireless-tools-29-5.1.1.el6.i686.rpm
-r--r--r--. 2 root root 95848 Jul 3 2011 wireless-tools-29-5.1.1.el6.x86_64.rpm
[root@CentOS Packages]# yum install wireless -y
现在可以使用iwconfig查看无线网卡设置了
[root@CentOS ~]# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

wlan0 unassociated Nickname:"rtl_wifi"
Mode:Auto Access Point: Not-Associated Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=0/100 Signal level=0 dBm Noise level=0 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

现在将wlan0启动
[root@CentOS ~]# ifconfig wlan0 up
搜索无线网络
[root@CentOS ~]# iwlist wlan0 scanning
[root@localhost rtl8191]# iwlist wlan0 scanning
wlan0 Scan completed :
Cell 01 - Address: A8:57:4E:78:A4:02
ESSID:"NET-1"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD310050F204104A00011010440001021047001000000000000010000000A8574E78A402103C0001011049000600372A000120
Signal level=23/100
Cell 02 - Address: F8:D1:11:FB:F6:D4
ESSID:"php-1"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD0E0050F204104A0001101044000102
Signal level=23/100
已经可以找到无线网了。想要连接无线网还需要安装一个wpa工具
进入光盘查看与wpa相关的软件包
[root@localhost rtl8191]# cd /media/cdrom/Packages/
[root@localhost Packages]# ll |grep -i wpa_supplicant
-r--r--r--. 2 root root 374368 Feb 4 2013 wpa_supplicant-0.7.3-4.el6_3.i686.rpm
安装这个软件包来连接
[root@localhost Packages]# yum install wpa_supplicant -y
安装好后用 wpa_passphrase来设置无线网的名称和密码
格式是 wpa_passphrase <SSID> [password]
[root@localhost Packages]# wpa_passphrase NET-1
# reading passphrase from stdin
123!@#qaz
network={
ssid="NET-1"
#psk="123!@#qaz"
psk=aee0ca338ea19d7e84cc9da72c00836d0ea646594f1e9ff7f01a0173ce853de6
}
设置好后就可以连接了
连接用 wpa_supplicant 命令
[root@localhost Packages]# wpa_supplicant -B -i wlan0 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf
-B 后台运行 -i 选择网卡 -D wext -c 配置文件地址
动态获得IP地址
[root@localhost Packages]# dhcpclient wlan0
编辑开机脚本
[root@localhost Packages]# vim /etc/rc.d/rc.local
添加3条命令
modprobe 8712u
wpa_supplicant -B -i wlan0 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf
dhcpclient wlan0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 无线网卡