Ubuntu – How to change default interface for internet


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

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

    $ cat /etc/network/interfaces
    auto enp2s0
    iface enp2s0 inet static 

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?


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

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

Best Answer

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.
How to Add or Change the Default Gateway in Linux

Related Question