在winidow中,系统会自动读取随身wifi的window驱动并安装,同时我们可以看到,网卡自带的install_linux文件说明也有linux驱动,遗憾的是,在ubuntu系统上始终无法正确识别,因为ubuntu认为是存储设备,但是又无法检测出usb网卡,因此也无法挂载,所以需要我们自己修改ubuntu.
解决步骤:
- 插入随身wif,按Ctrl +Alt+t打开终端,输入lsusb,显示目前所有的usb设备
root@pve:~# lsusb
Bus 002 Device 002: ID 0bc2:ab24 Seagate RSS LLC Backup Plus Portable Drive
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge
Bus 001 Device 003: ID 040a:2814 Kodak Co. USB Composite Device
Bus 001 Device 002: ID 12d1:1c20 Huawei Technologies Co., Ltd. R205 Mobile WiFi (Charging)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
- 可以看到我的华为随身wifi是被当做storage mode,我们要修改这个mode,让系统连网,
修改/etc/usb_modeswitch.conf文件
sudo gedit /etc/usb_modeswitch.conf
3.添加以下内容
# HUAWEI R205 Mobile WiFi
DefaultVendor=0x12d1
DefaultProduct=0x1c20
TargetVendor=0x12d1
TargetProduct=0x1c20
MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
保存
4.现在修改的结果还没有生效,需要usb_modeswitch
sudo usb_modeswitch -c /etc/usb_modeswitch.conf
5.成功
root@pve:~# usb_modeswitch -c /etc/usb_modeswitch.conf
Look for target devices ...
Found devices in target mode or class (1)
Look for default devices ...
Found devices in default mode (1)
Access device 002 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
with class 8
Use endpoints 0x01 (out) and 0x81 (in)
Looking for active drivers ...
OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
Read the response to message 1 (CSW) ...
Response successfully read (13 bytes), status 1
Reset response endpoint 0x81
Reset message endpoint 0x01
-> Run lsusb to note any changes. Bye!
设置网络
- 重启PVE
pve节点 - 系统 - 网络
应该能看到列表:多了一个网络设备
| 名称 | 类别 | |
|---|---|---|
| enp2s0 | 网络设备 | |
| enp3s0 | 网络设备 | |
| enp4s0 | 网络设备 | |
| enp5s0 | 网络设备 | |
| enxa85a… | 网络设备 |
- 测试
ping 192.168.8.1
要是能ping得通就成一大半了。继续设置,使得能访问外网
创建网桥
pve节点 - 系统 - 网络
创建:Linux Bridge
名称:vmbr8
自动启动:√
IPv4/CIDR:192.168.8.9/24
网关(IPv4):192.168.8.1
桥接端口:enxa85ae03d888a //这里就填
备注:HUAWEI路由就好了
设置DNS
上面设置完还是无法ping通baidu,需要正确设置DNS
pve节点 - 系统 - 「DNS」
编辑:
搜索域:example.com
DNS服务器 1:192.168.8.1 //不要填多个,会拖慢解析速度
DNS服务器 2:
DNS服务器 3:
修改虚拟机网桥
前面创建新的网桥vmbr8,就是方便不同网络环境,给虚拟机的切换
「硬件」- 「网络设备」- 编辑:
编辑:网络设备
桥接:vmbr8
模型:VirtIO(半虚拟化)
遇到的问题
无法实现网卡热插拔:
重新插上USB网卡,PVE没网;如果直接重启PVE网络,导致虚拟机断网
例如:直接 systemctl restart networking.service;Win10虚拟机需要关机-再开机,软重启不起作用
解决:
- 添加定时任务
*/1 * * * * /usr/bin/ping -c 2 baidu.com > /dev/null || /usr/sbin/ifreload -a > /dev/null 2>&1
识别为大容量存储问题
插上USB网卡,确保没有设置直通给任何虚拟机(包括没启动的虚拟机)
lsusb可以看到华为随身wifi是被当做(Mass storage mode)
#lsusb
Bus 002 Device 002: ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131(Mass storage mode)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 040a:2814 Kodak Co. USB Composite Device
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
解决
- 运行:
modprobe rndis_host
modprobe 命令用于在 Linux 系统中加载内核模块。rndis_host 是一个内核模块,用于支持 RNDIS(Remote Network Driver Interface Specification)主机模式。
当你运行 modprobe rndis_host 命令时,它会尝试加载 rndis_host 内核模块。如果该模块可用并正确安装,它将被加载到内核中,以提供所需的功能。
usb-modeswitch
apt install usb-modeswitch -y
前后对比
usb-devices
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 3 Spd=5000 MxCh= 0
D: Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1
P: Vendor=12d1 ProdID=1f01 Rev=01.02
S: Manufacturer=HUAWEI_MOBILE
S: Product=HUAWEI_MOBILE
S: SerialNumber=0123456789ABCDEF
C: #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=8mA
I: If#=0x0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
lsusb -tv
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M
ID 1d6b:0003 Linux Foundation 3.0 root hub
|__ Port 1: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
usb-devices
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=5000 MxCh= 0
D: Ver= 3.00 Cls=02(commc) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1
P: Vendor=12d1 ProdID=14db Rev=01.02
S: Manufacturer=HUAWEI_MOBILE
S: Product=HUAWEI_MOBILE
C: #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=8mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I: If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
lsusb -tv
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M
ID 1d6b:0003 Linux Foundation 3.0 root hub
|__ Port 1: Dev 4, If 0, Class=Communications, Driver=cdc_ether, 5000M
ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131
|__ Port 1: Dev 4, If 1, Class=CDC Data, Driver=cdc_ether, 5000M
ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131