Default gateway changing
I am using 3 ethernet interfaces on Ubuntu but when I restart, the default gateway is changing to a different interface. Each time I boot I have to change default gateway back to the eth1 by deleting the default gateway and adding it back with eth1. How can I fix this problem?
networking routing
add a comment |
I am using 3 ethernet interfaces on Ubuntu but when I restart, the default gateway is changing to a different interface. Each time I boot I have to change default gateway back to the eth1 by deleting the default gateway and adding it back with eth1. How can I fix this problem?
networking routing
Have you configured it manually using the/etc/network/interfaces
file, or a with software like Network Manager or wicd?
– Lekensteyn
Mar 23 '11 at 12:56
1
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used.
– Lekensteyn
Jun 2 '11 at 19:24
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available.
– belacqua
Oct 29 '11 at 22:14
Can you provide your routing table and list of interface, and other any relevant network configuration you've done?
– belacqua
Oct 29 '11 at 22:17
add a comment |
I am using 3 ethernet interfaces on Ubuntu but when I restart, the default gateway is changing to a different interface. Each time I boot I have to change default gateway back to the eth1 by deleting the default gateway and adding it back with eth1. How can I fix this problem?
networking routing
I am using 3 ethernet interfaces on Ubuntu but when I restart, the default gateway is changing to a different interface. Each time I boot I have to change default gateway back to the eth1 by deleting the default gateway and adding it back with eth1. How can I fix this problem?
networking routing
networking routing
edited Oct 29 '11 at 22:16
belacqua
15.9k1473103
15.9k1473103
asked Mar 23 '11 at 12:12
BaranBaran
238148
238148
Have you configured it manually using the/etc/network/interfaces
file, or a with software like Network Manager or wicd?
– Lekensteyn
Mar 23 '11 at 12:56
1
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used.
– Lekensteyn
Jun 2 '11 at 19:24
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available.
– belacqua
Oct 29 '11 at 22:14
Can you provide your routing table and list of interface, and other any relevant network configuration you've done?
– belacqua
Oct 29 '11 at 22:17
add a comment |
Have you configured it manually using the/etc/network/interfaces
file, or a with software like Network Manager or wicd?
– Lekensteyn
Mar 23 '11 at 12:56
1
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used.
– Lekensteyn
Jun 2 '11 at 19:24
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available.
– belacqua
Oct 29 '11 at 22:14
Can you provide your routing table and list of interface, and other any relevant network configuration you've done?
– belacqua
Oct 29 '11 at 22:17
Have you configured it manually using the
/etc/network/interfaces
file, or a with software like Network Manager or wicd?– Lekensteyn
Mar 23 '11 at 12:56
Have you configured it manually using the
/etc/network/interfaces
file, or a with software like Network Manager or wicd?– Lekensteyn
Mar 23 '11 at 12:56
1
1
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used.
– Lekensteyn
Jun 2 '11 at 19:24
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used.
– Lekensteyn
Jun 2 '11 at 19:24
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available.
– belacqua
Oct 29 '11 at 22:14
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available.
– belacqua
Oct 29 '11 at 22:14
Can you provide your routing table and list of interface, and other any relevant network configuration you've done?
– belacqua
Oct 29 '11 at 22:17
Can you provide your routing table and list of interface, and other any relevant network configuration you've done?
– belacqua
Oct 29 '11 at 22:17
add a comment |
3 Answers
3
active
oldest
votes
To temporarily change the default route you can use an ip command like this:
$ sudo ip route change default via 192.168.1.1 dev eth0
If you have a static ip configuration in /etc/network/interfaces
you can add a gateway statement to make this permanent.
iface eth0 inet static
gateway 192.168.1.1
[…]
Using DHCP to configure networking you have to adjust another file instead. Add the supersede statement in /etc/dhcp/dhclient.conf
.
supersede routers 192.168.1.1;
1
Scriptable version (should be a space between the quotation marks):echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
add a comment |
Open the file /etc/network/interfaces
find desired interface and add following:
gateway 192.x.x.x
Restart network:
sudo /etc/init.d/networking restart
16
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
add a comment |
I had the same issue for my wifi interface wlp3s0
on Ubuntu 18.04. It was affecting my ability to connect to Android tethering and router outside home. The way to solve the issue for me was to comment in file /etc/dhcpcd.conf
the following:
interface wlp3s0
static ip_address=192.168.0.16/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1
to get the following
#interface wlp3s0
# static ip_address=192.168.0.16/24
# static routers=192.168.0.1
# static domain_name_servers=127.0.0.1
Then, I've disconnected from my current network and reconnected an tried route -n
or nmcli
to see changes
You can also remove the same lines when you are sure it works for you.
Because of these lines, the NetworkManager was always adding a default route with a wrong gateway, in particular when I was not on my home network.
I was getting "Destination Host Unreachable" when I was doing a ping 8.8.8.8
. Hardcoding a gateway in /etc/network/interfaces
was not a viable solution as I connect a lot to public wifis (so, never the same wifi router or gateway) and normally DHCP should work "out of the box" IMHO.
PS: I've never edited manually /etc/dhcpcd.conf
so I don't know why the file /etc/dhcpcd.conf
did contain these lines.
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f31646%2fdefault-gateway-changing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
To temporarily change the default route you can use an ip command like this:
$ sudo ip route change default via 192.168.1.1 dev eth0
If you have a static ip configuration in /etc/network/interfaces
you can add a gateway statement to make this permanent.
iface eth0 inet static
gateway 192.168.1.1
[…]
Using DHCP to configure networking you have to adjust another file instead. Add the supersede statement in /etc/dhcp/dhclient.conf
.
supersede routers 192.168.1.1;
1
Scriptable version (should be a space between the quotation marks):echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
add a comment |
To temporarily change the default route you can use an ip command like this:
$ sudo ip route change default via 192.168.1.1 dev eth0
If you have a static ip configuration in /etc/network/interfaces
you can add a gateway statement to make this permanent.
iface eth0 inet static
gateway 192.168.1.1
[…]
Using DHCP to configure networking you have to adjust another file instead. Add the supersede statement in /etc/dhcp/dhclient.conf
.
supersede routers 192.168.1.1;
1
Scriptable version (should be a space between the quotation marks):echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
add a comment |
To temporarily change the default route you can use an ip command like this:
$ sudo ip route change default via 192.168.1.1 dev eth0
If you have a static ip configuration in /etc/network/interfaces
you can add a gateway statement to make this permanent.
iface eth0 inet static
gateway 192.168.1.1
[…]
Using DHCP to configure networking you have to adjust another file instead. Add the supersede statement in /etc/dhcp/dhclient.conf
.
supersede routers 192.168.1.1;
To temporarily change the default route you can use an ip command like this:
$ sudo ip route change default via 192.168.1.1 dev eth0
If you have a static ip configuration in /etc/network/interfaces
you can add a gateway statement to make this permanent.
iface eth0 inet static
gateway 192.168.1.1
[…]
Using DHCP to configure networking you have to adjust another file instead. Add the supersede statement in /etc/dhcp/dhclient.conf
.
supersede routers 192.168.1.1;
answered Jan 10 '14 at 13:38
webwurstwebwurst
1,3201212
1,3201212
1
Scriptable version (should be a space between the quotation marks):echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
add a comment |
1
Scriptable version (should be a space between the quotation marks):echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
1
1
Scriptable version (should be a space between the quotation marks):
echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
Scriptable version (should be a space between the quotation marks):
echo supersede routers $(ip route | grep default | cut -f3 -d" "); | sudo tee --append /etc/dhcp/dhclient.conf
– colan
Jan 10 '17 at 22:15
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
What if I have multiple interfaces? Shouldn't they all have a 'gateway' for each interface? But what affects the example ''default via 192.168.3.1 dev eth6" output of ip route command? It lists a specific interface, right?
– JohnyTex
Sep 27 '18 at 9:19
add a comment |
Open the file /etc/network/interfaces
find desired interface and add following:
gateway 192.x.x.x
Restart network:
sudo /etc/init.d/networking restart
16
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
add a comment |
Open the file /etc/network/interfaces
find desired interface and add following:
gateway 192.x.x.x
Restart network:
sudo /etc/init.d/networking restart
16
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
add a comment |
Open the file /etc/network/interfaces
find desired interface and add following:
gateway 192.x.x.x
Restart network:
sudo /etc/init.d/networking restart
Open the file /etc/network/interfaces
find desired interface and add following:
gateway 192.x.x.x
Restart network:
sudo /etc/init.d/networking restart
edited Aug 19 '15 at 10:47
Myst
123310
123310
answered Mar 23 '11 at 12:30
mount.cifsmount.cifs
1,240712
1,240712
16
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
add a comment |
16
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
16
16
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign?
– devmiles.com
Aug 31 '12 at 10:40
add a comment |
I had the same issue for my wifi interface wlp3s0
on Ubuntu 18.04. It was affecting my ability to connect to Android tethering and router outside home. The way to solve the issue for me was to comment in file /etc/dhcpcd.conf
the following:
interface wlp3s0
static ip_address=192.168.0.16/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1
to get the following
#interface wlp3s0
# static ip_address=192.168.0.16/24
# static routers=192.168.0.1
# static domain_name_servers=127.0.0.1
Then, I've disconnected from my current network and reconnected an tried route -n
or nmcli
to see changes
You can also remove the same lines when you are sure it works for you.
Because of these lines, the NetworkManager was always adding a default route with a wrong gateway, in particular when I was not on my home network.
I was getting "Destination Host Unreachable" when I was doing a ping 8.8.8.8
. Hardcoding a gateway in /etc/network/interfaces
was not a viable solution as I connect a lot to public wifis (so, never the same wifi router or gateway) and normally DHCP should work "out of the box" IMHO.
PS: I've never edited manually /etc/dhcpcd.conf
so I don't know why the file /etc/dhcpcd.conf
did contain these lines.
New contributor
add a comment |
I had the same issue for my wifi interface wlp3s0
on Ubuntu 18.04. It was affecting my ability to connect to Android tethering and router outside home. The way to solve the issue for me was to comment in file /etc/dhcpcd.conf
the following:
interface wlp3s0
static ip_address=192.168.0.16/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1
to get the following
#interface wlp3s0
# static ip_address=192.168.0.16/24
# static routers=192.168.0.1
# static domain_name_servers=127.0.0.1
Then, I've disconnected from my current network and reconnected an tried route -n
or nmcli
to see changes
You can also remove the same lines when you are sure it works for you.
Because of these lines, the NetworkManager was always adding a default route with a wrong gateway, in particular when I was not on my home network.
I was getting "Destination Host Unreachable" when I was doing a ping 8.8.8.8
. Hardcoding a gateway in /etc/network/interfaces
was not a viable solution as I connect a lot to public wifis (so, never the same wifi router or gateway) and normally DHCP should work "out of the box" IMHO.
PS: I've never edited manually /etc/dhcpcd.conf
so I don't know why the file /etc/dhcpcd.conf
did contain these lines.
New contributor
add a comment |
I had the same issue for my wifi interface wlp3s0
on Ubuntu 18.04. It was affecting my ability to connect to Android tethering and router outside home. The way to solve the issue for me was to comment in file /etc/dhcpcd.conf
the following:
interface wlp3s0
static ip_address=192.168.0.16/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1
to get the following
#interface wlp3s0
# static ip_address=192.168.0.16/24
# static routers=192.168.0.1
# static domain_name_servers=127.0.0.1
Then, I've disconnected from my current network and reconnected an tried route -n
or nmcli
to see changes
You can also remove the same lines when you are sure it works for you.
Because of these lines, the NetworkManager was always adding a default route with a wrong gateway, in particular when I was not on my home network.
I was getting "Destination Host Unreachable" when I was doing a ping 8.8.8.8
. Hardcoding a gateway in /etc/network/interfaces
was not a viable solution as I connect a lot to public wifis (so, never the same wifi router or gateway) and normally DHCP should work "out of the box" IMHO.
PS: I've never edited manually /etc/dhcpcd.conf
so I don't know why the file /etc/dhcpcd.conf
did contain these lines.
New contributor
I had the same issue for my wifi interface wlp3s0
on Ubuntu 18.04. It was affecting my ability to connect to Android tethering and router outside home. The way to solve the issue for me was to comment in file /etc/dhcpcd.conf
the following:
interface wlp3s0
static ip_address=192.168.0.16/24
static routers=192.168.0.1
static domain_name_servers=127.0.0.1
to get the following
#interface wlp3s0
# static ip_address=192.168.0.16/24
# static routers=192.168.0.1
# static domain_name_servers=127.0.0.1
Then, I've disconnected from my current network and reconnected an tried route -n
or nmcli
to see changes
You can also remove the same lines when you are sure it works for you.
Because of these lines, the NetworkManager was always adding a default route with a wrong gateway, in particular when I was not on my home network.
I was getting "Destination Host Unreachable" when I was doing a ping 8.8.8.8
. Hardcoding a gateway in /etc/network/interfaces
was not a viable solution as I connect a lot to public wifis (so, never the same wifi router or gateway) and normally DHCP should work "out of the box" IMHO.
PS: I've never edited manually /etc/dhcpcd.conf
so I don't know why the file /etc/dhcpcd.conf
did contain these lines.
New contributor
edited 3 hours ago
New contributor
answered 3 hours ago
ThomasG77ThomasG77
1013
1013
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f31646%2fdefault-gateway-changing%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
Have you configured it manually using the
/etc/network/interfaces
file, or a with software like Network Manager or wicd?– Lekensteyn
Mar 23 '11 at 12:56
1
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used.
– Lekensteyn
Jun 2 '11 at 19:24
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available.
– belacqua
Oct 29 '11 at 22:14
Can you provide your routing table and list of interface, and other any relevant network configuration you've done?
– belacqua
Oct 29 '11 at 22:17