Skip to content
Advertisement

Making changes with ifconfig persistent [closed]

can anyone tell me on how to make the following commandline changes persistent? (Like via /etc/network/interfaces or /etc/dhcpcd.conf)

route del default
ifconfig eth0 add 172.25.1.1 netmask 255.240.0.0
ifconfig eth0:0 netmask 255.240.0.0
route del default
route add default gw 172.25.0.1

I need to make these changes to make this RPI use a Router as a default gateway a room next to ours. For more info: We don’t have direct access to this Router, as in we can’t make any changes to it by ourselves.

Am thankful for any insightful responses.

Advertisement

Answer

To make the route permanent, you need to create a static route configuration file. Create a file with the name route-interface in /etc/sysconfig/network-scripts directory, such as /etc/sysconfig/network-scripts/route-eth0

Then, add the same line you would with ip route add:

172.16.5.0/24 via 10.0.0.101 dev eth0

Make sure to restart your network settings so they take effect:

# service network restart
Advertisement