linux|操作系统|centos7物理机安装网卡驱动8188gu(内核升级,firmware固件,USB设备管理,module管理)

前言:

目前服务器领域centos7基本是主流的操作系统,而linux相对于Windows来说,软硬件方面的支持是差很多的,在硬件方面来说,以一个免驱的网卡为例,window xp可能不会自动识别到,但Windows10基本都会自动识别到,简简单单的即插即用。根本原因在Windows随着版本的升级,内置的各类网卡驱动更多,也因此Windows系统越来越大。

tips:什么是驱动?

驱动指的是操作系统层面的一组程序,该程序告诉操作系统的内核如何使用硬件,例如,网卡的启停,网卡的IP绑定,网卡的路由路径这些都是网卡驱动通知内核调用相关的程序,例如,ifconfig程序,做相应的动作来完成的。

而linux操作系统的内核一般是不集成过多的网卡的,主要在于linux一般是服务器用途,内核追求轻量化,因此,我们可以看到,linux 6.X的内核更新介绍里说某些网卡驱动已经集成到了内核中,也就是某些型号的网卡可以做到即插即用,而低版本的内核通常支持的硬件是比较少的,因此,某些情况下,某个硬件我们想使用的时候就必须升级内核了,简单来说,内核版本越高,那么,它可以识别的硬件种类越多,硬件识别之后,我们就可以安装相应的驱动来使用这些硬件了。通常我们是采用源码编译的方式安装驱动。

下面我将就在一台物理机通过编译方式安装水星的网卡驱动做一个介绍,本次实践基于虚拟机安装网卡驱动,见我的博客(本次相关文件都在下面这个文章内的网盘链接):

Linux|centos7操作系统|VMware虚拟机安装水星免驱USB网卡8188gu记录-CSDN博客

一,

服务器的信息

该服务器是一台比较老旧的服务器,硬件配置如下:

CPU: E52660 16核心

硬盘:259G 金士顿

主板:华南金牌770X

内存:16G

操作系统:centos7.5

网卡:主板网卡 芯片型号是r8168  USB网卡芯片型号是8188gu

操作系统的安装就不在这里废话了

二,

内核的升级

内核版本选择的是5,4,266版本,方式是rpm包直接安装

通常,内核的安装有两种方式,第一种是网上的各种deb,rpm包,该方式比较迅速,方便,基本不会有错误,第二种方式是手动编译方式,需要对内核比较熟悉,需要更多的定制功能,比如,linux系统对NTFS文件系统的支持,NET网咯的扩展性功能,EXT2文件系统的支持特殊的需求,以及一些自定义的自己编写的模块需要编译进内核。

本次实践选择的是使用现成的rpm包,rpm包下载地址是:

Index of /linux/kernel/el7/x86_64/RPMS

三,

Linux的gcc编译器问题

centos7的默认编译器版本是4.8版本,随着内核升级到了5.X版本,这个时候内核和编译器已经是不匹配了,因此,需要使用高版本的gcc编译器,本例中使用devtools版本的gcc9,将此gcc加入环境变量:

在/etc/profile文件末尾添加:

source /opt/rh/devtools-set/enable

添加后,执行命令  source /etc/profile 

如果内核和gcc编译器版本不匹配会有什么样的后果呢?

基本上编译是不会成功的,一开始编译就一大堆报错,例如下面这样:

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编译器问题,随着内核版本的升级,很多原内核的模块比如cfg80211也需要跟随升级,如果不升级,那么在加载新网卡模块的时候,可能会报错,如下图:

关键报错信息:cfg88211:failed to load regulatory.db

那么,我们的固件也就是firmware应该怎么更新呢?

其实比较的简单,/lib/firmware目录下就是centos7所使用的固件的存放目录,当然了,这个报错其实并不太影响网卡的驱动安装,因为,我在把网卡驱动安装完毕后,仍然有这个报错,但网卡是正常工作的,如果不希望看到这个报错,处理方案为:

手动从 https://mirrors.edge.kernel.org/pub/software/network/wireless-regdb/ 下载最新的包,解压缩后需要将文件 regulatory.db 和 regulatory.db.p7s 复制到/lib/firmware中 

最终系统日志里在没有看到这个报错了(我下载的是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

 我这里强调cfg80211这个模块是由于该模块是8188gu这个模块的依赖,相关证据如下:

[root@localhost firmware]# modinfo 8188gu |grep dep
depends:        cfg80211
[root@localhost firmware]# lsmod |grep 8188gu
8188gu               1007616  0 
cfg80211              704512  1 8188gu

因此,保证cfg80211模块正常运行是非常必要的




由于操作系统的内核升级导致usb_modeswitch 切换U盘报错,报错如下:

tips:主要报错信息是Error:Sierra conrol message failed (error -7)

这个错误导致以下命令执行出错:

[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= 0x1a2bStandardEject=1Look for default devices ...found USB ID 1d6b:0003found USB ID 2109:3431found USB ID 1d6b:0002found USB ID 0bda:1a2bfound USB ID 8087:0024found USB ID 1d6b:0002No devices in default mode found. Nothing to do. Bye!

 两种解决方案,第一个是更新usb相关的模块,第二个是更新固件

usb相关模块有usb-storage,scsi-mod等等好几个模块,更新比较困难,因此,选择第二个方法:更新固件,更新固件后可以摆脱这个usb相关module的依赖,也就是说不需要管这些模块是否加载了

更新固件的方法为:从 https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/下载后的最新 firmware 包存放在当前目录的lib文件夹下 

我下载的是这个固件包:

[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目录下的所有内容,将解压出来的内容放置到原/lib/firmware目录下,无需重启服务器,即时生效 




以上两个报错解决后,发现板载网卡也就是r8186在新内核下看不到了,翻遍日志也找不到任何有用的信息,而在旧内核下是可以看到这个网卡的

那么,如何知道板载网卡的芯片型号呢?

以旧内核进入系统后,使用ethtool 查看网卡信息就可以确定板载网卡的芯片信息了:

[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

以新内核进入系统后,开始make 素质三连,发现报错如下:

关键报错:fatal error:linux/pci-aspm.h:No such file or directory

打开报错的位置:

[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

 经判断,这里是内核版本检查,可以删除,因此,删除这三行后,可以正常编译了:

删除的三行内容如下

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#include <linux/pci-aspm.h>
#endif

 剩下基本就是一路绿灯了,按照上面提到的虚拟机内安装网卡驱动的文章,一路畅通无阻的安装完毕了

五,

USB的即插即用实现

编辑/etc/udev/rules.d/70-persistent-ipoib.rules,该文件末尾添加三行内容如下:

[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 是根据下面这个命令的倒数第三行得出的,因为是安装的8188gu这个驱动,因此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

重启服务器后可以看到非常快的就自动识别到了USB并自动挂载了8188gu 这个驱动

相关自动挂载的日志在/var/log/messages 文件内,内容如下:

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 >

六,

网卡功能的测试和网卡的若干管理方法介绍

WiFi连接:

第一种方式:

WiFi连接有很多种方法,这里使用nmcli的方式来连接WiFi,这种方法是最简单的:

扫描WiFi热点:

[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,可以看到网卡wlp0s26u1u1 成功连接名为mywifi的这个热点

[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(网盘里有),然后直接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 here387 |   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 here396 |   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 here483 |   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 here623 |       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 here748 |   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 here761 |       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 here773 |       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 here793 |    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 here813 |       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 here827 |       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 here850 |       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/

以上输出有一个温馨提示*** 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用户执行ldconfig命令激活此环境变量即可正常使用iw命令了

在使用iw之前,还需要激活网卡:

[root@centos10 wireless_tools]# ifconfig wls35u1 up

扫描WiFi(先查看网卡信息,记住网卡名称是wls35u1):

该扫描的信息比较全,需要重点关注目标WiFi网络的ESSID(网络名称)和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 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::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 1000link/ether 00:0c:29:e8:89:a2 brd ff:ff:ff:ff:ff:ffinet 192.168.123.20/24 brd 192.168.123.255 scope global noprefixroute ens33valid_lft forever preferred_lft foreverinet6 fd15:4ba5:5a2b:1008:162e:7500:4e67:2fb1/64 scope global noprefixroute dynamic valid_lft 86387sec preferred_lft 14387secinet6 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 1000link/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:C2ESSID:"YBJ"Protocol:IEEE 802.11bgnMode:MasterFrequency:2.412 GHz (Channel 1)Encryption key:onBit Rates:144 Mb/sExtra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202IE: WPA Version 1Group Cipher : CCMPPairwise Ciphers (1) : CCMPAuthentication Suites (1) : PSKExtra:IE: IEEE 802.11i/WPA2 Version 1Group Cipher : CCMPPairwise Ciphers (1) : CCMPAuthentication Suites (1) : PSKQuality=0/100  Signal level=18/100  Extra:fm=0003Cell 02 - Address: F4:32:3D:98:9A:39ESSID:"ChinaNet-6b4R"Protocol:IEEE 802.11bgnMode:MasterFrequency:2.417 GHz (Channel 2)Encryption key:onBit Rates:144 Mb/sExtra:wpa_ie=dd1a0050f20101000050f20202000050f2040050f20201000050f202IE: WPA Version 1Group Cipher : TKIPPairwise Ciphers (2) : CCMP TKIPAuthentication Suites (1) : PSKQuality=0/100  Signal level=23/100  Extra:fm=0001Cell 03 - Address: 38:21:87:7E:68:65ESSID:"midea_db_0821"Protocol:IEEE 802.11bgnMode:MasterFrequency:2.422 GHz (Channel 3)Encryption key:onBit Rates:72 Mb/sExtra:rsn_ie=30140100000fac040100000fac040100000fac020000IE: IEEE 802.11i/WPA2 Version 1Group Cipher : CCMPPairwise Ciphers (1) : CCMPAuthentication Suites (1) : PSKQuality=0/100  Signal level=13/100  Extra:fm=0003Cell 04 - Address: 50:33:F0:CD:21:D9ESSID:"mywifi"Protocol:IEEE 802.11bgnMode:MasterFrequency:2.432 GHz (Channel 5)Encryption key:onBit Rates:867 Mb/sExtra:rsn_ie=30140100000fac040100000fac040100000fac020000IE: IEEE 802.11i/WPA2 Version 1Group Cipher : CCMPPairwise Ciphers (1) : CCMPAuthentication Suites (1) : PSKIE: Unknown: DD9F0050F204104A0001101044000102103B00010310470010BC329E001DD811B286015033F0CD21D81021001852616C696E6B20546563686E6F6C6F67792C20436F72702E1023001C52616C696E6B20576972656C6573732041636365737320506F696E74102400065254323836301042000831323334353637381054000800060050F20400011011000B52616C696E6B4150535F3010080002008C103C000101Quality=0/100  Signal level=36/100  Extra:fm=0003

 iwconfig wls35u2 essid mywifi key s:WiFi密码

创建WiFi的配置文件:

wpa_passphrase ESSID passphrase > /etc/wpa_supplicant.conf

例如,现在我需要连接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

此时已经可以看到wls35u2这个网卡的ipv6地址了,但还没有ipv4的地址:

[root@centos10 network-scripts]# ifconfig  wls35u2
wls35u2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500inet6 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 0TX packets 55  bytes 15762 (15.3 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

通过DHCP分配ip地址:

dhclient  wls35u2

最终可以看到新网卡的ip地址,完结,撒花!!!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/639636.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JUC并发编程与源码分析学习笔记(二)

二十九、多线程锁之线程锁知识概述 说说Java“锁”事 从轻松的乐观锁和悲观锁开讲 通过8种情况演示锁运行案例&#xff0c;看看我们到底锁的是什么 公平锁和非公平锁 可重入锁&#xff08;又名递归锁&#xff09; 死锁及排查 写锁&#xff08;独占锁&#xff09;/读锁&a…

Java中创建List接口、ArrayList类和LinkedList类的常用方法(一)

List接口 要了解List接口&#xff0c;就不得不说起Java的集合框架。 &#xff08;该图来自菜鸟教程&#xff09; Collection接口和Map接口 Java 集合框架主要包括两种类型的容器&#xff0c;集合Collection和图Map。 Collection接口代表了单列集合&#xff0c;它包含了一组…

微信公众号怎么申请超过2个

一般可以申请多少个公众号&#xff1f;目前公众号申请数量的规定是从2018年底开始实施的&#xff0c;至今没有变化。规定如下&#xff1a;1、个人可以申请1个个人主体的公众号&#xff1b;2、企业&#xff08;有限公司&#xff09;可以申请2个公众号&#xff1b;3、个体户可以申…

MyBatis 的XML实现方法(JAVA)

数据库表的结构如下&#xff1a; DROP DATABASE IF EXISTS test; CREATE DATABASE test DEFAULT CHARACTER SET utf8mb4; -- 使⽤数据数据 USE test; -- 创建表[⽤⼾表] DROP TABLE IF EXISTS userinfo; CREATE TABLE userinfo ( id INT ( 11 ) NOT NULL AUTO_INCREMENT, user…

如何本地搭建Splunk Enterprise数据平台并实现任意浏览器公网访问

文章目录 前言1. 搭建Splunk Enterprise2. windows 安装 cpolar3. 创建Splunk Enterprise公网访问地址4. 远程访问Splunk Enterprise服务5. 固定远程地址 前言 本文主要介绍如何简单几步&#xff0c;结合cpolar内网穿透工具实现随时随地在任意浏览器&#xff0c;远程访问在本地…

MacM1Pro Parallels19.1.0 CentOS7.9 Install PostgrepSQL

相关阅读 MacM1Pro安装 Parallels Desktop 19.1.0 https://blog.csdn.net/qq_41594280/article/details/135420241 MacM1Pro Parallels安装Parallels Tools https://blog.csdn.net/qq_41594280/article/details/135398780 MacM1Pro Parallels安装CentOS7.9 https://blog.csdn.n…

win7或win10如何设置休眠不断网

win7电脑一断休眠wifi网络就会断&#xff0c;那么怎么办呢?该如何设置Win7电脑休眠时不断开WiFi呢?怎么办呢&#xff1f;下面为大家介绍一下方法能使大脑休眠时不断开WiFi网络。 设置Win7电脑休眠时不断开WiFi教程如下&#xff1a; 1、首先点击桌面右下角的.无线图标&#xf…

[嵌入式软件][启蒙篇][仿真平台] STM32F103实现串口输出输入、ADC采集

上一篇&#xff1a;[嵌入式软件][启蒙篇][仿真平台] STM32F103实现LED、按键 文章目录 一、串口输出(1) 简介(2) 示例代码(3) 仿真效果 二、串口输入(1) 简介(2) 示例代码(3) 仿真效果 三、ADC采集(1) 简介(2) 示例代码&#xff08;电压&#xff09;(3) 仿真效果 &#xff08;…

Conda python管理环境environments 一 从入门到精通

Conda系列&#xff1a; 翻译: Anaconda 与 miniconda的区别Miniconda介绍以及安装Conda python运行的包和环境管理 入门 使用 conda&#xff0c;可以创建、导出、列出、删除和更新 具有不同 Python 版本和/或 安装在其中的软件包。在两者之间切换或移动 环境称为激活环境。您…

vue中的插槽

在vue中&#xff0c;有的名词听着高大上&#xff0c;挺怪异的&#xff0c;比如插槽&#xff0c;就是slot&#xff0c;它的作用是为了解决组件之间写的内容在组件中的使用问题。 一、插槽的作用 <!DOCTYPE html> <html> <head><title>Vue中的插槽</…

接口测试-Mock测试方法

一、关于Mock测试 1、什么是Mock测试&#xff1f; Mock 测试就是在测试过程中&#xff0c;对于某些不容易构造&#xff08;如 HttpServletRequest 必须在Servlet 容器中才能构造出来&#xff09;或者不容易获取的比较复杂的对象&#xff08;如 JDBC 中的ResultSet 对象&#…

EHS管理系统为何需要物联网的加持?

EHS是Environment、Health、Safety的缩写&#xff0c;是从欧美企业引进的管理体系&#xff0c;在国外也被称为HSE。EHS是指健康、安全与环境一体化的管理。 而在国内&#xff0c;整个EHS市场一共被分成三类&#xff1b; 一类是EHS管培体系&#xff0c;由专门的EHS机构去为公司…

有色金属市场分析:预计2023年产量增幅在3.5%左右

上周各有色金属品种走势接近&#xff0c;均呈现出周初持续走弱、最后两个交易日反弹的走势。影响有色金属行情的主线逻辑一个是美国债务上限谈判的进展情况&#xff0c;另一个是全球经济衰退的预期。上周四和上周五市场整体反弹&#xff0c;主要由于美国债务上限谈判出现进展&a…

day27 组合总和 组合总和Ⅱ 分割回文串

题目1&#xff1a;39 组合总和 题目链接&#xff1a;39 组合总和 题意 找出无重复元素的正整数数组candidates中元素和为目标数target的所有不同组合&#xff0c;同一个数字可重复选取 回溯 回溯三部曲&#xff1a; 1&#xff09;参数和返回值 2&#xff09;终止条件 3…

php基础学习之常量

php常量的基本概念 常量是在程序运行中的一种不可改变的量&#xff08;数据&#xff09;&#xff0c;常量一旦定义&#xff0c;通常不可改变&#xff08;用户级别&#xff09;。 php常量的定义形式 使用define函数&#xff1a;define("常量名字", 常量值);使用cons…

EasyDarwin计划新增将各种流协议(RTSP、RTMP、HTTP、TCP、UDP)、文件转推RTMP到其他视频直播平台,支持转码H.264、文件直播推送

之前我们尝试做过EasyRTSPLive&#xff08;将RTSP流转推RTMP&#xff09;和EasyRTMPLive&#xff08;将各种RTSP/RTMP/HTTP/UDP流转推RTMP&#xff0c;这两个服务在市场上都得到了比较多的好评&#xff0c;其中&#xff1a; 1、EasyRTSPLive用的是EasyRTSPClient取流&#xff…

内网穿透的应用-如何使用Docker部署Redis数据库并结合内网穿透工具实现公网远程访问

文章目录 前言1. 安装Docker步骤2. 使用docker拉取redis镜像3. 启动redis容器4. 本地连接测试4.1 安装redis图形化界面工具4.2 使用RDM连接测试 5. 公网远程访问本地redis5.1 内网穿透工具安装5.2 创建远程连接公网地址5.3 使用固定TCP地址远程访问 前言 本文主要介绍如何在Ub…

RT-Thread 17. 中断发送信号量后线程去处理信号量

1. 代码 //sem.c #include <rtthread.h> #include <rtdevice.h> #include "drv_gpio.h"#define THREAD_PRIORITY 25 #define THREAD_TIMESLICE 5#define LED3_PIN GET_PIN(B, 3) ALIGN(RT_ALIGN_SIZE) static char thread3_stack[1024]; static struct…

【Spring 篇】MyBatis多表操作:编织数据的交响乐

欢迎来到MyBatis的多表操作世界&#xff01;在这个充满交响乐的舞台上&#xff0c;我们将探索如何巧妙地编织多个数据表的数据&#xff0c;创造出一场旋律动听的数据交响曲。无需繁琐的SQL拼接&#xff0c;MyBatis让多表操作变得优雅而简单。让我们一起进入这个音乐殿堂&#x…

司铭宇老师:房地产电话营销培训:房地产电话销售话术与销售技巧:打造高转化率的电话营销策略

房地产电话营销培训&#xff1a;房地产电话销售话术与销售技巧&#xff1a;打造高转化率的电话营销策略 在房地产销售中&#xff0c;电话销售是一种常见且有效的营销手段。它不仅可以快速触达潜在客户&#xff0c;还能够建立起销售人员与客户之间的初步信任关系。然而&#xff…