ubuntu18 usb网卡网速只有10M解决方法

手上有个win10平板,经折腾,刷成了ubuntu18,但自带的wifi经千辛万苦驱动起来后,内网ping值高达200+,遂购买usb网卡一张,ping值降到2以内,可以接受,但是网速只有10m,无法接受

一.修改网卡参数

1.1 查询网卡名

ip addr或ifconfig均可

xue@xue-EZpad6:~$ ip addr
2: enx00e04c3603d8:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:e0:4c:36:03:d8 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.110/24 brd 10.0.0.255 scope global dynamic noprefixroute enx00e04c3603d8
       valid_lft 73698sec preferred_lft 73698sec
    inet6 fe80::75f7:f5c3:e075:ade6/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

1.2 安装ethtool工具

sudo apt install ethtool

xue@xue-EZpad6:~$ ethtool enx00e04c3603d8
Settings for enx00e04c3603d8:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 10Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00007fff (32767)
                               drv probe link timer ifdown ifup rx_err tx_err tx_queued intr tx_done rx_status pktdata hw wol
        Link detected: yes

问题就在这里,Speed: 10Mb/s

1.3 通过测试,命令如下

sudo ethtool -s enx00e04c3603d8 speed 100 duplex full autoneg off

speed 100 设置速度(我的网卡最大只支持100Mb/s),duplex full 设置全双工模式,  autoneg off 关闭自动协商

注:最重要的是第三个参数,开启了自动协商,设置速度是无效的,因为网卡和路由器协商的结果就是10Mb/s,只有关闭了协商,才能让网卡强制运行100Mb/s模式.

 

二.设置开机启动

经过ethtool设置后,只是当前有效,重启设备后即失效,故需把命令添加到开机启动中,让他自动生效

2.1 编辑/lib/systemd/system/rc.local.service,设置启动参数,添加如下代码

sudo vim /lib/systemd/system/rc.local.service 

[Install]
WantedBy=multi-user.target
Alias=rc-local.service

2.2设置软连接,开机启动回去/etc/……这个目录下去找文件

ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/rc.local.service

2.3创建/etc/rc.local,写入需要开启启动的命令

sudo vim /etc/rc.local

#!/bin/bash
ethtool -s enx00e04c3603d8 speed 100 duplex full autoneg off
exit 0

:x保存退出

2.4 为/etc/rc.local附加执行权限

sudo chmod +x /etc/rc.local

2.5 重启设备

reboot

2.6 用ethtool检查结果

xue@xue-EZpad6:~$ ethtool enx00e04c3603d8
Settings for enx00e04c3603d8:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: off
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00007fff (32767)
                               drv probe link timer ifdown ifup rx_err tx_err tx_queued intr tx_done rx_status pktdata hw wol
        Link detected: yes

Speed: 100Mb/s

成功.

你可能感兴趣的:(Linux,Ubuntu)