0

I have a raspberry pi 4 and need to restrict the ethernet interface speed to 100BaseT. Both ends of the ethernet link are advertising 1000BaseT. However, my "legacy" wiring only has two pairs of the cable wired and is therefore restricted to 100BaseT. 1000BaseT requires 4pairs of the Cat5/6 cable, 100BaseT only needs 2 pairs.

I know I can use

`ethtool --change eth0 advertise 0x008`

from the command line however, this does not persist across restarts.

How do I configure the link speed at reboot when using dchpcd?

5
  • Run sudo ethtool -s eth0 speed 100 after boot using any of the usual methods.
    – Milliways
    Commented May 13, 2023 at 22:39
  • As mentioned I know I can do it manually after the system has booted. The idea is to get my headless system on the network at boot time.
    – ferg
    Commented May 14, 2023 at 15:20
  • Just use any of the usual methods. A systemd service would be best (but requires some expertise) cron would probably work.
    – Milliways
    Commented May 14, 2023 at 22:07
  • Have you tried? The ports should negotiate the correct speed for your cable Commented May 25, 2023 at 22:02
  • Sorted, see below.
    – ferg
    Commented May 26, 2023 at 21:40

1 Answer 1

0

I need to ensure one of the following is run when my Raspberry Pi 4 is rebooted.

/usr/sbin/ethtool --change eth0 advertise 0x008
/usr/sbin/ethtool –-change eth0 speed 100 duplex full autoneg off

I have four situations I wish the PI to handle.

1 - Connected with 4pairs direct to a ubiqity edgemaster POE port
2 - Connected with 4pairs direct to a apple airport extreme
3 - Connected with 2pairs via a ls-poe-b0525 POE spliter to a ubiqity edgemaster POE port
4 - Connected with 2pairs direct to a ubiqity edgemaster port

This should be trivial, but dealing with the current obstacle course of networking utilities made it difficult. The system is apparently using dhcpcd for most networking config, but dhcpcd only seems to cater for basic cases. It is confusing in that all the ifconfip, ip and NetworkManager systems are also in place.

So starting with a new-ish image

  • reference 2023-02-21
  • wifi configured as well but switched off
  • updated and upgraded to the latest
  • boots to CLI

After hours of messing around, I discovered that adding the following to the end of /etc/network/if-pre-up.d/ethtool solved the problem.

sleep 10
/usr/sbin/ethtool --change eth0 advertise 0x008

Adding the same two lines to /etc/rc.local also worked.

The key element in this solution is the sleep command. Without the sleep, ethtool appears to do its thing too soon and has no effect. I am not sure what is causing ethtool to fail without the sleeps. I suspect the half-wired cabling is causing something to retry and take longer to initialise. Even with sleeps I suspect your mileage may vary depending on boot media speed, remote hub, DHCP server response, etc. However, initially setting sleep to 60secs should cater for the worst case. Once working you can reduce the sleep time in steps till you are happy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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