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

news2024/11/24 1:29:34

前言:

目前服务器领域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= 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!

 两种解决方案,第一个是更新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 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/

以上输出有一个温馨提示*** 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 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密码

创建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 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地址:

dhclient  wls35u2

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

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

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

相关文章

数据库中的经纬度数据如何在QGIS中显示

思路&#xff1a;必须先将经纬度数据转换成POINT&#xff0c;MULTILINESTRING等格式才能在QGIS中展示 步骤 1、首先在postgresql数据中建一张包括经纬度数据的表 **注意&#xff1a;**如果是新建数据库&#xff0c;一定要执行如下代码&#xff0c;否则后面的函数ST_GeomFrom…

使用fastapi和apifox实现后端接口

使用python文件import fastapi和uvicorn编写接口脚本 格式例&#xff1a; from pydantic import BaseModel from fastapi import FastAPI import uvicorn import jsonappFastAPI()class Response_data(BaseModel):re: strclass YourService():def __init__(self):passdef f(s…

【centos7安装docker】

背景&#xff1a; 学习docker&#xff0c;我是想做一个隔离环境&#xff0c;并且部署的话&#xff0c;希望实现自动化&#xff0c;不为安装软件而烦恼&#xff0c;保证每个人的环境一致。 2C4G内存 50G磁盘的虚拟机事先已经准备完毕。 1.查看下centos版本&#xff0c;docker要…

pytest自动化测试框架—基础篇

Pytest是一种基于Python编程语言的自动化测试框架&#xff0c;它提供了丰富的功能和灵活的扩展性&#xff0c;可以用于单元测试、集成测试、功能测试、端到端测试等多种场景。本文将介绍Pytest框架的基础知识&#xff0c;包括安装、配置、运行测试、断言和参数化等方面。 一、安…

shell脚本概念与命令

一、shell的作用 Shell 是一个特殊的应用程序&#xff0c;它介于操作系统内核与用户之间&#xff0c;充当 了一个“命令解释器”的角色&#xff0c;负责接收用户输入的操作指令&#xff08;命令&#xff09;并进行解释&#xff0c;将需要执 行的操作传递给内核执行&#xff0c;…

二分法——C++

二分分为整数二分和浮点数二分&#xff0c;其中比较复杂的是整数二分&#xff0c;简单一点的是浮点数二分。 我们首先来说明整数二分,主要来讲解模板。 整数二分&#xff1a; 我们先来说一说使用二分法的前提&#xff0c;要有单调性&#xff0c;然后可以根据某种性质来划分成…

【算法小记】——机器学习中的概率论和线性代数,附线性回归matlab例程

内容包含笔者个人理解&#xff0c;如果错误欢迎评论私信告诉我 线性回归matlab部分参考了up主DR_CAN博士的课程 机器学习与概率论 在回归拟合数据时&#xff0c;根据拟合对象&#xff0c;可以把分类问题视为一种简答的逻辑回归。在逻辑回归中算法不去拟合一段数据而是判断输入…

linux杀毒软件clamav安装使用

1、下载 在下面地址下载&#xff1a;https://www.clamav.net/downloads 2、安装 clamav-1.2.1.linux.x86_64.rpm放在/home路径。 执行&#xff1a; chmod -R 777 /home/clamav-1.2.1.linux.x86_64.rpm rpm -ivh clamav-1.2.1.linux.x86_64.rpm3、下载病毒库 下载路径&am…

数仓建设学习路线(三)元数据管理

什么是元数据&#xff1f; 简单来说就是描述数据的数据&#xff0c;更直白来说就是描述表名、表制作者、表字段、表生命周期、表存粗等信息的数据 元数据该如何管理 工具化 开源&#xff1a; 可通过atlas获取表依赖及信息做二次开发&#xff0c;或者完成可视化界面 平台化&am…

梳理Langchain-Chatchat知识库API接口

一.Langchain-Chatchat 知识库管理 1.Langchain-Chatchat 对话和知识库管理界面 Langchain-Chatchat v0.28 完整的界面截图&#xff0c;如下所示&#xff1a; 2.知识库中源文件和向量库 知识库 test 中源文件和向量库的位置&#xff0c;如下所示&#xff1a; 3.知识库表结构 k…

