Support Requests - CLICK TO READ BEFORE POSTING


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

How to persist changes to the routing table?
#1

I am running linux lite 4.6 inside virtualbox. The machine has two network interfaces. I face the issue where the machine isn't able to connect to the internet. After investigation I found the issue to be with my routing table. No idea why this routing table got persisted in the first place.

Code:
$ ip route default via 192.168.175.1 dev enp0s8 onlink 10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 192.168.175.0/24 dev enp0s8 proto kernel scope link src 192.168.175.18

After a bit of tinkering, I have a workaround. I modify the routing table as follows:

Code:
$ ip route default via 10.0.2.2 dev enp0s3 10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 10.0.2.2 via 10.0.2.15 dev enp0s3 192.168.175.0/24 dev enp0s8 proto kernel scope link src 192.168.175.18

I am not sure why the above works.

However, I have to manually issue commands to setup the routing table to the state as shown above, after every reboot.

I have tried some ways to persist using the [tt]/etc/network/interfaces[/tt] file. The below file is an attempt at that:

Code:
auto lo iface lo inet loopback auto enp0s3 iface enp0s3 inet dhcp up /sbin/ip route add 10.0.2.2 via 10.0.2.15 up /sbin/ip route add default via 10.0.2.2 auto enp0s8 iface enp0s8 inet static address 192.168.175.18 netmask 255.255.255.0 gateway 192.168.175.1 down /sbin/ip route del default # up /sbin/ip route add 10.0.2.2 via 10.0.2.15 # down /sbin/ip route del default # up /sbin/ip route add default via 10.0.2.2

But nothing worked.

Next I tried putting the commands in [tt]/etc/rc.local[/tt] that didn't work too.

What is the correct way to persist this?
Reply
#2

I am not familiar with crontab but you can setup a cronjob to start at every reboot. How to get exactly what you need is you will have to create a script then just put the script somewhere like in the /usr/scripts folder and use a sudo crontab -e to run the script with @reboot then path to your script. Just an off the wall suggestion.
Reply
#3

Sounds great. However, if there were errors in the script, how can I know what it was...?
Reply
#4

Make the script, test the script out after a reboot by using the terminal to execute it then see if it works. Always test first before blindly doing anything that is automatic. If there are errors you should see the errors and if it worked or not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)