前言:
目前服務(wù)器領(lǐng)域centos7基本是主流的操作系統(tǒng),而linux相對(duì)于Windows來說,軟硬件方面的支持是差很多的,在硬件方面來說,以一個(gè)免驅(qū)的網(wǎng)卡為例,window xp可能不會(huì)自動(dòng)識(shí)別到,但Windows10基本都會(huì)自動(dòng)識(shí)別到,簡(jiǎn)簡(jiǎn)單單的即插即用。根本原因在Windows隨著版本的升級(jí),內(nèi)置的各類網(wǎng)卡驅(qū)動(dòng)更多,也因此Windows系統(tǒng)越來越大。
tips:什么是驅(qū)動(dòng)?
驅(qū)動(dòng)指的是操作系統(tǒng)層面的一組程序,該程序告訴操作系統(tǒng)的內(nèi)核如何使用硬件,例如,網(wǎng)卡的啟停,網(wǎng)卡的IP綁定,網(wǎng)卡的路由路徑這些都是網(wǎng)卡驅(qū)動(dòng)通知內(nèi)核調(diào)用相關(guān)的程序,例如,ifconfig程序,做相應(yīng)的動(dòng)作來完成的。
而linux操作系統(tǒng)的內(nèi)核一般是不集成過多的網(wǎng)卡的,主要在于linux一般是服務(wù)器用途,內(nèi)核追求輕量化,因此,我們可以看到,linux 6.X的內(nèi)核更新介紹里說某些網(wǎng)卡驅(qū)動(dòng)已經(jīng)集成到了內(nèi)核中,也就是某些型號(hào)的網(wǎng)卡可以做到即插即用,而低版本的內(nèi)核通常支持的硬件是比較少的,因此,某些情況下,某個(gè)硬件我們想使用的時(shí)候就必須升級(jí)內(nèi)核了,簡(jiǎn)單來說,內(nèi)核版本越高,那么,它可以識(shí)別的硬件種類越多,硬件識(shí)別之后,我們就可以安裝相應(yīng)的驅(qū)動(dòng)來使用這些硬件了。通常我們是采用源碼編譯的方式安裝驅(qū)動(dòng)。
下面我將就在一臺(tái)物理機(jī)通過編譯方式安裝水星的網(wǎng)卡驅(qū)動(dòng)做一個(gè)介紹,本次實(shí)踐基于虛擬機(jī)安裝網(wǎng)卡驅(qū)動(dòng),見我的博客(本次相關(guān)文件都在下面這個(gè)文章內(nèi)的網(wǎng)盤鏈接):
Linux|centos7操作系統(tǒng)|VMware虛擬機(jī)安裝水星免驅(qū)USB網(wǎng)卡8188gu記錄-CSDN博客
一,
服務(wù)器的信息
該服務(wù)器是一臺(tái)比較老舊的服務(wù)器,硬件配置如下:
CPU: E52660 16核心
硬盤:259G 金士頓
主板:華南金牌770X
內(nèi)存:16G
操作系統(tǒng):centos7.5
網(wǎng)卡:主板網(wǎng)卡 芯片型號(hào)是r8168? USB網(wǎng)卡芯片型號(hào)是8188gu
操作系統(tǒng)的安裝就不在這里廢話了
二,
內(nèi)核的升級(jí)
內(nèi)核版本選擇的是5,4,266版本,方式是rpm包直接安裝
通常,內(nèi)核的安裝有兩種方式,第一種是網(wǎng)上的各種deb,rpm包,該方式比較迅速,方便,基本不會(huì)有錯(cuò)誤,第二種方式是手動(dòng)編譯方式,需要對(duì)內(nèi)核比較熟悉,需要更多的定制功能,比如,linux系統(tǒng)對(duì)NTFS文件系統(tǒng)的支持,NET網(wǎng)咯的擴(kuò)展性功能,EXT2文件系統(tǒng)的支持特殊的需求,以及一些自定義的自己編寫的模塊需要編譯進(jìn)內(nèi)核。
本次實(shí)踐選擇的是使用現(xiàn)成的rpm包,rpm包下載地址是:
Index of /linux/kernel/el7/x86_64/RPMS
三,
Linux的gcc編譯器問題
centos7的默認(rèn)編譯器版本是4.8版本,隨著內(nèi)核升級(jí)到了5.X版本,這個(gè)時(shí)候內(nèi)核和編譯器已經(jīng)是不匹配了,因此,需要使用高版本的gcc編譯器,本例中使用devtools版本的gcc9,將此gcc加入環(huán)境變量:
在/etc/profile文件末尾添加:
source /opt/rh/devtools-set/enable
添加后,執(zhí)行命令? source /etc/profile?
如果內(nèi)核和gcc編譯器版本不匹配會(huì)有什么樣的后果呢?
基本上編譯是不會(huì)成功的,一開始編譯就一大堆報(bào)錯(cuò),例如下面這樣:
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/3.10.0-862.14.1.0.h209.eulerosv2r7.x86_64/build M=/opt/rtl8188gu-master modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-862.14.1.0.h209.eulerosv2r7.x86_64'
CC [M] /opt/rtl8188gu-master/core/rtw_cmd.o
In file included from include/linux/kernel.h:11,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /opt/rtl8188gu-master/include/basic_types.h:76,
from /opt/rtl8188gu-master/include/drv_types.h:26,
from /opt/rtl8188gu-master/core/rtw_cmd.c:17:
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Wattributes]
22 | int ____ilog2_NaN(void);
| ^~~
/opt/rtl8188gu-master/core/rtw_cmd.c: In function ‘rtw_joinbss_cmd’:
/opt/rtl8188gu-master/core/rtw_cmd.c:1477:38: warning: taking address of packed member of ‘struct _WLAN_BSSID_EX’ may result in an unaligned pointer value [-Waddress-of-packed-member]
1477 | pnetwork->network.IELength - 12, &psecnetwork->IELength,
| ^~~~~~~~~~~~~~~~~~~~~~
/opt/rtl8188gu-master/core/rtw_cmd.c:1490:32: warning: taking address of packed member of ‘struct _WLAN_BSSID_EX’ may result in an unaligned pointer value [-Waddress-of-packed-member]
1490 | pnetwork->network.IELength, &psecnetwork->IELength);
| ^~~~~~~~~~~~~~~~~~~~~~
/opt/rtl8188gu-master/core/rtw_cmd.c:1494:57: warning: taking address of packed member of ‘struct _WLAN_BSSID_EX’ may result in an unaligned pointer value [-Waddress-of-packed-member]
1494 | rtw_append_exented_cap(padapter, &psecnetwork->IEs[0], &psecnetwork->IELength);
| ^~~~~~~~~~~~~~~~~~~~~~
CC [M] /opt/rtl8188gu-master/core/rtw_security.o
In file included from include/linux/kernel.h:11,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /opt/rtl8188gu-master/include/basic_types.h:76,
from /opt/rtl8188gu-master/include/drv_types.h:26,
from /opt/rtl8188gu-master/core/rtw_security.c:17:
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Wattributes]
22 | int ____ilog2_NaN(void);
| ^~~
CC [M] /opt/rtl8188gu-master/core/rtw_debug.o
In file included from include/linux/kernel.h:11,
from include/linux/cache.h:4,
from include/linux/time.h:4,
四,linux的固件問題
類似上面的gcc編譯器問題,隨著內(nèi)核版本的升級(jí),很多原內(nèi)核的模塊比如cfg80211也需要跟隨升級(jí),如果不升級(jí),那么在加載新網(wǎng)卡模塊的時(shí)候,可能會(huì)報(bào)錯(cuò),如下圖:
關(guān)鍵報(bào)錯(cuò)信息:cfg88211:failed to load regulatory.db
那么,我們的固件也就是firmware應(yīng)該怎么更新呢?
其實(shí)比較的簡(jiǎn)單,/lib/firmware目錄下就是centos7所使用的固件的存放目錄,當(dāng)然了,這個(gè)報(bào)錯(cuò)其實(shí)并不太影響網(wǎng)卡的驅(qū)動(dòng)安裝,因?yàn)?,我在把網(wǎng)卡驅(qū)動(dòng)安裝完畢后,仍然有這個(gè)報(bào)錯(cuò),但網(wǎng)卡是正常工作的,如果不希望看到這個(gè)報(bào)錯(cuò),處理方案為:
手動(dòng)從 https://mirrors.edge.kernel.org/pub/software/network/wireless-regdb/ 下載最新的包,解壓縮后需要將文件 regulatory.db 和 regulatory.db.p7s 復(fù)制到/lib/firmware中?
最終系統(tǒng)日志里在沒有看到這個(gè)報(bào)錯(cuò)了(我下載的是wireless-regdb-2023.09.01.tar.gz)
[root@localhost firmware]# pwd
/lib/firmware
[root@localhost firmware]# ls -al reg*
-rw-r--r-- 1 root root 4896 Jan 18 23:16 regulatory.db
-rw-r--r-- 1 root root 1182 Jan 18 23:16 regulatory.db.p7s
[root@localhost firmware]# ls -al /opt/test/wireless-regdb-2023.09.01/
total 192
drwxrwxr-x. 4 root root 4096 Sep 2 03:58 .
drwxr-xr-x. 7 root root 4096 Jan 18 07:12 ..
-rw-rw-r--. 1 root root 1871 Sep 2 03:58 CONTRIBUTING
-rwxrwxr-x. 1 root root 3672 Sep 2 03:58 db2bin.py
-rwxrwxr-x. 1 root root 4181 Sep 2 03:58 db2fw.py
-rwxrwxr-x. 1 root root 17490 Sep 2 03:58 dbparse.py
-rw-rw-r--. 1 root root 82408 Sep 2 03:58 db.txt
drwxrwxr-x. 2 root root 94 Sep 2 03:58 debian-example
-rwxrwxr-x. 1 root root 363 Sep 2 03:58 gen-pubcert.sh
-rw-rw-r--. 1 root root 25 Sep 2 03:58 .gitignore
-rw-rw-r--. 1 root root 880 Sep 2 03:58 LICENSE
-rw-rw-r--. 1 root root 3989 Sep 2 03:58 Makefile
-rw-rw-r--. 1 root root 1448 Sep 2 03:58 README
-rw-rw-r--. 1 root root 6668 Sep 2 03:58 regulatory.bin
-rw-rw-r--. 1 root root 1266 Sep 2 03:58 regulatory.bin.5
-rw-rw-r--. 1 root root 4896 Sep 2 03:58 regulatory.db
-rw-rw-r--. 1 root root 29 Sep 2 03:58 regulatory.db.5
-rw-rw-r--. 1 root root 1182 Sep 2 03:58 regulatory.db.p7s
-rw-rw-r--. 1 root root 451 Sep 2 03:58 sforshee.key.pub.pem
-rw-rw-r--. 1 root root 977 Sep 2 03:58 sforshee.x509.pem
-rw-rw-r--. 1 root root 49 Sep 2 03:58 sha1sum.txt
drwxrwxr-x. 2 root root 27 Sep 2 03:58 web
-rw-rw-r--. 1 root root 972 Sep 2 03:58 wireless-regdb.spec
?我這里強(qiáng)調(diào)cfg80211這個(gè)模塊是由于該模塊是8188gu這個(gè)模塊的依賴,相關(guān)證據(jù)如下:
[root@localhost firmware]# modinfo 8188gu |grep dep
depends: cfg80211
[root@localhost firmware]# lsmod |grep 8188gu
8188gu 1007616 0
cfg80211 704512 1 8188gu
因此,保證cfg80211模塊正常運(yùn)行是非常必要的
由于操作系統(tǒng)的內(nèi)核升級(jí)導(dǎo)致usb_modeswitch?切換U盤報(bào)錯(cuò),報(bào)錯(cuò)如下:
tips:主要報(bào)錯(cuò)信息是Error:Sierra?conrol?message?failed (error -7)
這個(gè)錯(cuò)誤導(dǎo)致以下命令執(zhí)行出錯(cuò):
[root@localhost firmware]# usb_modeswitch -KW -v06bd -p 1a2b
Take all parameters from the command line
* usb_modeswitch: handle USB devices with multiple modes
* Version 2.4.0 (C) Josua Dietze 2016
* Based on libusb1/libusbx
! PLEASE REPORT NEW CONFIGURATIONS !
DefaultVendor= 0x06bd
DefaultProduct= 0x1a2b
StandardEject=1
Look for default devices ...
found USB ID 1d6b:0003
found USB ID 2109:3431
found USB ID 1d6b:0002
found USB ID 0bda:1a2b
found USB ID 8087:0024
found USB ID 1d6b:0002
No devices in default mode found. Nothing to do. Bye!
?兩種解決方案,第一個(gè)是更新usb相關(guān)的模塊,第二個(gè)是更新固件
usb相關(guān)模塊有usb-storage,scsi-mod等等好幾個(gè)模塊,更新比較困難,因此,選擇第二個(gè)方法:更新固件,更新固件后可以擺脫這個(gè)usb相關(guān)module的依賴,也就是說不需要管這些模塊是否加載了
更新固件的方法為:從 https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/下載后的最新 firmware 包存放在當(dāng)前目錄的lib文件夾下?
我下載的是這個(gè)固件包:
[root@localhost firmware]# ls -al /opt/test/linux-firmware-20240115.tar.gz
-rwxr-xr-x. 1 root root 553601923 Jan 17 09:27 /opt/test/linux-firmware-20240115.tar.gz
解壓上面的壓縮包后,備份原/lib/firmware目錄,刪除原firmware目錄下的所有內(nèi)容,將解壓出來的內(nèi)容放置到原/lib/firmware目錄下,無需重啟服務(wù)器,即時(shí)生效?
以上兩個(gè)報(bào)錯(cuò)解決后,發(fā)現(xiàn)板載網(wǎng)卡也就是r8186在新內(nèi)核下看不到了,翻遍日志也找不到任何有用的信息,而在舊內(nèi)核下是可以看到這個(gè)網(wǎng)卡的
那么,如何知道板載網(wǎng)卡的芯片型號(hào)呢?
以舊內(nèi)核進(jìn)入系統(tǒng)后,使用ethtool?查看網(wǎng)卡信息就可以確定板載網(wǎng)卡的芯片信息了:
[root@localhost firmware]# ethtool -i enp5s0
driver: r8168
version: 8.047.05-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:05:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
以新內(nèi)核進(jìn)入系統(tǒng)后,開始make?素質(zhì)三連,發(fā)現(xiàn)報(bào)錯(cuò)如下:
關(guān)鍵報(bào)錯(cuò):fatal error:linux/pci-aspm.h:No such file or directory
打開報(bào)錯(cuò)的位置:
[root@localhost firmware]# sed -n '65,70p' /opt/test/Realtek-PCIe-GBE-NIC-Driver-master/r8168-8.047.04/src/r8168_n.c
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#define dev_printk(A,B,fmt,args...) printk(A fmt,##args)
#else
#include <linux/dma-mapping.h>
#include <linux/moduleparam.h>
[root@localhost firmware]# sed -n '55,65p' /opt/test/Realtek-PCIe-GBE-NIC-Driver-master/r8168-8.047.04/src/r8168_n.c
#include <linux/init.h>
#include <linux/rtnetlink.h>
#include <linux/completion.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#include <linux/pci-aspm.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,37)
#include <linux/prefetch.h>
#endif
?經(jīng)判斷,這里是內(nèi)核版本檢查,可以刪除,因此,刪除這三行后,可以正常編譯了:
刪除的三行內(nèi)容如下
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#include <linux/pci-aspm.h>
#endif
?剩下基本就是一路綠燈了,按照上面提到的虛擬機(jī)內(nèi)安裝網(wǎng)卡驅(qū)動(dòng)的文章,一路暢通無阻的安裝完畢了
五,
USB的即插即用實(shí)現(xiàn)
編輯/etc/udev/rules.d/70-persistent-ipoib.rules,該文件末尾添加三行內(nèi)容如下:
[root@localhost r8168-8.047.04]# cat /etc/udev/rules.d/70-persistent-ipoib.rules
# This is a sample udev rules file that demonstrates how to get udev to
# set the name of IPoIB interfaces to whatever you wish. There is a
# 16 character limit on network device names though, so don't go too nuts
#
# Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the
# ATTR{address} match must start with ?* and only reference the last 8
# bytes of the address or else the address might not match on any given
# start of the IPoIB stack
#
# Note: as of rhel7, udev is case sensitive on the address field match
# and all addresses need to be in lower case.
#
# ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="1a2b", RUN+="/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="1a2b", RUN+="/bin/bash -c 'modprobe 8188gu && echo 0bda 1a2b > /sys/bus/usb-serial/drivers/option1/new_id'"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="1a2b", RUN+="/bin/bash -c 'modprobe 8188gu && echo 0bda 1a2b > /sys/bus/usb-serial/drivers/option1/new_id'"
idVendor和idProduct?是根據(jù)下面這個(gè)命令的倒數(shù)第三行得出的,因?yàn)槭前惭b的8188gu這個(gè)驅(qū)動(dòng),因此modprobe 8188gu
[root@localhost r8168-8.047.04]# lsusb
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:1a2b Realtek Semiconductor Corp.
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
重啟服務(wù)器后可以看到非??斓木妥詣?dòng)識(shí)別到了USB并自動(dòng)掛載了8188gu?這個(gè)驅(qū)動(dòng)
相關(guān)自動(dòng)掛載的日志在/var/log/messages?文件內(nèi),內(nèi)容如下:
Jan 18 23:17:50 localhost kernel: usb 1-1.1: New USB device found, idVendor=0bda, idProduct=b711, bcdDevice= 2.00
Jan 18 23:17:50 localhost kernel: usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 18 23:17:50 localhost kernel: usb 1-1.1: Product: 802.11n WLAN Adapter
Jan 18 23:17:50 localhost kernel: usb 1-1.1: Manufacturer: Realtek
Jan 18 23:17:50 localhost kernel: usb 1-1.1: SerialNumber: 00E04CB82101
Jan 18 23:17:50 localhost kernel: sdb: sdb1 sdb2 < sdb5 >
六,
網(wǎng)卡功能的測(cè)試和網(wǎng)卡的若干管理方法介紹
WiFi連接:
第一種方式:
WiFi連接有很多種方法,這里使用nmcli的方式來連接WiFi,這種方法是最簡(jiǎn)單的:
掃描WiFi熱點(diǎn):
[root@localhost r8168-8.047.04]# nmcli device wifi lis
* SSID MODE CHAN RATE SIGNAL BARS SECURITY
mywifi-WiFi5 Infra 5 54 Mbit/s 100 ▂▄▆█ WPA2
-- Infra 5 54 Mbit/s 100 ▂▄▆█ WPA2
* mywifi Infra 5 54 Mbit/s 90 ▂▄▆█ WPA2
ChinaNet-gTUm Infra 5 54 Mbit/s 80 ▂▄▆_ WPA1 WPA2
MIQI Infra 11 54 Mbit/s 55 ▂▄__ WPA1 WPA2
-- Infra 11 54 Mbit/s 55 ▂▄__ WPA1 WPA2
-- Infra 8 54 Mbit/s 50 ▂▄__ WPA2
zhwww Infra 8 54 Mbit/s 49 ▂▄__ WPA2
ChinaNet-6b4R Infra 2 54 Mbit/s 42 ▂▄__ WPA1
ChinaNet-wfJ9 Infra 10 54 Mbit/s 24 ▂___ WPA1 WPA2
nmcli直接連接:
mywifi是我的WiFi,可以看到網(wǎng)卡wlp0s26u1u1?成功連接名為mywifi的這個(gè)熱點(diǎn)
[root@localhost r8168-8.047.04]# nmcli device wifi connect mywifi password 密碼
Device 'wlp0s26u1u1' successfully activated with '00efc1c4-b849-4821-8f75-c5957cb6defd'.
第二種方式:
利用iw工具和wpa_suppliant工具配置WiFi連接
解壓wireless-tools-29.zip(網(wǎng)盤里有),然后直接make && make install? 輸出日志如下:
[root@centos10 wireless_tools]# make
gcc -Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -I. -MMD -fPIC -c -o iwlib.so iwlib.c
In file included from iwlib.c:14:
iwlib.c: In function ‘print_iface_version_info’:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:387:6: note: called from here
387 | if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:396:6: note: called from here
396 | if(iw_get_ext(skfd, ifname, SIOCGIWRANGE, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.c: In function ‘iw_get_range_info’:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:483:6: note: called from here
483 | if(iw_get_ext(skfd, ifname, SIOCGIWRANGE, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.c: In function ‘iw_get_priv_info’:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:623:10: note: called from here
623 | if(iw_get_ext(skfd, ifname, SIOCGIWPRIV, &wrq) >= 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.c: In function ‘iw_set_basic_config’:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:748:6: note: called from here
748 | if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:761:10: note: called from here
761 | if(iw_get_ext(skfd, ifname, SIOCSIWMODE, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:506:1: warning: inlining failed in call to ‘iw_set_ext’: call is unlikely and code size would grow [-Winline]
506 | iw_set_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:773:10: note: called from here
773 | if(iw_set_ext(skfd, ifname, SIOCSIWFREQ, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:506:1: warning: inlining failed in call to ‘iw_set_ext’: call is unlikely and code size would grow [-Winline]
506 | iw_set_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:793:7: note: called from here
793 | if(iw_set_ext(skfd, ifname, SIOCSIWENCODE, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:506:1: warning: inlining failed in call to ‘iw_set_ext’: call is unlikely and code size would grow [-Winline]
506 | iw_set_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:813:10: note: called from here
813 | if(iw_set_ext(skfd, ifname, SIOCSIWENCODE, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:506:1: warning: inlining failed in call to ‘iw_set_ext’: call is unlikely and code size would grow [-Winline]
506 | iw_set_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:827:10: note: called from here
827 | if(iw_set_ext(skfd, ifname, SIOCSIWNWID, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.h:506:1: warning: inlining failed in call to ‘iw_set_ext’: call is unlikely and code size would grow [-Winline]
506 | iw_set_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
iwlib.c:850:10: note: called from here
850 | if(iw_set_ext(skfd, ifname, SIOCSIWESSID, &wrq) < 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from iwlib.c:14:
iwlib.c: In function ‘iw_get_basic_config’:
iwlib.h:522:1: warning: inlining failed in call to ‘iw_get_ext’: call is unlikely and code size would grow [-Winline]
522 | iw_get_ext(int skfd, /* Socket to the kernel */
| ^~~~~~~~~~
。。。。。。。。。。。后面的略略略
[root@centos10 wireless_tools]# make install
install -m 755 -d /usr/local/lib/
install -m 755 libiw.so.29 /usr/local/lib/
ln -sfn libiw.so.29 /usr/local/lib//libiw.so
*** Don't forget to add /usr/local/lib/ to /etc/ld.so.conf, and run ldconfig as root. ***
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/
install -m 755 -d /usr/local/man//man8/
install -m 644 iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8 /usr/local/man//man8/
install -m 755 -d /usr/local/man//man7/
install -m 644 wireless.7 /usr/local/man//man7/
install -m 755 -d /usr/local/man//man5/
install -m 644 iftab.5 /usr/local/man//man5/
以上輸出有一個(gè)溫馨提示*** Don't forget to add /usr/local/lib/ to /etc/ld.so.conf, and run ldconfig as root. ***,因此,在/etc/ld.so.conf文件末尾添加/usr/local/lib/?保存文件后,以root用戶執(zhí)行l(wèi)dconfig命令激活此環(huán)境變量即可正常使用iw命令了
在使用iw之前,還需要激活網(wǎng)卡:
[root@centos10 wireless_tools]# ifconfig wls35u1 up
掃描WiFi(先查看網(wǎng)卡信息,記住網(wǎng)卡名稱是wls35u1):
該掃描的信息比較全,需要重點(diǎn)關(guān)注目標(biāo)WiFi網(wǎng)絡(luò)的ESSID(網(wǎng)絡(luò)名稱)和BSSID(無線路由器的MAC地址),例如mywifi的ESSID是?mywifi,BSSID是50:33:F0:CD:21:D9
[root@centos10 wireless_tools]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 00:0c:29:e8:89:a2 brd ff:ff:ff:ff:ff:ff
inet 192.168.123.20/24 brd 192.168.123.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fd15:4ba5:5a2b:1008:162e:7500:4e67:2fb1/64 scope global noprefixroute dynamic
valid_lft 86387sec preferred_lft 14387sec
inet6 fe80::523b:7d77:34e9:fa42/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wls35u1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 00:5c:c2:ce:dc:24 brd ff:ff:ff:ff:ff:ff
[root@centos10 wireless_tools]# iwlist wls35u1 scan
wls35u1 Scan completed :
Cell 01 - Address: 74:05:A5:DC:86:C2
ESSID:"YBJ"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.412 GHz (Channel 1)
Encryption key:on
Bit Rates:144 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
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=0/100 Signal level=18/100
Extra:fm=0003
Cell 02 - Address: F4:32:3D:98:9A:39
ESSID:"ChinaNet-6b4R"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.417 GHz (Channel 2)
Encryption key:on
Bit Rates:144 Mb/s
Extra:wpa_ie=dd1a0050f20101000050f20202000050f2040050f20201000050f202
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : CCMP TKIP
Authentication Suites (1) : PSK
Quality=0/100 Signal level=23/100
Extra:fm=0001
Cell 03 - Address: 38:21:87:7E:68:65
ESSID:"midea_db_0821"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.422 GHz (Channel 3)
Encryption key:on
Bit Rates:72 Mb/s
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality=0/100 Signal level=13/100
Extra:fm=0003
Cell 04 - Address: 50:33:F0:CD:21:D9
ESSID:"mywifi"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.432 GHz (Channel 5)
Encryption key:on
Bit Rates:867 Mb/s
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD9F0050F204104A0001101044000102103B00010310470010BC329E001DD811B286015033F0CD21D81021001852616C696E6B20546563686E6F6C6F67792C20436F72702E1023001C52616C696E6B20576972656C6573732041636365737320506F696E74102400065254323836301042000831323334353637381054000800060050F20400011011000B52616C696E6B4150535F3010080002008C103C000101
Quality=0/100 Signal level=36/100
Extra:fm=0003
?iwconfig wls35u2 essid mywifi key s:WiFi密碼
創(chuàng)建WiFi的配置文件:
wpa_passphrase ESSID passphrase > /etc/wpa_supplicant.conf
例如,現(xiàn)在我需要連接mywifi,那么配置此WiFi的命令就是
wpa_passphrase?mywif?WiFi的密碼 > /etc/wpa_supplicant.conf
連接WiFi:
[root@centos10 network-scripts]# wpa_supplicant -D nl80211 -i wls35u2 -c /etc/wpa_supplicant.conf -B
Successfully initialized wpa_supplicant
此時(shí)已經(jīng)可以看到wls35u2這個(gè)網(wǎng)卡的ipv6地址了,但還沒有ipv4的地址:
[root@centos10 network-scripts]# ifconfig wls35u2
wls35u2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet6 fe80::25c:c2ff:fece:dc24 prefixlen 64 scopeid 0x20<link>
ether 00:5c:c2:ce:dc:24 txqueuelen 1000 (Ethernet)
RX packets 1229 bytes 122805 (119.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 55 bytes 15762 (15.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
通過DHCP分配ip地址:文章來源:http://www.zghlxwxcb.cn/news/detail-807610.html
dhclient wls35u2
最終可以看到新網(wǎng)卡的ip地址,完結(jié),撒花?。。。?!文章來源地址http://www.zghlxwxcb.cn/news/detail-807610.html
到了這里,關(guān)于linux|操作系統(tǒng)|centos7物理機(jī)安裝網(wǎng)卡驅(qū)動(dòng)8188gu(內(nèi)核升級(jí),firmware固件,USB設(shè)備管理,module管理)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!