Configuring the MTU of an Interface
Context
The maximum transmission unit (MTU) determines the maximum number of bytes in IP packets each time a sender can send. The MTU of an IP packet is the number of bytes from the IP header to the data of the packet.
When the IP layer receives an IP packet to be sent, it checks to which local interface the packet needs to be sent and obtains the MTU configured on the interface. The IP layer then compares the MTU with the packet length. If the packet length is longer than the MTU, the IP layer fragments the packet into smaller packets, which are shorter than or equal to the MTU. If unfragmentation is configured, some packets may be discarded during data transmission at the IP layer. To ensure that large packets are not discarded during transmission, configure forcible fragmentation.
- If the configured MTU is excessively small and the packet size is larger, packets are discarded when being forwarded through the forwarding chip. Packets are broken into a great number of fragments when being forwarded through the CPU, affecting proper data transmission.
- If the size of packets exceeds the MTU supported by a transit node or a receiver, the transit node or receiver fragments the packets or even discards them, aggravating the network transmission load.
The default MTU is recommended. When the size of packets to be transmitted or the device that receives packets changes, you can change the MTU based on the actual network.
The configured MTU takes effect for data packets on the control plane.
For X series cards, the configured MTU takes effect for data packets on the forwarding plane only after you run the ipv4 fragment enable command to enable packet fragmentation. The configured MTU takes effect for GRE packets on the forwarding plane without the need to execute the ipv4 fragment enable command. For other cards, the configured MTU does not take effect for data packets on the forwarding plane.
Procedure
- Run system-view
The system view is displayed.
- Run interface interface-type interface-number
The Ethernet interface view is displayed.
- Run undo portswitch
The Ethernet interface is switched from Layer 2 mode to Layer 3 mode.
- Run mtu mtu
The MTU of the interface is configured.
By default, the MTU of an interface is 1500 bytes.
Configuring the MTU of an interface affects the maximum number of bytes in IP packets to be sent by the interface at a time. This configuration also affects the maximum frame length of sent Ethernet packets. The Ethernet packet size cannot exceed the maximum frame length allowed by the peer interface, which can be set using the jumboframe enable command.
- Run restart
The interface is restarted.