12

I can set the MTU of an interface, eg:

ip link set dev eth0 mtu 9000

However different interfaces and different machines appear to have different limits resulting in an error:

Error: mtu greater than device maximum.

I'm trying to find a way to check if NIC supporting a specific MTU size or not without trying to set it first; actually, I want to find the theoretical maximum MTU on all interfaces on all my servers.

I've inspected all features of ethtool, looked in /sys/class/net, etc, but all I can find is the current MTU value.

Are there a way to see how high MTU can be on interface without trying it?

3
  • I don't know of any cananonical way to find out what you want, but you must ask yourself why do you want to change the MTU. 9/10 cases, your default MTU is just fine. And there is something to be said about jumbo frames, as seen here : archive.nanog.org/sites/default/files/…
    – schaiba
    Nov 14, 2019 at 8:06
  • I can answer this question pretty easily: because we are running network appliances and those are asking to provide them with as much MTU as we could in their cluster fabric network, but it should be the same MTU on all servers. So I want to see what number can I make without breaking stuff in the process (so, no trial and error). Nov 15, 2019 at 9:39
  • @GeorgeShuklin I've edited the question to aid future readers, feel free to revert the edit if you think it is incorrect. Jun 3, 2020 at 9:20

2 Answers 2

15

Amazingly, I found that ip reports this information if asked.

ip -d link list

21: enxa44cc8aa52bd: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 link/ether a4:4c:c8:aa:52:bd brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 9194 addrgenmode none numtxqueues 1 numrxqueues 1 gso_max_size 16354 gso_max_segs 65535

minmtu and maxmtu is the answer.

1
  • 2
    Note that the reduced ip command included in busybox does not support the -d option to show the minmtu and maxmtu. Aug 6, 2021 at 14:25
4

you can send a specific mtu size with ping

ping -M do -s <mtu-size> <ip-address>

<ip-address> being the local ip of the interface you wish to check.

Note there is an additional 28 bytes as a header when using this method.

Just keep increasing the mtu size (in the ping command) until you get a Message too long error or similar.

Current MTU setting and IP:

[root@centos7 ~]# ip l  | grep ens37 | awk '{print $4,$5}'
mtu 1500
[root@dev-worker1 ~]# ip addr show ens37 | grep "inet " | awk '{print $2}'
10.10.10.10/24

sending a packet larger than the current MTU setting, but is still accepted:

[root@centos7 ~]#  ping -M do -s 8972 10.10.10.10
PING 10.10.10.10 (10.10.10.10) 8972(9000) bytes of data.
8980 bytes from 10.10.10.10: icmp_seq=1 ttl=64 time=0.103 ms
8980 bytes from 10.10.10.10: icmp_seq=2 ttl=64 time=0.067 ms

Sending one too large. Some distros may actually tell you the maximum via this method. E.g Centos7:

[root@centos7 ~]#  ping -M do -s 118972 10.10.10.10
Error: packet size 118972 is too large. Maximum is 65507

Once done, you can set it to the maximum if that's what you desire using ip link

ip link set <interface name> mtu <mtu value>

edit:

  • Clarified I'm referring to pinging a local IP and provided example.
  • I do not know for sure that some distros will output the actual limit, as my testing environment interfaces have max capabilities of 65535 bytes.
6
  • 1
    You completely missed the point of question. I don't need to know what MTU I have on server now (it's in ip l output), I want to know the maximum my hardware is supported. Nov 15, 2019 at 9:37
  • 1
    ip l output is indeed what is set. ping -M do -s <mtu-size> <ip-address> ignores the set mtu size and will send a packet to that interface of whatever desired size. if it's too big (not for the current set size, but the interface's maximum capability), it will complain. please see: access.redhat.com/solutions/2440411 Nov 20, 2019 at 14:03
  • This looks to be rather close. The question now is, where does ping get this maximum value from?
    – Panki
    Nov 20, 2019 at 14:09
  • it may be just just because 65535 bytes is the absolute maximum it could ever be; therefore 65507 is the max ping can send after the headers. I can't see how it would know for sure until it hit a limit and got a packet too large or similar response the more I think about it Nov 20, 2019 at 14:22
  • 1
    This answer is entirely wrong, and misunderstands the meaning of both the question and it's own results. The 65507 limit is NOT the hardware MTU limit. It's the maximum IP packet size less 28 bytes for the header. This is not the same as the hardware limit or the configured limit. IPv4 uses two bytes to show the packet size (see here) which limits the total packet size to 65535 bytes. Less 28 bytes for a header = 65507 Jun 3, 2020 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.