I need to be able to ping my rPi through eth0, but it is connected to wifi via wlan0. Turns out, it receives the ping on eth0, and replies through wlan0.

I have a rPi b+ 3, latest updates. Running sudo ip route add dev eth0 works for my applications up until I reboot, then it disappears from ip route. Trying to add to crontab didn't work for me, I presume because it is a sudo command.

Is there a better method? Is it possible to have this command run every time at startup? Is there another file that runs at startup as the Pi user, so I can edit it and add the above line?

Thank you very much in advance!


Don't know what you did in your crontab, but

@reboot ip route add dev eth0

in the crontab for root should work. It doesn't seem useful to use the crontab for the user pi and then try to sudo, when you can just put it in root's crontab.

Alternatives are to add the line to rc.local, which sounds easy, but systemd will probably remove that compatibility in the future.

So creating a systemd unit file is the other viable solution.

  • 1
    Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it. – Ingo Jun 20 '20 at 16:56
  • I did add that line in root crontab, and it didn't run, presumably because it has to have sudo in front of it, adding sudo doesn't make it work either.. To get by, I just added a global variable and run it every time I start up. – Fenderbridge Jun 22 '20 at 15:07

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.