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.

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'
  • 1
    This works, but only on-boot. If you suspend/resume your machine, rc.local is not executed and you're back to unmodified network settings... – isync Jan 18 at 14:08
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.

  • 1
    You're right, scripts in if-up are run after NM is done ''fiddling with interfaces'. And that's the problem. On my system, the autoneg setting was preventing the network from connecting. NM was doing all sorts of avahi, dns, etc. but never reached a "I'm done fiddling" state, thus never executing scripts in if-up! -- Even more annoying, I've read in script execution related bug reports that the pre-up hook has been silently removed. Thus, for me, actually the only solution was to use the rc.local approach. – isync Jan 9 '18 at 19:06
2

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
  • You probaly upgraded from a previous release..I read somewhere that netplan is now the new default for fresh 18.04 installs. kinda sad that this old issue has never been properly resolved over five fucking LTS releases #opensourcepr0blems – prusswan Oct 1 '18 at 13:49
  • It was a new install. So seeing it written that netplan was the new way just added another wrench since network manager was still fudging things up. – sidewinder12s Oct 1 '18 at 23:57
  • Dunno why, but nmcli doesn't actually set settings for me. Using the interactive editor (subcommand 'edit'), for example, a save persistent followed by quit results in a "you've got unsaved changes" warning. Quitting with saved is not posibble, under user and sudo. Graphical nm-connection-editor does the trick, BUT does not expose the auto-negotiate flag, and in my case set it to 'no' silently. – isync Jan 18 at 14:13
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.