無線網絡:pc和服務器通過網絡設備連接到一塊稱爲網絡,其中有線的爲有線網絡,無線的爲無線網絡。
無線網絡的標準:
802.11a使用5GHz頻段,傳輸速度爲54Mbps,與802.11b不兼容。
802.11b使用2.4GHz頻段,傳輸速度爲11Mbps,與802.11b不兼容。
802.11g使用2.4GHz頻段,傳輸速度主要有54Mbps,108Mbps與802.11b兼容。
802.11n使用2.4GHZ頻段,傳輸速度可達300Mbps
無線網卡的歷史:CDMIA接口卡 pci接口 usb接口卡
實驗環境:
版本:CentOS release 6.5
內核:2.6.32-431.el6.i686
無線網卡版本: Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter
Usb接口無線網卡的使用:
usb無線網卡先插上電腦,打開電腦,如果是虛擬機需要設置
點擊可移動設備,到usb wlan點擊連接
這時候將會斷開宿主機,連接到虛擬機。
如果輸入lsusb命令沒有響應,
[root@wang ~]# lsusb
-bash: lsusb: command not found
需要安裝usb相關的包
[root@wang ~]mkdir /media/cdrom
[root@wang ~]# mount /dev/cdrom /media/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@wang ~]# cd /media/cdrom/Packages/
[root@wang Packages]# ll |grep -i 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--. 3 root root 27992 Jul 3 2011 libusb-0.1.12-23.el6.i686.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 82240 Feb 24 2013 libusb1-1.0.9-0.6.rc1.el6.i686.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 41116 Feb 24 2013 usbredir-0.5.1-1.el6.i686.rpm
-r--r--r--. 2 root root 71644 Dec 9 2011 usbutils-003-4.el6.i686.rpm
-r--r--r--. 2 root root 41892 Feb 24 2013 xorg-x11-drv-sisusb-0.9.6-2.el6.i686.r
[root@wang Packages]# yum --disablerepo=\* --enablerepo=c6-media install usbutils -y 安裝usbutils-003-4.el6.i686.rpm包
[root@wang ~]# 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:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter
然後輸入lsusb將會出現usb無線網卡
查看內核是否支持該無線網卡
[root@wang ~]# cd /boot
[root@wang boot]# ll
total 20731
-rw-r--r--. 1 root root 1982877 Nov 22 2013 System.map-2.6.32-431.el6.i686
-rw-r--r--. 1 root root 109953 Nov 22 2013 config-2.6.32-431.el6.i686
drwxr-xr-x. 3 root root 1024 Jul 9 02:39 efi
drwxr-xr-x. 2 root root 1024 Jul 13 16:25 grub
-rw-------. 1 root root 14917989 Jul 10 08:03 initramfs-2.6.32-431.el6.i686.img
drwx------. 2 root root 12288 Jul 9 02:37 lost+found
-rw-r--r--. 1 root root 190104 Nov 22 2013 symvers-2.6.32-431.el6.i686.gz
-rwxr-xr-x. 1 root root 4002656 Nov 22 2013 vmlinuz-2.6.32-431.el6.i686
[root@wang boot]# grep -i rt1 config-2.6.32-431.el6.i686 查看內核是否支持芯片型號rtl的無線網卡
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 支持rtl8180 8187等。並不支持RTL8188EUS
所以需要在官網上下載驅動包並解壓
[root@wang 8192]# ll 進入下載的驅動包目錄裏查看文件
total 68
-rw-r--r--. 1 root root 110 Jul 20 12:28 Kconfig
-rw-r--r--. 1 root root 14353 Jul 20 12:28 Makefile
-rw-r--r--. 1 root root 6848 Jul 20 12:28 autoconf_rtl8192c_usb_linux.h
-rw-r--r--. 1 root root 5358 Jul 20 12:28 autoconf_rtl8192d_usb_linux.h
-rw-r--r--. 1 root root 116 Jul 20 12:28 clean
drwxr-xr-x. 3 root root 4096 Jul 20 12:28 core
drwxr-xr-x. 4 root root 4096 Jul 20 12:28 hal
-rw-r--r--. 1 root root 54 Jul 20 12:28 ifcfg-wlan0
drwxr-xr-x. 3 root root 4096 Jul 20 12:28 include
-rw-r--r--. 1 root root 3272 Jul 20 12:28 make_drv
drwxr-xr-x. 3 root root 4096 Jul 20 12:28 os_dep
-rw-r--r--. 1 root root 294 Jul 20 12:28 wlan0dhcp
有Makefile文件,所以應該是基於源代碼安裝。
需要掛載硬盤安裝個工具包具體爲
[root@wang 8192]# mount /dev/cdrom /media/cdrom 掛載硬盤
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@wang 8192]# yum --disablerepo=\* --enablerepo=c6-media groupinstall "Development tools" -y 安裝工具包
[root@wang 8192]# make
[root@wang 8192]# make install 安裝
install -p -m 644 8192cu.ko /lib/modules/2.6.32-431.el6.i686/kernel/drivers/net/wireless/
/sbin/depmod -a 2.6.32-431.el6.i686
查看下系統所說的目錄
[root@wang 8192]# cd /lib/modules/2.6.32-431.el6.i686/kernel/drivers/net/wireless/
[root@wang wireless]# ls
能找到8192cu.ko 安裝成功,接下來
模塊的加載方式
insmod (後跟全路徑,不能解決依賴關係)
modprobe (後跟模塊名稱,自動解決依賴關係)當然用這種了
[root@wang wireless]# modprobe 8192cu 加載模塊
[root@wang wireless]# lsmod |grep 8192 查看已經加載的模塊是否成功
8192cu 481561 0 成功了
[root@wang wireless]# ifconfig -a 查看網卡情況
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 unassociated Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
[root@wang wireless]# cd /media/cdrom/Packages/
[root@wang Packages]# ll |grep -i wireless
-r--r--r--. 2 root root 94584 Jul 3 2011 wireless-tools-29-5.1.1.el6.i686.rpm
[root@wang Packages]# yum --disablerepo=\* --enablerepo=c6-media install wireless-tools -y 安裝wireless相關的工具
[root@wang Packages]# iwconfig 查看無線網卡
[root@wang ~]# ifconfig wlan0 up 激活無線網卡
[root@wang ~]# iwlist wlan0 scanning 掃描無線網絡ap
wlan0 Scan completed :
Cell 01 - 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:
[root@wang ~]# wpa_passphrase php-1 設置連接php-1的密碼 如果沒有wpa_passphrase,需要安裝wpa_supplicant相關的包
# reading passphrase from stdin
qaz123!@#
network={
ssid="php-1"
#psk="qaz123!@#"
psk=3a30ab87951721ed310c46f6b19ceed2aa2fdb54baaffcbdd965d6bc81744698
[root@wang ~]# wpa_passphrase php-1 >>/etc/wpa_supplicant/wpa_supplicant.conf 將上面的文件追加到wpa_supplicant.conf控制文件中
qaz123!@#
[root@wang ~]# vim /etc/wpa_supplicant/wpa_supplicant.conf可以查看下是否追加成功
[root@wang ~]# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext
進行無線網絡的連接 -B後臺運行 -i指出哪個設備 -c密碼文件的路徑 -D驅動名稱
ioctl[SIOCSIWAP]: Operation not permitted 出現這個沒關係實際上已經連接上了
[root@wang ~]# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11bgn ESSID:"php-1" Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency:2.437 GHz Access Point: F8:D1:11:FB:F6:D4
Bit Rate:300 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:****-****-****-****-****-****-****-**** Security mode:open
Power Management:off
Link Quality=100/100 Signal level=74/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
[root@wang ~]# dhclient wlan0獲取ip地址
[root@wang ~]# ifconfig
wlan0 Link encap:Ethernet HWaddr 0C:82:68:1E:48:FB
inet addr:192.168.102.103 Bcast:255.255.255.255 Mask:255.255.255.0
inet6 addr: fe80::e82:68ff:fe1e:48fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:333 errors:0 dropped:476 overruns:0 frame:0
TX packets:11 errors:0 dropped:6 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:59505 (58.1 KiB) TX bytes:3244 (3.1 KiB)
獲取ip地址成功
接下來還有個問題,當系統重啓時候
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext
dhclient wlan0 這些命令不會自動執行
如果需要自動執行需要把這些文件寫到開機腳本里面
開機腳本寫到/etc/rc.local 或者 /etc/rc.d/rc.local 都可以
[root@wang ~]# echo "wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext" >>/etc/rc.d/rc.local
[root@wang ~]# echo "dhclient wlan0">>/etc/rc.d/rc.local 將這2條命令加入開機腳本即可