2019年11月10日 星期日

[Linux 文章收集] How can I setup the MTU for my network interface?

Source From Here
Preface
MTU (Maximum Transmission Unit) is related to TCP/IP networking in Linux/BSD/UNIX oses. It refers to the size (in bytes) of the largest datagram that a given layer of a communications protocol can pass at a time. You can see current MTU setting with ifconfig command under Linux:
# ifconfig

Output:
  1. eth0      Link encap:Ethernet  HWaddr 00:0F:EA:91:04:07  
  2.          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0  
  3.          inet6 addr: fe80::20f:eaff:fe91:407/64 Scope:Link  
  4.          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
  5.          RX packets:141567 errors:0 dropped:0 overruns:0 frame:0  
  6.          TX packets:141306 errors:0 dropped:0 overruns:0 carrier:0  
  7.          collisions:0 txqueuelen:1000  
  8.          RX bytes:101087512 (96.4 MiB)  TX bytes:32695783 (31.1 MiB)  
  9.          Interrupt:18 Base address:0xc000  
A better way is to use ip command:
$ ip link show

Output:
  1. 1: lo:  mtu 16436 qdisc noqueue  
  2.    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
  3. 2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000  
  4.    link/ether 00:0f:ea:91:04:07 brd ff:ff:ff:ff:ff:ff  
  5. 3: sit0:  mtu 1480 qdisc noop  
  6.    link/sit 0.0.0.0 brd 0.0.0.0  
As you see, MTU set to 1500 for eth0. Let us say you want this to 1400 then you can use any one of the following command to setup MTU.

Setup MTU of Network Interface
# ifconfig eth0 mtu 1400

OR
# ip link set dev eth0 mtu 1400

Verify that new mtu is setup with following command:
$ ip link list

To make the setting permanent for eth0, edit the configuration file /etc/network/interfaces (Debian Linux file)
  1. auto lo  
  2. iface lo inet loopback  
  3.   
  4. auto eth0  
  5. iface eth0 inet static  
  6. name Ethernet LAN card  
  7. address 192.168.1.2  
  8. netmask 255.255.255.0  
  9. broadcast 192.168.1.255  
  10. network 192.168.1.0  
  11. gateway 192.168.1.254  
  12. mtu 1400  
  13. post-up /etc/fw.start  
  14. post-down /etc/fw.stop  
Or /etc/sysconfig/network-scripts/ifcfg-eth0 (Red Hat Linux)
  1. DEVICE=eth0  
  2. BOOTPROTO=static  
  3. BROADCAST=192.168.1.255  
  4. HWADDR=00:0F:EA:91:04:07  
  5. IPADDR=192.168.1.111  
  6. NETMASK=255.255.255.0  
  7. NETWORK=192.168.1.0  
  8. MTU=1400  
  9. ONBOOT=yes  
  10. TYPE=Ethernet  
Save the file and restart network service
If you are using Redhat:
# service network restart

If you are using Debian:
# /etc/init.d/networking restart


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...