🌑

Linhost.info

Change NIC setting in Linux

If you ever find your self in need of changing or setting different parameters on a network interface then you need to install Ethtool. Basically you can set the duplex on a network interface and link speed among many other things. Do not dismiss Ethtool, I have found it to be useful for configuring Linux devices that need to be linked to legacy networking devices or some network related funkiness that results in auto-negotiation not working. In order to use Ethtool you need to have root. Ethtool man page

Basic use

Ethtool can output detailed information about the NIC. Here you can see all the supported link modes and current settings.

ethtool eth0

Output.

Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes

Tip

To display the available options use.

ethtool -h

Ethtool is by no means limited, but this are some of the common options I use.

  • full speed 10 | 100 | 1000
  • duplex half | full
  • autoneg on | off

Working examples

Some networking devices have a difficult time auto-negotiating with other network devices, mostly legacy devices that only support half duplex like hubs. On this example eth0 is configured to work at half duplex and turn auto-negotiation off.

ethtool -s eth0 duplex half autoneg off

In this example the interface is force to work at full duplex, turn auto-negotiation off and set the speed to 1000 Mb/s.

ethtool -s eth0 duplex full speed 1000 autoneg off

Ethtool is by no means difficult to use, it’s mostly about matching the desired settings. I recommend you click the link located at the top of the article to to learn more about Ethtool.

, — Jan 29, 2009