Page 1 of 1

How to permanently change MTU

Posted: Tue Jul 23, 2019 1:48 pm
by EOFFJM
Hi

I would like to know how to change the MTU permanently on Raspberry pi 3 Model B+.
I heard that you need to change it on /etc/network/interfaces but I do not know what to add or change.
When I open /etc/network/interfaces, I get

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
I use static IP so do I also need to change something on /etc/dhcpcd.conf?

I can already change the MTU temporarily with

Code: Select all

sudo ifconfig eth0 mtu 1200 up
on the terminal but when I reboot the RPi, it goes back to 1500.

Thanks.

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 1:56 pm
by trejan
Add "static interface_mtu=1200" to your Ethernet interface in /etc/dhcpcd.conf

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 2:07 pm
by EOFFJM
trejan wrote:
Tue Jul 23, 2019 1:56 pm
Add "static interface_mtu=1200" to your Ethernet interface in /etc/dhcpcd.conf
I did what you wrote but when this is what I got when I did ifconfig.

Code: Select all

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 131.246.76.243  netmask 255.255.255.0  broadcast 131.246.76.255
        inet6 2001:638:208:1203:2d70:f0a2:2052:44b  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::d96a:53ca:4eb5:2b5f  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:b1:78:d5  txqueuelen 1000  (Ethernet)
        RX packets 3086  bytes 218203 (213.0 KiB)
        RX errors 0  dropped 2  overruns 0  frame 0
        TX packets 2566  bytes 1720467 (1.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
It says mtu 1500 still.

What I did was add "static interface_mtu=1200" below

"interface eth0
static ip_address=131.246.76.243/24"

on /etc/dhcpcd.conf

Thanks.

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 2:30 pm
by epoch1970
Look at the routes: "ip route show". Normally the mtu will be set as an option there.

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 2:38 pm
by EOFFJM
epoch1970 wrote:
Tue Jul 23, 2019 2:30 pm
Look at the routes: "ip route show". Normally the mtu will be set as an option there.
Thanks. This is what I got.

Code: Select all

131.246.76.0/24 dev eth0 proto kernel scope link src 131.246.76.243 metric 202  mtu 1200
Why does mtu say 1200 when I do "ip route show" and 1500 when I do "ifconfig"?

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 3:12 pm
by epoch1970
That's the way dhcpcd implemented it, if you look around you can find a Debian ticket on that question (where I found the answer...)
As to why, I don't know. I suppose PMTU discovery is supposed to work almost always, except towards some hosts/networks/routes. So clamping is better done on the routes and not the interface.
Pure speculation.

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 3:17 pm
by EOFFJM
epoch1970 wrote:
Tue Jul 23, 2019 3:12 pm
That's the way dhcpcd implemented it, if you look around you can find a Debian ticket on that question (where I found the answer...)
As to why, I don't know. I suppose PMTU discovery is supposed to work almost always, except towards some hosts/networks/routes. So clamping is better done on the routes and not the interface.
Pure speculation.
When I set the mtu to 9000, I get

Code: Select all

131.246.76.0/24 dev eth0 proto kernel scope link src 131.246.76.243 metric 202  mtu 1472
after "ip route show"
Do you know why it says 1472 and not 9000?

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 3:30 pm
by trejan
MTU on the route instead of the interface is intentional. It gives you more flexibility in configuration as you may have differing MTU for your routes. The main case for that is IPv6 where a lot of people are still using tunnels which will have a much smaller MTU.

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 4:03 pm
by epoch1970
EOFFJM wrote:
Tue Jul 23, 2019 3:17 pm
Do you know why it says 1472 and not 9000?
1200, 9000?? So many possibilities
The driver for eth0 does not support jumbo frames on Pi3 (neither on Pi 4 AFAIK). I suppose this explains that.

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 5:09 pm
by EOFFJM
epoch1970 wrote:
Tue Jul 23, 2019 4:03 pm
EOFFJM wrote:
Tue Jul 23, 2019 3:17 pm
Do you know why it says 1472 and not 9000?
1200, 9000?? So many possibilities
The driver for eth0 does not support jumbo frames on Pi3 (neither on Pi 4 AFAIK). I suppose this explains that.
OK. Thanks. How do you know that driver for eth0 does not support jumbo frames on Pi3?

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 6:13 pm
by epoch1970
Because I read this forum. I don’t have any 3b+.
(Not that I would have tried activating jumbo frames on a link limited to 250mbps at best...)

Re: How to permanently change MTU

Posted: Tue Jul 23, 2019 6:49 pm
by trejan
The LAN7515 in the RPi 3B+ does support 9K jumbo frames and the lan78xx driver it uses also has support. The RPi 4 internal gigabit MAC does support jumbo frames as well but the driver doesn't.

Your problem appears to be that dhcpcd is refusing to set a higher MTU on the route than what is on the interface. In your situation, the easiest option is probably to just get rid of dhcpcd and use /etc/network/interfaces again.