JavaWeb之开发介绍 --黑马笔记

什么是 Web &#xff1f; Web&#xff1a;全球广域网&#xff0c;也称为万维网(www World Wide Web)&#xff0c;能够通过浏览器访问的网站。 Web 网站的工作流程 上图解释&#xff1a; 当你在浏览器中输入网址或点击一个链接时&#xff0c;浏览器会向前端服务器发起请求&…

CSAPP fall2015 深入理解计算机系统 Cache lab详解

Cache Lab cache lab 缓存实验 代码下载 从CSAPP上面下载对应的lab代码 http://csapp.cs.cmu.edu/3e/labs.html 环境准备 需要安装 valgrind。可以参考文章Valgrind centos。 安装好以后执行valgrind --version可以看到版本号。 Cache simulator cache simulator not a …

API接口安全总结

接口分类 HTTP接口 RPC接口&#xff08;客户端和服务器端的连接 例如游戏登陆&#xff09;非web协议&#xff0c;PRC 远程过程调用 Remote Procedure Call&#xff0c;其就是一个节点请求另外一个节点提供的服务。当两个物理分离的子系统需要建立逻辑上的关联时&#xff0c;R…

第08章_面向对象编程(高级)(static,单例设计模式,理解mian方法,代码块,final,抽象类与抽象方法,接口,内部类,枚举类,注解,包装类)

文章目录 第08章_面向对象编程(高级)本章专题与脉络1. 关键字&#xff1a;static1.1 类属性、类方法的设计思想1.2 static关键字1.3 静态变量1.3.1 语法格式1.3.2 静态变量的特点1.3.3 举例1.3.4 内存解析 1.4 静态方法1.4.1 语法格式1.4.2 静态方法的特点1.4.3 举例 1.5 练习 …

小土堆pytorch学习笔记001

1、Pytorch环境的配置与安装。 &#xff08;1&#xff09;建议安装&#xff1a;Anaconda &#xff08;2&#xff09;检查显卡&#xff1a;GPU &#xff08;3&#xff09;管理环境&#xff08;不同版本的pytorch 版本不同&#xff09;&#xff1a; conda create -n pytorch…

【开源】基于JAVA+Vue+SpringBoot的农家乐订餐系统

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 用户2.2 管理员 三、系统展示四、核心代码4.1 查询菜品类型4.2 查询菜品4.3 加购菜品4.4 新增菜品收藏4.5 新增菜品留言 五、免责说明 一、摘要 1.1 项目介绍 基于JAVAVueSpringBootMySQL的农家乐订餐系统&#xff0c…

防御保护----信息安全

网络安全概述 信息安全&#xff1a;防止任何对数据进行未授权访问的措施&#xff0c;或者防止造成信息有意无意泄露、破坏、丢失等问题的发生&#xff0c;让数据处于远离危险、免于威胁的状态和特性。 网络安全&#xff1a;计算机网络环境下的信息安全。 网络安全背景 网络空间…

STM32单片机学习5--STM32中断

文章目录 一、前言二、NVIC中断控制器2.1、NVIC结构体成员2.2、抢占优先级和响应优先级2.3、NVIC的优先级组 三、EXTI外部中断四、中断实战4.1、确定连线4.2、配置中断控制端口4.3、配置中断端口4.4、配置中断服务函数4.5、主函数调用 一、前言 单片机无系统执行逻辑&#xff…

央视:人工智能规模达5000亿元,企业超4400家,生成式AI发展进入快车道

2023年&#xff0c;对世界和中国来讲都是非常不平凡的一年。新一代信息技术&#xff0c;如5G、大数据和云计算&#xff0c;正在引领全球科技和产业变革的潮流。这些技术已经深深地融入了经济社会发展的各个领域&#xff0c;推动信息通信业实现了跨越式的发展。 1、AI助力产业发…

教你三个方法去除图片上的涂鸦快收藏起来吧

在数字时代&#xff0c;我们经常需要在图片上进行各种编辑和修改&#xff0c;以使其符合我们的需求。然而&#xff0c;有时候我们会遇到一些图片上的涂鸦&#xff0c;这些涂鸦不仅影响了图片的美观度&#xff0c;还破坏了图片的整体效果。那么图片上的涂鸦怎么去掉&#xff0c;…