Permanently change MTU

Kernels & Hardware, configuring network, installing services

Permanently change MTU

Postby HarborView » 2020-03-17 21:15

I experimented with ping and found an ideal MTU size to use with my ISP. I have to run this code fragment each time I boot up:

Code: Select all
ifconfig $WIFI  mtu $MTU

That's in a Bash program with variables for my wifi adapter and MTU in it.

But this has to run as root so I have to open a terminal window and so sudo su. I searched the web and found only misinformation as to where in Debian (still using #9 Stretch for a while) does the Network Manager get its sizes.
Posts: 41
Joined: 2014-02-01 02:21
Location: The Space Coast of the USA

Re: Permanently change MTU

Postby shep » 2020-03-17 22:16

This, in part, depends on how your are managing your interface.

For a basic CLI interface in /etc/network/interfaces:

If you are using Network Manger, Wicd or Connman you may be able to specify MTU in a pre-up command.
Posts: 381
Joined: 2011-03-15 15:22

Re: Permanently change MTU

Postby Head_on_a_Stick » 2020-03-18 18:55

Or add the command to /etc/rc.local, that should work for all network management solutions.

But ifconfig(8) is buggy and obsolete so use this instead:
Code: Select all
/sbin/ip link set $interface mtu $value

Replace $interface with the name of your wireless interface and replace $value with the desired MTU size.

The ip(8) command can be found in the iproute2 package.
User avatar
Posts: 11992
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Permanently change MTU

Postby Deb-fan » 2020-03-19 03:37

Like using a systemd service unit for what rc.local was formerly used for and/or an @reboot crontab for root user worked well too. Doesn't overly matter as rc.local still works fine anyway, only that when terms like deprecated/backwards compatibility are being used seems a good time to explore that topic, see what's advised as newer/cleaner practice.

Wonder if you/others have seen noteable improvement in networking having done this kind of adjustments on common network scenarios? More solid/speedier connections? Been meaning to dork with such minutiae as it shouldn't take all that much effort to test/apply. People do bother and benefit from this? :)
Posts: 708
Joined: 2012-08-14 12:27

Re: Permanently change MTU

Postby trinidad » 2020-03-19 12:45

You can also use the nmcli modify tool. For example as below:

Code: Select all
nmcli c modify "my connection name" ethernet.mtu 1600

And then bring the connection back up afterwards:

Code: Select all
nmcli con up con-name

You can't believe your eyes if your imagination is out of focus.
Posts: 129
Joined: 2016-08-04 14:58

Return to System configuration

Who is online

Users browsing this forum: No registered users and 11 guests