linux – 如何永久更改MTU设置

我需要永久性地将MTU更改为1500.永久地我的意思是,如果我重新启动系统或将重新启动服务,它将始终是1500.

我遵循了这篇文章http://www.cyberciti.biz/faq/centos-rhel-redhat-fedora-debian-linux-mtu-size/

但不幸的是,它对我不起作用.

这是我做的:

检查当前的MTU:

eth0: <broADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP qlen 1000 

将MTU =“1500”添加到/ etc / sysconfig / network-scripts / ifcfg-eth0:

[root@ip-xx-xx-xxx~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
PERSISTENT_DHCLIENT=yes
IPV6_MTU="1500"
MTU="1500"

然后再次检查MTU,(没有运气):

root@ip-xx-xx-xxx ~]# service network restart 
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  
Determining IP information for eth0... done.
                                                           [  OK  ]
[root@ip-xx-xx-xxx ~]# ip addr show eth0 
2: eth0: <broADCAST,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP qlen 1000

/ sbin / ifconfig改变了MTU但只是暂时的

[root@ip-xx-xx-xxx ~]# /sbin/ifconfig eth0 mtu 1500 up
[root@ip-xx-xx-xxx ~]# ip addr show eth0 
2: eth0: <broADCAST,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

如果我重新启动网络,它再次是9001:

[root@ip-xx-xx-xxx ~]# service network restart 
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  
Determining IP information for eth0... done.
                                                           [  OK  ]
[root@ip-10-0-1-135 ~]# ip addr show eth0 
2: eth0: <broADCAST,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP qlen 1000
最佳答案
您的环境中的MTU是通过DHCP自动设置的,在您的配置中您具有以下设置:

DEVICE = eth0的

BOOTPROTO = DHCP

所以DHCP实际上是设置MTU大小.在Ubuntu中,您可以编辑以下文件:/etc/dhcp/dhclient.conf

在请求行之前设置这两个命令:

default interface-mtu 1500;

supercede interface-mtu 1500;

我不知道如何在Red Hat中设置它,但我认为该文件名为dhcpd.conf

希望这可以帮助!

相关文章

在Linux上编写运行C语言程序,经常会遇到程序崩溃、卡死等异...
git使用小结很多人可能和我一样,起初对git是一无所知的。我...
1. 操作系统环境、安装包准备 宿主机:Max OSX 10.10.5 虚拟...
因为业务系统需求,需要对web服务作nginx代理,在不断的尝试...
Linux模块机制浅析 Linux允许用户通过插入模块,实现干预内核...
一、Hadoop HA的Web页面访问 Hadoop开启HA后,会同时存在两个...