ubuntu20.04只有10m带宽

如题所述

内存或者上传下载慢。
虚拟机网速慢,我觉得就两个限制因素。一个是虚拟机的内存,内存小了,上传和下载的速率就慢了,就像内存小的虚拟机跑得慢是一个道理。
虚拟机VirtualMachine指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统
一.修改网卡参数
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.创建/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
————————————————
版权声明:本文为CSDN博主「Mr_老冷」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mr_oldcold/article/details/93617999
温馨提示:答案为网友推荐,仅供参考
相似回答