4

It so happens that I have a NIC that is only able to establish a connection with the current network when auto negotiation is set to false. In windows, this can be achieved rather easily by changing the NIC properties via Device Manager. Currently I am only able to do so in Ubuntu (10.04 if that matters) via the following after login:

sudo ethtool -s eth0 autoneg off speed 100 duplex full

sudo service network-manager restart

PS: I have read reports from ubuntu forums that it may be necessary to remove network-manager and only use /etc/network/interfaces for configuration, but I intend to do so only as a last resort. I would also appreciate it if someone can add auto-negotiation ethtool to the list of tags.

prusswan
  • 1,049

5 Answers5

5

There seems to be no way to do it within Network Manager. Editing /etc/network/interfaces on the other hand is clumsy and causes delays in later editions of Ubuntu like 12.04 (see this and this). In the end the solution offered here turns out to be best (for now), by adding the ethtool command to rc.local:

sudo -H gedit /etc/rc.local

ethtool -s eth0 autoneg off speed 100 duplex full    # put this above 'exit 0'
Zanna
  • 72,312
prusswan
  • 1,049
4

If someone else ends up with this problem of trying to configure network interfaces in 18.04, It turned out network manager was setting auto-negotiate to off for me, so on reboot nothing seemed to be working; ifupdown (deprecated), netplan, probably some other option because we can't pick a technology.

Use

nmcli c show "Wired connection 1"

To display current settings. Use nmcli c edit "Wired connection 1" to interactively set values (traverse the settings hierarchy with goto and back, change and set for values. There's built-in help):

goto 802-3-ethernet.auto-negotiate
change
save persistent
quit
Elder Geek
  • 36,752
2

I've had better results putting ethtool scripts in /etc/network/if-up.d. According to Network Manager documentation, scripts in /etc/NetworkManager/dispatcher.d will be run after NM 'fiddles with interfaces'. On my 12.04 system, the only script is 01ifupdown, which will then run scripts in /etc/network/if-up.d (also /etc/network/if-post-down.d).

This sequence of events seems to happen well after the login screen appears on my system.

I've found many occurrences of the following line in the system log which may explain what is causing the delay:

NetworkManager[871]: <info> (eth0): carrier now OFF (device state 100, deferring action  for 4 seconds).

Do not forget to put interpreter description (#!/bin/sh) as the first line of your script. Otherwise it will not work as NetworkManager uses the run-parts utility to run them. They also need to be owned by root and have write permission only for their owner.

Zanna
  • 72,312
Jeff M.
  • 21
2

As Jeff M hinted, you can do this with NetworkManager and I've had pretty good luck doing it that way.

Create a file in /etc/NetworkManager/dispatcher.d/ named 50-ethtool-autoneg-off and put the following contents in it. Note you can change eth0 to eth* if you want to disable for any eth device, you could also add eth*|en* if you have a system using the newer "predictable kernel names".

#!/bin/sh
myname=${0##*/}
log() { logger -p user.info -t "${myname}[$$]" "$*"; }
IFACE=$1
ACTION=$2

case ${IFACE} in
    eth0)
        case ${ACTION} in
            up)
                log "Disabling auto-negotation on $IFACE"
                ethtool -s $IFACE autoneg off speed 100 duplex full
                ;;
        esac
        ;;
esac

You do need a shebang #!/bin/sh or #!/bin/bash from the examples I've seen, and the permissions he mentioned are definitely important. It should be at least read/execute for root, and writable makes it easier to update without having to change permissions or force your editor to save.

sudo chmod 0744 /etc/NetworkManager/dispatcher.d/50-ethtool-autoneg-off

If you have any issues with this let me know and I'll do some experimenting, but I'm currently using a similar method to change an interface from speed 1000 to speed 100 due to instability at the default speed.

dragon788
  • 1,716
0

All the other answers should work, but I add here what I consider to be the "clean" solution for my case (Debian without graphical interface).

Edit the /etc/network/interfaces.d/eth0 file (check with ip link show if your interface is named eth0 or something like enp0s25) adding this line at its bottom (with the same indentation as the previous lines):

 up sleep 5; ethtool -s eth0 speed 100 duplex full autoneg off

Also here, correct the interface name if it is not eth0.

If you are using a static IPv4 configuration and your interface is named eth0, the file would look something like this:

auto eth0
iface eth0  inet static
 address 10.29.0.15
 netmask 255.255.252.0
 gateway 10.29.0.1
 dns-domain ciao.ciao
 dns-nameservers 10.4.1.10 10.4.1.20
 up sleep 5; ethtool -s eth0 speed 100 duplex full autoneg off

Solution taken from: https://wiki.debian.org/NetworkConfiguration#Setting_the_speed_and_duplex