How to change default interface for internet?
up vote
0
down vote
favorite
I have a PC with Ubuntu server 18.04 installed on it and I'm trying to use this PC as a server. There are 2 interfaces involved here:
To provide Its internet, I am using an android smartphone that has access to internet via its Data and it will be sharing internet with my PC (server) via USB Tethering. This will create an interface called ' enp0s29f7u8 '. This interface will get an IP automatically (DHCP?), mostly '192.168.42.249'.
There is another interface called ' enp2s0 ' which is a Huawei internet modem and it's connected to my PC with a LAN cable. This ' enp2s0 ' will serve as an Access-Point so I can SSH to my PC While I'm close. I installed ' ifupdown ' on server so I can assign an Static IP to my Access-Point, namely '192.168.1.10'.
$ cat /etc/network/interfaces
auto enp2s0
iface enp2s0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
Here is the problem: I cannot access internet with this setups. It's like Ubuntu is trying to connect to Internet via 'enp2s0', which is only an AP with no access to internet.
So i tried
sudo ifconfig enp2s0 down
and there it is, i have internet. Also, when I do
sudo ifconfig enp2s0 up
after that, i still have access to internet.
How can I config my PC so that it will always use 'enp0s29f7u8' to access internet and use 'enp2s0' only as an AP?
PS:
I really don't understand network stuff. I tried changing default gateway (I don't know why) but it didn't helped(at least the way i did).
I'm not a native English speaker. Hope that I could talk my mind.
networking server routing
New contributor
|
show 5 more comments
up vote
0
down vote
favorite
I have a PC with Ubuntu server 18.04 installed on it and I'm trying to use this PC as a server. There are 2 interfaces involved here:
To provide Its internet, I am using an android smartphone that has access to internet via its Data and it will be sharing internet with my PC (server) via USB Tethering. This will create an interface called ' enp0s29f7u8 '. This interface will get an IP automatically (DHCP?), mostly '192.168.42.249'.
There is another interface called ' enp2s0 ' which is a Huawei internet modem and it's connected to my PC with a LAN cable. This ' enp2s0 ' will serve as an Access-Point so I can SSH to my PC While I'm close. I installed ' ifupdown ' on server so I can assign an Static IP to my Access-Point, namely '192.168.1.10'.
$ cat /etc/network/interfaces
auto enp2s0
iface enp2s0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
Here is the problem: I cannot access internet with this setups. It's like Ubuntu is trying to connect to Internet via 'enp2s0', which is only an AP with no access to internet.
So i tried
sudo ifconfig enp2s0 down
and there it is, i have internet. Also, when I do
sudo ifconfig enp2s0 up
after that, i still have access to internet.
How can I config my PC so that it will always use 'enp0s29f7u8' to access internet and use 'enp2s0' only as an AP?
PS:
I really don't understand network stuff. I tried changing default gateway (I don't know why) but it didn't helped(at least the way i did).
I'm not a native English speaker. Hope that I could talk my mind.
networking server routing
New contributor
Possible duplicate of Set specific interface for internet access ?
– singrium
Nov 23 at 10:52
1
@singrium that is my question exactly. But the answer doesn't fit my situation since my PC doesn't have any desktop environment. Also I tried changing default gateway withroute add change default gw 192.168.42.1
but it didn't work
– ali
Nov 23 at 10:53
Runip route
to see which is your default gateway, then runsudo route delete default gw <IP Address> <Adapter>
. After that, runsudo route add default gw <IP Address> <Adapter>
. Ifroute
is not installed, runsudo apt install net-tools
to install it
– singrium
Nov 23 at 11:03
I will try it. thanks.
– ali
Nov 23 at 11:06
So what is theenp2s0
interface supposed to be use for?
– George Udosen
Nov 23 at 11:11
|
show 5 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a PC with Ubuntu server 18.04 installed on it and I'm trying to use this PC as a server. There are 2 interfaces involved here:
To provide Its internet, I am using an android smartphone that has access to internet via its Data and it will be sharing internet with my PC (server) via USB Tethering. This will create an interface called ' enp0s29f7u8 '. This interface will get an IP automatically (DHCP?), mostly '192.168.42.249'.
There is another interface called ' enp2s0 ' which is a Huawei internet modem and it's connected to my PC with a LAN cable. This ' enp2s0 ' will serve as an Access-Point so I can SSH to my PC While I'm close. I installed ' ifupdown ' on server so I can assign an Static IP to my Access-Point, namely '192.168.1.10'.
$ cat /etc/network/interfaces
auto enp2s0
iface enp2s0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
Here is the problem: I cannot access internet with this setups. It's like Ubuntu is trying to connect to Internet via 'enp2s0', which is only an AP with no access to internet.
So i tried
sudo ifconfig enp2s0 down
and there it is, i have internet. Also, when I do
sudo ifconfig enp2s0 up
after that, i still have access to internet.
How can I config my PC so that it will always use 'enp0s29f7u8' to access internet and use 'enp2s0' only as an AP?
PS:
I really don't understand network stuff. I tried changing default gateway (I don't know why) but it didn't helped(at least the way i did).
I'm not a native English speaker. Hope that I could talk my mind.
networking server routing
New contributor
I have a PC with Ubuntu server 18.04 installed on it and I'm trying to use this PC as a server. There are 2 interfaces involved here:
To provide Its internet, I am using an android smartphone that has access to internet via its Data and it will be sharing internet with my PC (server) via USB Tethering. This will create an interface called ' enp0s29f7u8 '. This interface will get an IP automatically (DHCP?), mostly '192.168.42.249'.
There is another interface called ' enp2s0 ' which is a Huawei internet modem and it's connected to my PC with a LAN cable. This ' enp2s0 ' will serve as an Access-Point so I can SSH to my PC While I'm close. I installed ' ifupdown ' on server so I can assign an Static IP to my Access-Point, namely '192.168.1.10'.
$ cat /etc/network/interfaces
auto enp2s0
iface enp2s0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
Here is the problem: I cannot access internet with this setups. It's like Ubuntu is trying to connect to Internet via 'enp2s0', which is only an AP with no access to internet.
So i tried
sudo ifconfig enp2s0 down
and there it is, i have internet. Also, when I do
sudo ifconfig enp2s0 up
after that, i still have access to internet.
How can I config my PC so that it will always use 'enp0s29f7u8' to access internet and use 'enp2s0' only as an AP?
PS:
I really don't understand network stuff. I tried changing default gateway (I don't know why) but it didn't helped(at least the way i did).
I'm not a native English speaker. Hope that I could talk my mind.
networking server routing
networking server routing
New contributor
New contributor
edited Nov 23 at 17:10
George Udosen
18.5k94265
18.5k94265
New contributor
asked Nov 23 at 10:39
ali
32
32
New contributor
New contributor
Possible duplicate of Set specific interface for internet access ?
– singrium
Nov 23 at 10:52
1
@singrium that is my question exactly. But the answer doesn't fit my situation since my PC doesn't have any desktop environment. Also I tried changing default gateway withroute add change default gw 192.168.42.1
but it didn't work
– ali
Nov 23 at 10:53
Runip route
to see which is your default gateway, then runsudo route delete default gw <IP Address> <Adapter>
. After that, runsudo route add default gw <IP Address> <Adapter>
. Ifroute
is not installed, runsudo apt install net-tools
to install it
– singrium
Nov 23 at 11:03
I will try it. thanks.
– ali
Nov 23 at 11:06
So what is theenp2s0
interface supposed to be use for?
– George Udosen
Nov 23 at 11:11
|
show 5 more comments
Possible duplicate of Set specific interface for internet access ?
– singrium
Nov 23 at 10:52
1
@singrium that is my question exactly. But the answer doesn't fit my situation since my PC doesn't have any desktop environment. Also I tried changing default gateway withroute add change default gw 192.168.42.1
but it didn't work
– ali
Nov 23 at 10:53
Runip route
to see which is your default gateway, then runsudo route delete default gw <IP Address> <Adapter>
. After that, runsudo route add default gw <IP Address> <Adapter>
. Ifroute
is not installed, runsudo apt install net-tools
to install it
– singrium
Nov 23 at 11:03
I will try it. thanks.
– ali
Nov 23 at 11:06
So what is theenp2s0
interface supposed to be use for?
– George Udosen
Nov 23 at 11:11
Possible duplicate of Set specific interface for internet access ?
– singrium
Nov 23 at 10:52
Possible duplicate of Set specific interface for internet access ?
– singrium
Nov 23 at 10:52
1
1
@singrium that is my question exactly. But the answer doesn't fit my situation since my PC doesn't have any desktop environment. Also I tried changing default gateway with
route add change default gw 192.168.42.1
but it didn't work– ali
Nov 23 at 10:53
@singrium that is my question exactly. But the answer doesn't fit my situation since my PC doesn't have any desktop environment. Also I tried changing default gateway with
route add change default gw 192.168.42.1
but it didn't work– ali
Nov 23 at 10:53
Run
ip route
to see which is your default gateway, then run sudo route delete default gw <IP Address> <Adapter>
. After that, run sudo route add default gw <IP Address> <Adapter>
. If route
is not installed, run sudo apt install net-tools
to install it– singrium
Nov 23 at 11:03
Run
ip route
to see which is your default gateway, then run sudo route delete default gw <IP Address> <Adapter>
. After that, run sudo route add default gw <IP Address> <Adapter>
. If route
is not installed, run sudo apt install net-tools
to install it– singrium
Nov 23 at 11:03
I will try it. thanks.
– ali
Nov 23 at 11:06
I will try it. thanks.
– ali
Nov 23 at 11:06
So what is the
enp2s0
interface supposed to be use for?– George Udosen
Nov 23 at 11:11
So what is the
enp2s0
interface supposed to be use for?– George Udosen
Nov 23 at 11:11
|
show 5 more comments
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You can set that up via the /etc/netplan/01-netcfg.yaml
configuration file. Steps:
Edit that file but make a backup first:
sudo nano /etc/netplan/01-netcfg.yaml
Add or change the file to this:
network:
version: 2
renderer: networkd
ethernets:
enp0s29f7u8:
dhcp4: true
Apply the changes:
sudo netplan apply
# Debug with
sudo netplan --debug apply
Or in your case use bonding
:
bonds:
bond0:
dhcp4: yes
interfaces:
- enp0s29f7u8
- enp2s0
parameters:
mode: active-backup
primary: enp0s29f7u8
Note: Take note of the indentations.
Excerpt:
Bonding, also called port trunking or link aggregation means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these. See Wikipedia for details.
Sources:
https://help.ubuntu.com/community/UbuntuBonding?&_ga=2.4304755.1589454052.1542970542-1686101836.1542733354#Descriptions_of_bonding_modes
https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux
https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
add a comment |
up vote
0
down vote
Di you try this:
To see which is your default gateway, run:
ip route
.To delete the current default gateway, run:
sudo route delete default gw
.
<IP Address> <Adapter>To add a new default gateway, run:
sudo route add default gw <IP
.
Address> <Adapter>
If route is not installed, run: sudo apt install net-tools
to install it.
Credits:
How to Add or Change the Default Gateway in Linux
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can set that up via the /etc/netplan/01-netcfg.yaml
configuration file. Steps:
Edit that file but make a backup first:
sudo nano /etc/netplan/01-netcfg.yaml
Add or change the file to this:
network:
version: 2
renderer: networkd
ethernets:
enp0s29f7u8:
dhcp4: true
Apply the changes:
sudo netplan apply
# Debug with
sudo netplan --debug apply
Or in your case use bonding
:
bonds:
bond0:
dhcp4: yes
interfaces:
- enp0s29f7u8
- enp2s0
parameters:
mode: active-backup
primary: enp0s29f7u8
Note: Take note of the indentations.
Excerpt:
Bonding, also called port trunking or link aggregation means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these. See Wikipedia for details.
Sources:
https://help.ubuntu.com/community/UbuntuBonding?&_ga=2.4304755.1589454052.1542970542-1686101836.1542733354#Descriptions_of_bonding_modes
https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux
https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
add a comment |
up vote
1
down vote
accepted
You can set that up via the /etc/netplan/01-netcfg.yaml
configuration file. Steps:
Edit that file but make a backup first:
sudo nano /etc/netplan/01-netcfg.yaml
Add or change the file to this:
network:
version: 2
renderer: networkd
ethernets:
enp0s29f7u8:
dhcp4: true
Apply the changes:
sudo netplan apply
# Debug with
sudo netplan --debug apply
Or in your case use bonding
:
bonds:
bond0:
dhcp4: yes
interfaces:
- enp0s29f7u8
- enp2s0
parameters:
mode: active-backup
primary: enp0s29f7u8
Note: Take note of the indentations.
Excerpt:
Bonding, also called port trunking or link aggregation means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these. See Wikipedia for details.
Sources:
https://help.ubuntu.com/community/UbuntuBonding?&_ga=2.4304755.1589454052.1542970542-1686101836.1542733354#Descriptions_of_bonding_modes
https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux
https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can set that up via the /etc/netplan/01-netcfg.yaml
configuration file. Steps:
Edit that file but make a backup first:
sudo nano /etc/netplan/01-netcfg.yaml
Add or change the file to this:
network:
version: 2
renderer: networkd
ethernets:
enp0s29f7u8:
dhcp4: true
Apply the changes:
sudo netplan apply
# Debug with
sudo netplan --debug apply
Or in your case use bonding
:
bonds:
bond0:
dhcp4: yes
interfaces:
- enp0s29f7u8
- enp2s0
parameters:
mode: active-backup
primary: enp0s29f7u8
Note: Take note of the indentations.
Excerpt:
Bonding, also called port trunking or link aggregation means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these. See Wikipedia for details.
Sources:
https://help.ubuntu.com/community/UbuntuBonding?&_ga=2.4304755.1589454052.1542970542-1686101836.1542733354#Descriptions_of_bonding_modes
https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux
https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
You can set that up via the /etc/netplan/01-netcfg.yaml
configuration file. Steps:
Edit that file but make a backup first:
sudo nano /etc/netplan/01-netcfg.yaml
Add or change the file to this:
network:
version: 2
renderer: networkd
ethernets:
enp0s29f7u8:
dhcp4: true
Apply the changes:
sudo netplan apply
# Debug with
sudo netplan --debug apply
Or in your case use bonding
:
bonds:
bond0:
dhcp4: yes
interfaces:
- enp0s29f7u8
- enp2s0
parameters:
mode: active-backup
primary: enp0s29f7u8
Note: Take note of the indentations.
Excerpt:
Bonding, also called port trunking or link aggregation means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these. See Wikipedia for details.
Sources:
https://help.ubuntu.com/community/UbuntuBonding?&_ga=2.4304755.1589454052.1542970542-1686101836.1542733354#Descriptions_of_bonding_modes
https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux
https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
edited Nov 23 at 11:22
answered Nov 23 at 11:08
George Udosen
18.5k94265
18.5k94265
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
add a comment |
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
i don't know why but after reinstalling OS and having no problem, i faced the same problem again and your answer worked for me. thanks
– ali
Nov 23 at 13:23
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
Great glad it worked out!
– George Udosen
Nov 23 at 13:43
add a comment |
up vote
0
down vote
Di you try this:
To see which is your default gateway, run:
ip route
.To delete the current default gateway, run:
sudo route delete default gw
.
<IP Address> <Adapter>To add a new default gateway, run:
sudo route add default gw <IP
.
Address> <Adapter>
If route is not installed, run: sudo apt install net-tools
to install it.
Credits:
How to Add or Change the Default Gateway in Linux
add a comment |
up vote
0
down vote
Di you try this:
To see which is your default gateway, run:
ip route
.To delete the current default gateway, run:
sudo route delete default gw
.
<IP Address> <Adapter>To add a new default gateway, run:
sudo route add default gw <IP
.
Address> <Adapter>
If route is not installed, run: sudo apt install net-tools
to install it.
Credits:
How to Add or Change the Default Gateway in Linux
add a comment |
up vote
0
down vote
up vote
0
down vote
Di you try this:
To see which is your default gateway, run:
ip route
.To delete the current default gateway, run:
sudo route delete default gw
.
<IP Address> <Adapter>To add a new default gateway, run:
sudo route add default gw <IP
.
Address> <Adapter>
If route is not installed, run: sudo apt install net-tools
to install it.
Credits:
How to Add or Change the Default Gateway in Linux
Di you try this:
To see which is your default gateway, run:
ip route
.To delete the current default gateway, run:
sudo route delete default gw
.
<IP Address> <Adapter>To add a new default gateway, run:
sudo route add default gw <IP
.
Address> <Adapter>
If route is not installed, run: sudo apt install net-tools
to install it.
Credits:
How to Add or Change the Default Gateway in Linux
answered Nov 23 at 11:09
singrium
842217
842217
add a comment |
add a comment |
ali is a new contributor. Be nice, and check out our Code of Conduct.
ali is a new contributor. Be nice, and check out our Code of Conduct.
ali is a new contributor. Be nice, and check out our Code of Conduct.
ali is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1095341%2fhow-to-change-default-interface-for-internet%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
Possible duplicate of Set specific interface for internet access ?
– singrium
Nov 23 at 10:52
1
@singrium that is my question exactly. But the answer doesn't fit my situation since my PC doesn't have any desktop environment. Also I tried changing default gateway with
route add change default gw 192.168.42.1
but it didn't work– ali
Nov 23 at 10:53
Run
ip route
to see which is your default gateway, then runsudo route delete default gw <IP Address> <Adapter>
. After that, runsudo route add default gw <IP Address> <Adapter>
. Ifroute
is not installed, runsudo apt install net-tools
to install it– singrium
Nov 23 at 11:03
I will try it. thanks.
– ali
Nov 23 at 11:06
So what is the
enp2s0
interface supposed to be use for?– George Udosen
Nov 23 at 11:11