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

1
  • Add that as a line at the bottom of /etc/rc.local (just before exit 0).
    – Dougie
    Jan 1, 2021 at 1:00

3 Answers 3

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
3
  • 2
    No need to have an extra bash script. ExecStart=/usr/bin/bash/ -c '/sbin/ethtool --change eth0 advertise 0x008' will also do.
    – Ingo
    Jan 1, 2021 at 14:58
  • 1
    @Ingo The forward slash after /usr/bin/bash shouldn't be there.
    – alwaysask
    Jan 12, 2021 at 16:55
  • @alwaysask You are right, that's a typo.
    – Ingo
    Jan 12, 2021 at 19:51
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

1
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

Your Answer

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

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