Ubuntu16.04安装无线网卡驱动+设置无线热点(AP)

目录

  • 选购USB无线网卡--rtl8821CU
  • 下载相关驱动--[https://github.com/qslia/rtl8821CU](https://github.com/qslia/rtl8821CU).
  • 安装过程
  • 设置无线热点(AP)
  • 手机/笔记本即可连接该热点

安装 Realtek 系列无线网卡 Linux 驱动: https://blog.csdn.net/opipa/article/details/51919847.

选购USB无线网卡–rtl8821CU

下载相关驱动–https://github.com/qslia/rtl8821CU.

获得压缩文件:rtl8821CU-master.zip
将其放置在/home下(以便后续操作)

安装过程

xxx@xxx:~$ sudo apt-get install dkms
xxx@xxx:~$ DRV_NAME=rtl8821CU
xxx@xxx:~$ DRV_VERSION=5.2.5.3
xxx@xxx:~$ sudo mkdir /usr/src/${DRV_NAME}-${DRV_VERSION}
xxx@xxx:~$ git archive master | sudo tar -x -C /usr/src/${DRV_NAME}-${DRV_VERSION}
若此时出现报错如下

fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
tar: 它似乎不像是一个 tar 归档文件
tar: 由于前次错误,将以上次的错误状态退出

或是

fatal: Not a valid object name
tar: 它似乎不像是一个 tar 归档文件
tar: 由于前次错误,将以上次的错误状态退出


xxx@xxx:~$ sudo unzip rtl8821CU-master.zip -d /usr/src/${DRV_NAME}-${DRV_VERSION}
xxx@xxx:~$ sudo mv /usr/src/rtl8821CU-5.2.5.3/rtl8821CU-master/ /usr/src/rtl8821CU-5.2.5.4/
xxx@xxx:~$ sudo rm -r /usr/src/rtl8821CU-5.2.5.3
xxx@xxx:~$ sudo mv /usr/src/rtl8821CU-5.2.5.4 /usr/src/rtl8821CU-5.2.5.3
接下来…
xxx@xxx:~$ sudo dkms add -m ${DRV_NAME} -v ${DRV_VERSION}
显示信息如下:

Creating symlink /var/lib/dkms/rtl8821CU/5.2.5.3/source ->
                 /usr/src/rtl8821CU-5.2.5.3
                 
DKMS: add completed.

xxx@xxx:~$ sudo dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
显示信息如下:

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area....
'make' KVER=4.15.0-101-generic......................
Signing module:
 - /var/lib/dkms/rtl8821CU/5.2.5.3/4.15.0-101-generic/x86_64/module/8821cu.ko
Secure Boot not enabled on this system.
cleaning build area....

DKMS: build completed.

xxx@xxx:~$ sudo dkms install -m ${DRV_NAME} -v ${DRV_VERSION}
显示信息如下:

8821cu:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.15.0-101-generic/updates/dkms/

depmod.......

DKMS: install completed.

打开解压后的文件:
xxx@xxx:~/rtl8821CU-master$ make
会显示好多内容,结束行为:

make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-101-generic'

xxx@xxx:~/rtl8821CU-master$ sudo make install
显示结果如下:

install -p -m 644 8821cu.ko  /lib/modules/4.15.0-101-generic/kernel/drivers/net/wireless/
/sbin/depmod -a 4.15.0-101-generic

xxx@xxx:~/rtl8821CU-master$ sudo modprobe 8821cu
此时插入USB无线网卡,
xxx@xxx:~$ lsusb
可以看到

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 002: ID 046d:c31d Logitech, Inc. Media Keyboard K200
Bus 001 Device 022: ID 0bda:1a2b Realtek Semiconductor Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 022: ID 0bda:1a2b Realtek Semiconductor Corp.
该行显示USB无线网卡信息,可以看到‘’0bda:1a2b‘’。最后切换USB网卡的模式为无线网卡模式:
xxx@xxx:~$ sudo usb_modeswitch -KW -v 0bda -p 1a2b
成功的输出结果显示:

Take all parameters from the command line


 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.2.5 (C) Josua Dietze 2015
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b

StandardEject=1
NeedResponse=0

Look for default devices ...
  found USB ID 1d6b:0003
  found USB ID 046d:c077
  found USB ID 046d:c31d
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 1d6b:0002
  found USB ID 1d6b:0003
  found USB ID 1d6b:0002
 Found devices in default mode (1)
Access device 025 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes).
Trying to send message 2 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 2 (CSW) ...
 Device seems to have vanished after reading. Good.
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

某些失败的输出结果显示:

Take all parameters from the command line


 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.2.5 (C) Josua Dietze 2015
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b

StandardEject=1
NeedResponse=0

Look for default devices ...
  found USB ID 1d6b:0003
  found USB ID 046d:c077
  found USB ID 046d:c31d
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 1d6b:0002
  found USB ID 1d6b:0003
  found USB ID 1d6b:0002
 Found devices in default mode (1)
Access device 022 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response reading failed (error -7)
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

重启后再设置
lsusb
显示

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 002: ID 046d:c31d Logitech, Inc. Media Keyboard K200
Bus 001 Device 022: ID 0bda:1a2b Realtek Semiconductor Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 022: ID 0bda:1a2b Realtek Semiconductor Corp.
该行显示USB无线网卡信息,可以看到‘’0bda:1a2b‘’。最后切换USB网卡的模式为无线网卡模式:
sudo usb_modeswitch -KW -v 0bda -p 1a2b
不行的话多试几次即可.

设置无线热点(AP)

https://jingyan.baidu.com/article/03b2f78c5a3c975ea237ae09.html.
依次点击
桌面右上角网络
编辑连接…
增加
Wi-Fi
新建…
在 Wi-Fi 随意填写 链接名称
填写SSID(电脑发出来的无线标识名)
在 模式 栏选择 热点(Hotspot)
切换到 Wi-Fi 安全性 选项卡并选择 WPA及WPA2个人
在 密码 中填写密码
切换到 IPv4 设置并在 方法 中选择 与其他计算机共享
切换到 IPv6 设置,并在 方法 中选择 I忽略
保存
最后
依次点击
桌面右上角网络
连接到隐藏的Wi-Fi网络
选择SSID
连接

手机/笔记本即可连接该热点

你可能感兴趣的:(Ubuntu,ubuntu,经验分享)