我在WSL2中使用Ubuntu20.04,不能在我的生命中永久设置MTU。无论我做什么,重新启动后,它又是1500。我在本机运行Ubuntu时也遇到了同样的问题,并切换到windows,因为Ubuntu无法在VPN上工作,因为MTU是错误的。
真的没有办法永久设置MTU吗?
我试过/etc/dhcp/dhclient.conf
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释
* * GNU nano 4.8 /etc/dhcp/dhclient.conf # Configuration file for /sbin/dhclient. # # This is a sample configuration file for dhclient. See dhclient.conf's # man page for more information about the syntax of this file # and a more comprehensive list of the parameters understood by # dhclient. # # Normally, if the DHCP server provides reasonable information and does # not leave anything out (like the domain name, for example), then # few changes must be made to this file, if any. # option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; send host-name = gethostname(); default interface-mtu 1340; supersede interface-mtu 1340; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers, netbios-name-servers, netbios-scope, rfc3442-classless-static-routes, ntp-servers; #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; #send dhcp-lease-time 3600; #supersede domain-name "fugue.com home.vix.com"; #prepend domain-name-servers 127.0.0.1; #require subnet-mask, domain-name-servers; timeout 300; #retry 60; #reboot 10; #select-timeout 5; #initial-interval 2; #script "/sbin/dhclient-script"; #media "-link0 -link1 -link2", "link0 link1"; #reject 192.33.137.209; #alias { # interface "eth0"; # fixed-address 192.5.5.213; # option subnet-mask 255.255.255.255; #} #lease { # interface "eth0"; # fixed-address 192.33.137.200; # medium "link0 link1"; # option host-name "andare.swiftmedia.com"; # option subnet-mask 255.255.255.0; # option broadcast-address 192.33.137.255; # option routers 192.33.137.250; # option domain-name-servers 127.0.0.1; # renew 2 2000/1/12 00:00:01; # rebind 2 2000/1/12 00:00:01; # expire 2 2000/1/12 00:00:01; #}
*/
*/我也尝试过破坏网络计划,但我认为我的系统不使用它。
也尝试过/etc/网络/接口
mtu 1340发布于 2022-02-17 22:08:45
你是如何证实你的真实MTU的?
我想您的Ubuntu使用Netplan管理器。你问的是CLI,而不是GUI。这是我的建议。
使用“不碎片”选项和指定的数据包大小按数据包平平您的默认GW或局域网中的另一个活动最近的节点。更改数据包大小并找到由对等节点响应的限制大小:
ping 192.168.1.1 -c 2 -M do -s 2000
ping 192.168.1.1 -c 2 -M do -s 1500
ping 192.168.1.1 -c 2 -M do -s 1400
ping 192.168.1.1 -c 2 -M do -s 1472
ping 192.168.1.1 -c 2 -M do -s 1473如果数据包大小大于MTU,则ping响应例如:
ping: local error: message too long, mtu=1500请注意,您在ping命令中使用的数据包大小(-s选项)必须是MTU减去18字节,例如1500-18=1472。
如果未超过MTU,则响应是。
2 packets transmitted, 2 received, 0% packet loss, time 1014ms我假设您的接口名是eth1。
cd /etc/netplan
ls -l
sudo cp 01-network-manager-all.yaml 02-eth1-mtu.yaml
sudo vi 02-eth1-mtu.yaml新文件02-eth1-mtu.yaml的内容示例:
network:
version: 2
renderer: NetworkManager
ethernets:
eth1:
dhcp4: true
mtu: 1000新设置将由命令netplan try应用。如果在执行命令时按Enter键,等待时间将小于120 s。
sudo netplan try现在是通过上述方法验证新MTU大小的时候了。
sudo mv /etc/netplan/02-eth1-mtu.yaml /etc/netplan/02-eth1-mtu.yaml.bak
sudo netplan tryhttps://askubuntu.com/questions/1393338
复制相似问题