Many issues setting the default gateway on boot-up
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am using a BeagleBone embedded computer running Debian.
I have two network interfaces :
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
An ethernet interface which is connected only to another local device. I have assigned the static IP address 192.168.1.40 to this interface. I set this inside rc.local with command
ifconfig eth0 192.168.1.40 netmask 255.255.255.0
Only when the two interfaces are active, there is a problem to connect out through the modem. I realized 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.
#!/bin/sh
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.
linux networking ethernet network-interface ppp
|
show 1 more comment
I am using a BeagleBone embedded computer running Debian.
I have two network interfaces :
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
An ethernet interface which is connected only to another local device. I have assigned the static IP address 192.168.1.40 to this interface. I set this inside rc.local with command
ifconfig eth0 192.168.1.40 netmask 255.255.255.0
Only when the two interfaces are active, there is a problem to connect out through the modem. I realized 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.
#!/bin/sh
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.
linux networking ethernet network-interface ppp
Which version of Debian are you using? What network management software do you have installed and running after you login (including ifupdown, NetworkManager, networkd, DHCP clients)? Have you tried adding the default route as a device route via ppp0 without a gateway address? (It's a point-to-point device anyway.)
– grawity
Feb 4 at 13:23
@grawity It's the latest version of Debian for the BeagleBone. I'm not sure about the network management software. How would I add the default route as a device route via ppp0 without a gw address? I'm not sure I understand
– Engineer999
Feb 4 at 13:30
If the external interface is always the same you could check whenever you can use the interface name rather than the IP for the route.
– Seth
Feb 4 at 13:35
1
Using iproute2,ip route add default via $IPADD
is the regular version with a gateway,ip route add default dev ppp0
is the device-only version. Simplifies your script a bit. (Point-to-point interfaces don't have a MAC layer, so the gateway address isn't actually used for anything anyway.)
– grawity
Feb 4 at 13:43
1
@grawity There are errors when I use those commands. "RTNETLINK answers : File exists" . It only works when I use "route add default gw $IPADD"
– Engineer999
Feb 4 at 15:40
|
show 1 more comment
I am using a BeagleBone embedded computer running Debian.
I have two network interfaces :
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
An ethernet interface which is connected only to another local device. I have assigned the static IP address 192.168.1.40 to this interface. I set this inside rc.local with command
ifconfig eth0 192.168.1.40 netmask 255.255.255.0
Only when the two interfaces are active, there is a problem to connect out through the modem. I realized 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.
#!/bin/sh
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.
linux networking ethernet network-interface ppp
I am using a BeagleBone embedded computer running Debian.
I have two network interfaces :
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
An ethernet interface which is connected only to another local device. I have assigned the static IP address 192.168.1.40 to this interface. I set this inside rc.local with command
ifconfig eth0 192.168.1.40 netmask 255.255.255.0
Only when the two interfaces are active, there is a problem to connect out through the modem. I realized 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.
#!/bin/sh
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.
linux networking ethernet network-interface ppp
linux networking ethernet network-interface ppp
edited Feb 4 at 13:36
Engineer999
asked Feb 4 at 13:11
Engineer999Engineer999
1065
1065
Which version of Debian are you using? What network management software do you have installed and running after you login (including ifupdown, NetworkManager, networkd, DHCP clients)? Have you tried adding the default route as a device route via ppp0 without a gateway address? (It's a point-to-point device anyway.)
– grawity
Feb 4 at 13:23
@grawity It's the latest version of Debian for the BeagleBone. I'm not sure about the network management software. How would I add the default route as a device route via ppp0 without a gw address? I'm not sure I understand
– Engineer999
Feb 4 at 13:30
If the external interface is always the same you could check whenever you can use the interface name rather than the IP for the route.
– Seth
Feb 4 at 13:35
1
Using iproute2,ip route add default via $IPADD
is the regular version with a gateway,ip route add default dev ppp0
is the device-only version. Simplifies your script a bit. (Point-to-point interfaces don't have a MAC layer, so the gateway address isn't actually used for anything anyway.)
– grawity
Feb 4 at 13:43
1
@grawity There are errors when I use those commands. "RTNETLINK answers : File exists" . It only works when I use "route add default gw $IPADD"
– Engineer999
Feb 4 at 15:40
|
show 1 more comment
Which version of Debian are you using? What network management software do you have installed and running after you login (including ifupdown, NetworkManager, networkd, DHCP clients)? Have you tried adding the default route as a device route via ppp0 without a gateway address? (It's a point-to-point device anyway.)
– grawity
Feb 4 at 13:23
@grawity It's the latest version of Debian for the BeagleBone. I'm not sure about the network management software. How would I add the default route as a device route via ppp0 without a gw address? I'm not sure I understand
– Engineer999
Feb 4 at 13:30
If the external interface is always the same you could check whenever you can use the interface name rather than the IP for the route.
– Seth
Feb 4 at 13:35
1
Using iproute2,ip route add default via $IPADD
is the regular version with a gateway,ip route add default dev ppp0
is the device-only version. Simplifies your script a bit. (Point-to-point interfaces don't have a MAC layer, so the gateway address isn't actually used for anything anyway.)
– grawity
Feb 4 at 13:43
1
@grawity There are errors when I use those commands. "RTNETLINK answers : File exists" . It only works when I use "route add default gw $IPADD"
– Engineer999
Feb 4 at 15:40
Which version of Debian are you using? What network management software do you have installed and running after you login (including ifupdown, NetworkManager, networkd, DHCP clients)? Have you tried adding the default route as a device route via ppp0 without a gateway address? (It's a point-to-point device anyway.)
– grawity
Feb 4 at 13:23
Which version of Debian are you using? What network management software do you have installed and running after you login (including ifupdown, NetworkManager, networkd, DHCP clients)? Have you tried adding the default route as a device route via ppp0 without a gateway address? (It's a point-to-point device anyway.)
– grawity
Feb 4 at 13:23
@grawity It's the latest version of Debian for the BeagleBone. I'm not sure about the network management software. How would I add the default route as a device route via ppp0 without a gw address? I'm not sure I understand
– Engineer999
Feb 4 at 13:30
@grawity It's the latest version of Debian for the BeagleBone. I'm not sure about the network management software. How would I add the default route as a device route via ppp0 without a gw address? I'm not sure I understand
– Engineer999
Feb 4 at 13:30
If the external interface is always the same you could check whenever you can use the interface name rather than the IP for the route.
– Seth
Feb 4 at 13:35
If the external interface is always the same you could check whenever you can use the interface name rather than the IP for the route.
– Seth
Feb 4 at 13:35
1
1
Using iproute2,
ip route add default via $IPADD
is the regular version with a gateway, ip route add default dev ppp0
is the device-only version. Simplifies your script a bit. (Point-to-point interfaces don't have a MAC layer, so the gateway address isn't actually used for anything anyway.)– grawity
Feb 4 at 13:43
Using iproute2,
ip route add default via $IPADD
is the regular version with a gateway, ip route add default dev ppp0
is the device-only version. Simplifies your script a bit. (Point-to-point interfaces don't have a MAC layer, so the gateway address isn't actually used for anything anyway.)– grawity
Feb 4 at 13:43
1
1
@grawity There are errors when I use those commands. "RTNETLINK answers : File exists" . It only works when I use "route add default gw $IPADD"
– Engineer999
Feb 4 at 15:40
@grawity There are errors when I use those commands. "RTNETLINK answers : File exists" . It only works when I use "route add default gw $IPADD"
– Engineer999
Feb 4 at 15:40
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1401851%2fmany-issues-setting-the-default-gateway-on-boot-up%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1401851%2fmany-issues-setting-the-default-gateway-on-boot-up%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Which version of Debian are you using? What network management software do you have installed and running after you login (including ifupdown, NetworkManager, networkd, DHCP clients)? Have you tried adding the default route as a device route via ppp0 without a gateway address? (It's a point-to-point device anyway.)
– grawity
Feb 4 at 13:23
@grawity It's the latest version of Debian for the BeagleBone. I'm not sure about the network management software. How would I add the default route as a device route via ppp0 without a gw address? I'm not sure I understand
– Engineer999
Feb 4 at 13:30
If the external interface is always the same you could check whenever you can use the interface name rather than the IP for the route.
– Seth
Feb 4 at 13:35
1
Using iproute2,
ip route add default via $IPADD
is the regular version with a gateway,ip route add default dev ppp0
is the device-only version. Simplifies your script a bit. (Point-to-point interfaces don't have a MAC layer, so the gateway address isn't actually used for anything anyway.)– grawity
Feb 4 at 13:43
1
@grawity There are errors when I use those commands. "RTNETLINK answers : File exists" . It only works when I use "route add default gw $IPADD"
– Engineer999
Feb 4 at 15:40