Ubuntu Network Speed and full or half duplex LAN

Written by
Date: 2013-05-09 11:11:11 00:00

If you need to change your Networks settings in Ubuntu from half duplex to full duplex or the other way, or if you need to change the speed of the port from 10, 100 or 1000 Mbps to any of the other options. Then, here is how to.

Install the tools

sudo apt-get install ethtool net-tools

Check the names of your interfaces

cat /proc/net/dev | awk '{print $1}'

That will list all available interfaces, but you will not know which one you are using, so maybe is better to use.

ip addr

Check the one with the ip address you are using, if your PC is not connected you will have to try to guess. In my case the first card is named em1

Check the supported speeds and modes of your interface

You need to be sure that the mode and speed you want to assign to your interface is supported.

sudo ethtool em1

The output in my case is:

Supported ports: [ TP ]
Supported link modes:   10baseT/Half 10baseT/Full 
                        100baseT/Half 100baseT/Full 
                        1000baseT/Full 
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full 
                        100baseT/Half 100baseT/Full 
                        1000baseT/Full 
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 2
Transceiver: internal
Auto-negotiation: on
MDI-X: off
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
		       drv probe link
Link detected: yes

You can see that my hardware supports, 10baseT and 100baseT in half and full duplex, but 1000baseT only in Full duplex.

Set the desired mode

sudo ethtool -s em1 autoneg off speed 100 duplex full

That will set the interface em1 to stop auto negotiating and the speed at 100baseT and to full duplex mode.

Making changes permanent

If you need to have this settings every time you boot up the PC, you have to add a command in the /etc/network/interfaces file, so:

sudo vim /etc/network/interfaces

And at the beginning of the file add:

pre-up /usr/sbin/ethtool -s em1 autoneg off 100 duplex full

That will set the parameters before bringing the interface up.