红色为命令和注释、修改后的MTU,蓝色的为修改前的MTU
Linux
中设置
MTU
值的三种方法:
[root@localhost ~]# ifconfig //
查看网卡信息
eth0 Link encap:Ethernet HWaddr 00: 0C :29: 0C :B8: 6A
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80:: 20c :29ff:fe 0c :b 86a /64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1948 errors:0 dropped:0 overruns:0 frame:0
TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:208651 (203.7 KiB) TX bytes:17782 (17.3 KiB)
Interrupt:169 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:7442 errors:0 dropped:0 overruns:0 frame:0
TX packets:7442 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9177752 (8.7 MiB) TX bytes:9177752 (8.7 MiB)
第一种:
[root@localhost ~]# ifconfig eth0 mtu 1492
eth0 Link encap:Ethernet HWaddr 00: 0C :29: 0C :B8: 6A
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80:: 20c :29ff:fe 0c :b 86a /64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1492 Metric:1
RX packets:1948 errors:0 dropped:0 overruns:0 frame:0
TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:208651 (203.7 KiB) TX bytes:17782 (17.3 KiB)
Interrupt:169 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:7442 errors:0 dropped:0 overruns:0 frame:0
TX packets:7442 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9177752 (8.7 MiB) TX bytes:9177752 (8.7 MiB)
[root@localhost ~]#
第二种方法:
[root@localhost ~]# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00: 0c :29: 0c :b8: 6a brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0 .0 brd 0.0.0.0
[root@localhost ~]# ip link set dev eth0 mtu 1492
[root@localhost ~]# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc pfifo_fast
qlen 1000
link/ether 00: 0c :29: 0c :b8: 6a brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0 .0 brd 0.0.0.0
[root@localhost ~]#
第三种方法:
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c 970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
HWADDR=00: 0C :29: 0C :B8: 6A
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.10.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c 970 [PCnet32 LANCE]
DEVICE=eth0
MTU=1492
BOOTPROTO=none
HWADDR=00: 0C :29: 0C :B8: 6A
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.10.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
[root@localhost ~]#
最后重启网络服务
[root@localhost ~]#service network restart eth0
Windows xp\vista\win 7
中测试
MTU
修改注册表中以下这项,
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services \Tcpip\Parameters\Interfaces\
在这项下有几个网卡信息,你点击每个看右边
IPAddress
项,对应自己网卡
IP
的就是的再
输入数值。
至于为什么
Windows
中
MTU
是
1492
,是因为我的是
ADSL
拨号(pppoe)上网的,不是
1492
可能有些网页无法游览。
MTU
最大值在以太网帧中是
1500
字节。