手上有個win10平闆,經折騰,刷成了ubuntu18,但自帶的wifi經千辛萬苦驅動起來後,内網ping值高達200+,遂購買usb網卡一張,ping值降到2以内,可以接受,但是網速隻有10m,無法接受
一.修改網卡參數
1.1 查詢網卡名
ip addr或ifconfig均可
xue@xue-EZpad6:~$ ip addr
2: enx00e04c3603d8: <BROADCAST,MULTICAST,UP,LOWER_UP> 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 重新開機裝置
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