Score:0

Automatically switch wired connection with and without 802.1x auth (in office and home setting)

au flag

I have a USB-Ethernet Adapter for my laptop, which I use at home ("normal" network) and at work, where the network is 802.1x protected. Both connections work fine when I set them up.

However, when coming home, I need to disable the 802.1x toggle (Ubuntu 20.04 Wired Connection Settings UI) for the internet to work. But when I enable it again, all the configuration is lost and I have to type my username, certificate etc again.

I know the USB adapter is the same adapter with the same MAC address, but surely there must exist a better way to deal with two networks? If it is not feasible or safe to detect the current network, I'm fine with toggling a switch, but not with setting up the networks all from scratch again every day. Surely, there is a better way?

Score:1
ar flag

Create a new connection

I upgraded all my computers to Ubuntu 22.04 some months ago. So, the instructions here may be a bit out of sync.

Open the app Advanced Network Configuration

To do this you will need to open a Terminal first. Press Ctrl+Alt+T to open a terminal and enter:

nm-connection-editor

You will see something like this:

enter image description here

As you can see there is a connection called the Wired connection 1 under Ethernet. This is your default (USB) Ethernet connection. We will keep it as is for your home Ethernet.

Click on the + sign at the bottom right corner to create a new connection. Once you click on it, you will see:

enter image description here

The connection type should be Ethernet by default if not choose Ethernet as the connection type. Then click the Create... button.

You will see something like this:

enter image description here

Go to the General tab as shown above and make sure the Connect automatically with priority is set at the default 0.

Similarly, open the settings of the other Ethernet connection (the default one used at home) and and make sure the Connect automatically with priority is set at the default 0. OP's comments shows keeping both connection's priority at the default 0 worked best for him.

Alternate Priority Settings:

Change automatically with priority from 0 to -10. This will try to use the default configuration first if your laptop is connected to any USB-Ethernet. If it fails to connect, then it will try to use this connection. If you want to have the this connection higher priority, you can use 10 instead of -10. 0 is the default. Higher numbers means higher priority.

END of Alternate Priority Settings:

Change the name of the connection to something like Office Ethernet

Go to the 802.1X Security tab and fill in the blanks as needed:

enter image description here

Make other configuration changes as your office IT department tells you. When satisfied, click on the Save button. You will see something like:

enter image description here

As you can see, a new Ethernet connection called the "Office Ethernet" has been added.

Now you will see the two Ethernet connections in the drop down system menu when you are connected to the USB-Ethernet.

enter image description here

If the automatically connect priorities do not work for some reason, you should be able to select the correct network configuration manually depending on your location.

Hope this helps

au flag
It looks the same on 20.04 and works perfectly. After using the`nm-connection-editor`, I can now also see the connections in the standard settings UI, but it's not possible to change the priority there unfortunately, so this is the way to go. Thank you!
ar flag
@bjrne thanks for confirming that it worked for you. For some reason Canonical decided to hide the `nm-connection-editor` from the GUI application searches in Ubuntu 20.04. I think they fixed it in 22.04 so that It is easier to find.
au flag
For others: in the end, I actually set the priority to 0 for both connections. When I had different priorities, ubuntu would sometimes try to switch to the other one which resulted in connection interruptions and authentication popups for me. This does not happen when both have a priority of 0, while it will still find the right connection if the other one fails to connect. I still needed the `nm-connection-editor`, since the default wired connection had a prio of `-999` before changing it.
ar flag
@bjrne Thanks for the feedback on the priority settings. i will edit the answer to reflect your experience.
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.