How to change default interface for internet?












-1














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:




  1. To provide It's internet, I am using an android smartphone that has access to internet via it's 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'.


  2. 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.268.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?



p.s. 1: 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).



p.s. 2: I'm not a native English speaker. Hope that I could talk my mind.










share|improve this question


















  • 1




    Hi and welcome to SO. Your question does not belong on stackoverflow (questions about programming only stackoverflow.com/help/on-topic) but on askubuntu.com
    – quant
    Nov 23 '18 at 10:31










  • @quant you are right. sorry about that and thank you :)
    – ali
    Nov 23 '18 at 10:33
















-1














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:




  1. To provide It's internet, I am using an android smartphone that has access to internet via it's 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'.


  2. 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.268.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?



p.s. 1: 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).



p.s. 2: I'm not a native English speaker. Hope that I could talk my mind.










share|improve this question


















  • 1




    Hi and welcome to SO. Your question does not belong on stackoverflow (questions about programming only stackoverflow.com/help/on-topic) but on askubuntu.com
    – quant
    Nov 23 '18 at 10:31










  • @quant you are right. sorry about that and thank you :)
    – ali
    Nov 23 '18 at 10:33














-1












-1








-1







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:




  1. To provide It's internet, I am using an android smartphone that has access to internet via it's 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'.


  2. 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.268.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?



p.s. 1: 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).



p.s. 2: I'm not a native English speaker. Hope that I could talk my mind.










share|improve this question













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:




  1. To provide It's internet, I am using an android smartphone that has access to internet via it's 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'.


  2. 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.268.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?



p.s. 1: 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).



p.s. 2: I'm not a native English speaker. Hope that I could talk my mind.







linux ubuntu networking routing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 10:18









ali

11




11








  • 1




    Hi and welcome to SO. Your question does not belong on stackoverflow (questions about programming only stackoverflow.com/help/on-topic) but on askubuntu.com
    – quant
    Nov 23 '18 at 10:31










  • @quant you are right. sorry about that and thank you :)
    – ali
    Nov 23 '18 at 10:33














  • 1




    Hi and welcome to SO. Your question does not belong on stackoverflow (questions about programming only stackoverflow.com/help/on-topic) but on askubuntu.com
    – quant
    Nov 23 '18 at 10:31










  • @quant you are right. sorry about that and thank you :)
    – ali
    Nov 23 '18 at 10:33








1




1




Hi and welcome to SO. Your question does not belong on stackoverflow (questions about programming only stackoverflow.com/help/on-topic) but on askubuntu.com
– quant
Nov 23 '18 at 10:31




Hi and welcome to SO. Your question does not belong on stackoverflow (questions about programming only stackoverflow.com/help/on-topic) but on askubuntu.com
– quant
Nov 23 '18 at 10:31












@quant you are right. sorry about that and thank you :)
– ali
Nov 23 '18 at 10:33




@quant you are right. sorry about that and thank you :)
– ali
Nov 23 '18 at 10:33












1 Answer
1






active

oldest

votes


















-1














To modify the routing table you have to use the command route.
If you run the command as super user it should show how the traffic is routed from your host. You have to change the default to enp0s29f7u8. In order to change it you can simply remove the default



# route del default



and add again



# route add default dev enp0s29f7u8



You can route only some address to the other interface. Have a look at the man for more option of the route command






share|improve this answer





















  • Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
    – ali
    Nov 23 '18 at 12:09











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444758%2fhow-to-change-default-interface-for-internet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














To modify the routing table you have to use the command route.
If you run the command as super user it should show how the traffic is routed from your host. You have to change the default to enp0s29f7u8. In order to change it you can simply remove the default



# route del default



and add again



# route add default dev enp0s29f7u8



You can route only some address to the other interface. Have a look at the man for more option of the route command






share|improve this answer





















  • Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
    – ali
    Nov 23 '18 at 12:09
















-1














To modify the routing table you have to use the command route.
If you run the command as super user it should show how the traffic is routed from your host. You have to change the default to enp0s29f7u8. In order to change it you can simply remove the default



# route del default



and add again



# route add default dev enp0s29f7u8



You can route only some address to the other interface. Have a look at the man for more option of the route command






share|improve this answer





















  • Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
    – ali
    Nov 23 '18 at 12:09














-1












-1








-1






To modify the routing table you have to use the command route.
If you run the command as super user it should show how the traffic is routed from your host. You have to change the default to enp0s29f7u8. In order to change it you can simply remove the default



# route del default



and add again



# route add default dev enp0s29f7u8



You can route only some address to the other interface. Have a look at the man for more option of the route command






share|improve this answer












To modify the routing table you have to use the command route.
If you run the command as super user it should show how the traffic is routed from your host. You have to change the default to enp0s29f7u8. In order to change it you can simply remove the default



# route del default



and add again



# route add default dev enp0s29f7u8



You can route only some address to the other interface. Have a look at the man for more option of the route command







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 11:04









Marco Fargetta

91




91












  • Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
    – ali
    Nov 23 '18 at 12:09


















  • Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
    – ali
    Nov 23 '18 at 12:09
















Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
– ali
Nov 23 '18 at 12:09




Unfortunately, something went wrong with Ubuntu and it was broken really bad. I tried reinstalling the OS while both interfaces where connected and now it's working fine. thanks for your time.
– ali
Nov 23 '18 at 12:09


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444758%2fhow-to-change-default-interface-for-internet%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo