Skip to Content

3 ways to check MTU size in Linux

This article is part of the following series.

 

In order to get the best performance when using the Internet, it is important to set the Maximum Transmission Unit (MTU) size properly. In this blog post, we will discuss 3 ways to check MTU size in Linux. We will also provide steps on how to change the MTU size if needed. Let’s get started!

The following commands can be used to check mtu size in Linux.

  • using the ip command
  • using the ifconfig command
  • using the cat /sys/class/net/<interface>/mtu command

 

what is MTU?

The Maximum Transmission Unit (MTU) is the size of the largest packet or frame that can be transmitted on a network. The MTU size is determined by the physical layer of the network. For example, Ethernet has an MTU size of 1500 bytes.

It is important to check MTU size because the wrong setting can lead to poor network performance. A too-large MTU can cause fragmentation, which can lead to lower throughput and higher latency. A too-small MTU can also cause problems, such as dropped packets and retransmissions.

The best practice for MTU size in Linux is to set the MTU size to the same size as the largest packet size that your network can handle. This will help to ensure that packets are not dropped due to being too large.

The MTU size on server side should be same as the MTU size in switch side. otherwise it will cause issues.

Related:

 

check MTU size with ifconfig Command in Linux

The easiest way to check MTU size in Linux is using the ifconfig command. Open the terminal and run ifconfig interface name |grep mtu. This command will list the configuration of a network interface including MTU size.

Replace [interface] with the name of your network interface. For example, if you want to view the MTU size of the eth0 interface, you would use the following command: ifconfig eth0 | grep mtu

To change the MTU size of a network interface, use the following command: ifconfig [interface] mtu [size]

Replace [interface] with the name of your network interface and [size] with the desired MTU size. For example, to change the MTU size of the eth0 interface to 1400 bytes, you would use the following command: ifconfig eth0 mtu 1400

check MTU size with ip Command in Linux

The ip command can be used to show or set various network interface parameters. To view the MTU size of a network interface, use the following command: ip link show dev [interface]

Replace [interface] with the name of your network interface. For example, if you want to view the MTU size of the eth0 interface, you would use the following command: ip link show dev eth0

The output of this command will look something like this:
eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

As you can see, the MTU size is 1500 bytes for this interface.To change the MTU size of a network interface, use the following command: ip link set dev [interface] mtu [size]

For example, to change the MTU size of the eth0 interface to 1400 bytes, you would use the following command: ip link set dev eth0 mtu 1400

3 ways to Find IP address in Ubuntu terminal

check MTU size with cat /sys/class/net/<interface>/mtu Command in Linux

The cat command can be used to view the contents of a file. To view the MTU size of a network interface, use the following command: cat /sys/class/net/[interface]/mtu

Replace [interface] with the name of your network interface. For example, if you want to view the MTU size of the eth0 interface, you would use the following command: cat /sys/class/net/eth0/mtu

The output of this command will be the MTU size for this interface. To change the MTU size of a network interface, use the following command: echo [size] > /sys/class/net/[interface]/mtu

Replace [interface] with the name of your network interface and [size] with the desired MTU size. For example, to change the MTU size of the eth0 interface to 1400 bytes, you would use the following command:echo 1400 > /sys/class/net/eth0/mtu

How to change MTU size in Linux?

You can change the MTU size of a network interface using the ip or ifconfig commands. For more information, see the “Using the ip Command” and “Using the ifconfig Command” sections above.

FAQ about MTU size

What is jumbo frame?

A “jumbo frame” is a frame that is larger than the standard MTU size. Jumbo frames are typically used to improve performance when transferring large files. Many Ethernet switches support jumbo frames, but your computer’s network adapter must also support them in order to take advantage of the increased size.

The standard MTU size for Ethernet is 1500 bytes, but jumbo frames can be as large as 9000 bytes. To use jumbo frames, you must first configure your network adapter and then your switch. Consult your network adapter’s documentation for instructions on how to do this. Once your network adapter is configured, you can enable jumbo frames on your switch by following the instructions in your switch’s documentation.

Enabling jumbo frames can improve performance when transferring large files, but it can also cause problems if your network is not configured properly. Make sure that all of the devices on your network support jumbo frames before enabling them.

Why is my MTU size set to 1500?

The MTU size is typically set to 1500 because this is the maximum size that can be transferred without requiring fragmentation. Fragmentation occurs when a frame is too large to fit into the MTU size of the next hop, and the frame is divided into smaller fragments. This can lead to decreased performance, so it is typically best to avoid fragmentation by using an MTU size of 1500.

Why do we want to change MTU size?

There are a few reasons why you might want to change your MTU size. For example, if you are transferring large files, you may want to increase the MTU size in order to improve performance. Alternatively, if you are having trouble connecting to a network, you may need to decrease the MTU size.

What happens if you use an incorrect MTU size?

If you use an incorrect MTU size, your computer may not be able to communicate with other computers on the network. In some cases, using an incorrect MTU size can cause networking problems or slow down your computer’s performance.

In this article, we have shown you three ways to check MTU size in Linux. We hope this has been helpful! Thank you for reading.

Have a great day! :)”

Daniel Li

Thursday 21st of September 2023

This post is much better than others. Thanks.