I am using a BeagleBone embedded computer running Debian.

I have two network interfaces :

1) A connection to a cellular modem over USB which uses ppp and connects to the outside world. It receives a dynamic IP address from the ISP

2) An ethernet interface which is connected only to another local device. I have assigned a static IP address to this interface by putting this command in rc.local ifconfig eth0 netmask

Only when the two interfaces are active, there is a problem to connect out through the modem. I realised that to solve this I have to set the default gateway to the address that the modem gets by running a script with my below commands.

IPADD=$(/sbin/ifconfig ppp0 | grep 'inet' | cut -d: -f2 | awk '{ print $2}')
route add default gw $IPADD

This works great when I manually execute my script after login. I can then communicate out through the two interfaces.

However, I am not able whatsoever to get this script to execute on boot-up properly and assign the the default gateway address automatically this way.

I have tried everything, by running it from rc.local, putting the script in /etc/rc5.d or /etc/rc3.d, running it from /root/.bashrc or /user/.bashrc. Using crontab, trying to sleep 1 minute before running the script, running it in a loop. Nothing works.

It seems after I login, the default gateway gets overwritten somehow from having the ethernet interface.

Does anyone have any idea how to solve this? I need this default gateway address to be assigned on boot-up automatically. I've been trying for days now.

If I don't have the ethernet cable plugged in , or I put the ethernet interface down, there are no problems at all. Only with the two interfaces active I have this problem. Thanks

  • How have you configured your static address on the ethernet interface? Please edit your question with relevant configuration files or snippets. – user4556274 Feb 4 '19 at 13:21
  • @user4556274 I've configured it in rc.local. I've edited the question – Engineer999 Feb 4 '19 at 13:26
  • Do you also have NetworkManager running? Run systemctl status NetworkManager to find out. If you do your network configuration in /etc/rc.local, what's in /etc/network/interfaces, the "classic" default network configuration file for Debian? If it includes a default DHCP setting for the ethernet interface, the DHCP client might be the one wiping out your default gateway settings. If you don't want to use /etc/network/interfaces, make it empty or comment out all lines in it. – telcoM Feb 4 '19 at 13:39
  • @telcoM I have nothing inside /etc/network/interfaces. This was causing problems for me at first, because the ppp0 interface was never showing up if i set the ethernet interface in there. I therefore decided to use rc.local instead to set up the ethernet IP address after the ppp0 interface, because ppp is set up using a systemd service. As far as I know there is no DHCP client for the ethernet interface that can be causing this. – Engineer999 Feb 4 '19 at 13:45
  • If the ppp configuration includes the defaultroute keyword then it should set the default route automatically when the ppp link is established. – wurtel Feb 4 '19 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.