16

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?

Philip Couling
  • 17,591
  • 5
  • 42
  • 82
George Shuklin
  • 591
  • 1
  • 5
  • 9
  • 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 : https://archive.nanog.org/sites/default/files/wednesday_general_steenbergen_antijumbo.pdf – schaiba Nov 14 '19 at 08: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). – George Shuklin Nov 15 '19 at 09:39
  • @GeorgeShuklin I've edited the question to aid future readers, feel free to revert the edit if you think it is incorrect. – Philip Couling Jun 03 '20 at 09:20

2 Answers2

22

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.

George Shuklin
  • 591
  • 1
  • 5
  • 9
  • 2
    Note that the reduced `ip` command included in `busybox` does not support the `-d` option to show the `minmtu` and `maxmtu`. – Alex Stragies Aug 06 '21 at 14:25
  • I would presume though it should be `ip -d link show`. Although the `list` works, but I don't see it mentioned in `man ip-iink` or zsh autcompletions when pressing TAB. I would guess using `list` is deprecated. – Hi-Angel Jun 03 '23 at 14:00
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.
RobotJohnny
  • 1,021
  • 8
  • 18
  • 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. – George Shuklin Nov 15 '19 at 09:37
  • 1
    `ip l` output is indeed what is set. `ping -M do -s ` 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: https://access.redhat.com/solutions/2440411 – RobotJohnny Nov 20 '19 at 14:03
  • This looks to be rather close. The question now is, where does `ping` get this maximum value from? – Panki Nov 20 '19 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 – RobotJohnny Nov 20 '19 at 14:22
  • I expected to find some low-level magic of ethtool, or roaming in /sys, but neither have any information on hardware limit for MTU. /sad – George Shuklin Nov 20 '19 at 14:47
  • 2
    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](https://en.wikipedia.org/wiki/IPv4) uses two bytes to show the packet size ([see here](https://en.wikipedia.org/wiki/IPv4#/media/File:IPv4_Packet_-en.svg)) which limits the total packet size to 65535 bytes. Less 28 bytes for a header = 65507 – Philip Couling Jun 03 '20 at 09:09