TransWikia.com

Permanent IP Routing on rPi

Raspberry Pi Asked by Fenderbridge on October 5, 2021

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 192.168.10.0/24 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!

One Answer

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

@reboot ip route add 192.168.10.0/24 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.

Answered by Ljm Dullaart on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP