1

I have Ubuntu LTS release 22.04.

I need to figure out how to specify which interface in my machine is the one it's using for network traffic. It's a Thinkpad w541 laptop. I need to be able to create virtual (VLAN) interface's and get my computer to use them instead of the "normal" interface.

Let's say I need to be able to access VLAN 6 on my computer. I have the interface in terminal. If I run an ifconfig, I see the enp0s25.6 interface with a valid network address, as well as the normal enp0s25 as well as the wireless interface and the loopback interface.

But my computer always chooses to use the enp0s25 interface.

How can I get it to use the enp0s25.6 virtual interface? I used the advanced network settings GUI to create the VLAN interface. It doesn't give any option to actually use it. The normal GUI settings do not say anything about vlans, so I assume I need the terminal.

David DE
  • 2,316

1 Answers1

1

When sending network packets, your computer selects a network interface based on the address it's sending the packet to, and the routing table.

Normally you will run the DHCP protocol to auto-configure your "main" interface and from this your computer will learn that it has a connection to the entire Internet through some router, and it will learn the address of that router. You can also specify the address of this router manually. The setting is usually called "default gateway" - I don't know whether Ubuntu also calls it that.

This information goes into the routing table which can be viewed with the ip route command. Your typical home computer will have a couple of specific routes for specific address ranges reflecting the networks it's directly connected to, telling it to send packets destined to those addresses directly to those networks, and then an entry for 0.0.0.0/0 which reflects the entire Internet, telling it to send packets destined for any address to your home router. More specific routes take priority, so 0.0.0.0/0 (the least specific route possible) does not include those directly connected networks that have specific entries.

If more than one interface uses DHCP or has a default gateway configured, you'll have more than one 0.0.0.0/0 entry in your routing table, and one is chosen arbitrarily (based on some kind of interface properties, and it's never the one you want) so you might want to unconfigure the ones you don't want to use.