1

I'm on a raspberry pi 4b

/home/pi# uname -r
5.4.79-v7l+

and trying to set

/sbin/ethtool -s eth0 speed 100 duplex full

The simple reason for that is because it does not work with autoneg / full speed.

Years ago I would have set that in /etc/network/interfaces but from what I googled the last hours that is depreciated. Additionally my pi would not if I do that. To my mind crontab is not a great solution; additionally I want to set eth0 as the primary connection - needed at boot. Where can put that setting ideally?

Thanks

Marc
  • 68
  • 6

3 Answers3

2

Ok, I found a solution. I did set up a service. First the script:

cat /etc/network/eth0speed.sh

#!/bin/sh
/sbin/ethtool --change eth0 advertise 0x008

Set the execution rights to ugo+x. Then the service:

etc/systemd/system# cat ethernet-settings.service

[Unit]

Description = Set ethernet speed to max 100mbps

[Service]

Type=oneshot

ExecStart=/etc/network/eth0speed.sh

[Install]

WantedBy=network-pre.target

Enable the service:

systemctl enable ethernet-settings.service
Marc
  • 68
  • 6
0

You would be better to fix the problem.

If you decide to continue try:-

sudo ethtool -s eth0 autoneg off
sudo ethtool -s eth0 speed 1000

AFAIK the setting then persists. (I once did this, and had some difficulty restoring autoneg.)

See https://raspberrypi.stackexchange.com/a/116687/8697

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Sorry, but the setting is definetly not persistent. I tried https://raspberrypi.stackexchange.com/questions/116677/force-wired-ethernet-speed-to-100-full but it does not work on a startup. – Marc Jan 01 '21 at 09:04
0

You can also add it to the crontab of root. I admit it is a hack:

@reboot sleep 15 && /sbin/ethtool -s eth0 speed 100 duplex full autoneg on
Marc
  • 68
  • 6