Score:1

how can I specify which network interface is the one my computer uses?

ma flag

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.

Score:1
pk flag

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.

Chris Foster avatar
ma flag
Thank you so much for this answer, it solved everything for me and it really helped me grasp what is actually going on here. Thank you so much
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.