How to change the default MTU of a network card on Ubuntu

February 26th, 2009 by alpho2k | Print How to change the default MTU of a network card on Ubuntu

On Ubuntu 8.10, the default MTU of a network card is 1500. Normally, this causes no problem. I have an application called Elluminate which must connect to the network of Laval University with a mtu of 1480. This small tutorial will show you how to change it and also, how can that change be effective even if you restart the computer.
[ad#Widgetbucks]
Change for the session only

To check the MTU of a network card, use the command “ifconfig” as follows :

~$ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:a0:d1:a7:6d:7b
UP BROADCAST MULTICAST MTU:1500 Metric:1
Packets reçus:0 erreurs:0 :0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:1
collisions:0 lg file transmission:1000
Octets reçus:0 (0.0 B) Octets transmis:0 (0.0 B)
Interruption:216

We note that for my part, the MTU of my network card is 1500. Note that if you have a wireless card, there is good chance that the name is wlan0. To change the MTU, you must again use the ifconfig command by adding at the end, the word mtu followed by the new value you want it. Here’s an example:

sudo ifconfig eth0 mtu 1480

We can validate the change by using the ifconfig command again:

~$ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:a0:d1:a7:6d:7b
UP BROADCAST MULTICAST MTU:1480 Metric:1
Packets reçus:0 erreurs:0 :0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:2
collisions:0 lg file transmission:1000
Octets reçus:0 (0.0 B) Octets transmis:0 (0.0 B)
Interruption:216

[ad#Adsense]
Permanent change

To make this change permanent without having to redo this command after each reboot, we need to add a small script to be executed during the computer start-up when the network card become active. To do this, we must first create the script in the “/etc/network/if-up” folder.

You can use gedit, kate or your favorite text editor like this:

sudo gedit /etc/network/if-up.d/mtu

or

sudo kate /etc/network/if-up.d/mtu

Here is the code of the script:

#!/bin/sh
ifconfig eth0 mtu 1480

Again, if you want to change the mtu of your wireless card, his name is probably wlan0. It will therefore change eth0 by wlan0.

Once the script is created, it must be made executable by the system as follows:

sudo chmod 755 /etc/network/if-up.d/mtu

Now, simply reboot and the mtu should be changed!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Related Posts

  • No Related Post

 

2 Comments For This Post

  1. mattia Says:

    Hi,

    thanks for your work!

    I would like to ask what could be the cause why suddenly facebook needed a 1492 value and not that of 1500

    Thank you

    Byeee

    mattia

  2. virgoptrex Says:

    This fails for mtu >1500. Thts what many high speed applications require :)

Leave a Reply

Live Comment Preview