Sunday, March 15, 2020

Switch connection between two interfaces using nmcli

A way to switch network interface from console is using nmcli. Going through the man page you can see a small set of examples. For example to create a new connection you can run

$ nmcli dev wifi con "Cafe Hotspot 1" password caffeine name "My cafe"

Some Basic Background

What you need is:
- A valid network device
Make sure that the device has recognized and the drivers have been loaded. After that you should be able to find the interface with nmcli

$ nmcli device 
or
$ nmcli device status

should give you an output like this(if you have no active connection yet)

DEVICE             TYPE      STATE           CONNECTION         
wlp2s0                wifi          disconnected  --

- A connection configuration that can be found under /etc/sysconfig/network-scripts/ (at least in fedora). The configuration file is created by nm when ever for example you run the command that we saw above first to create a new connection.

to check the connection from nmcli

$ nmcli connection show "My Cafe"
Here is good to check some things
- The connection.autoconnect. Make sure that it has "yes" value
- The connection.interface-name. This might have the name of the interface.

Use nmcli to change the interface of the connection

In case you have two interfaces and you want to switch between each other you should be able to do so with

$ nmcli connection up "My Cafe" ifname wlp2s0

This is not always easy as that but it is usually easy to fix. To make this work you might change a few things in the connection configuration. For instance if i have the following error, personally

Error: Connection activation failed: No suitable device found for this connection (device enp1s0 not available because profile is not compatible with device (mismatching interface name)). 
or
Error: device 'wlp0s29u1u3' not compatible with connection '1925_www.radlice.net': The MACs of the device and the connection didn't match..

For the first i solve the problem as i have already say above, removing the you connection.interface-name. For the other one, i checked the the 802-11-wireless.mac-address. it had the MAC from the other interface. I made sure that it is also not set. Easy modify any variable with

$ nmcli connection modify "My Cafe"  802-11-wireless.mac-address ""

Sunday, October 06, 2019

Resolving bootloader problem after upgrading Fedora 28 to 31(beta)

dnf is an amazing packaging tool in my opinion. And so far i had no problem to upgrade my system. This time, though, i tried an upgrade 3 distribution away. Fedora documentation ofcourse warns you that this might come with risks. Anyway i decided to give it a go and that ends with a problem in the booting process. While the upgrade finished smoothly without serious problems when i restarted i faced the bootloader which had the new kernel, the last two from Fedora28 and a rescue mode option. No matters where you chose to boot in, the loader was looping displaying the boot menu again and again.

To solve this, here what you can do

Press C to open the grub console and type

configfile /grub2/grub.cfg.rpmsave

dnf save the old configs with the extension rpmsave. This is the old grub.cfg and with the command above you will be able to boot in the old distribution. From there the solution is to reinstall the grub with

grub2-install /dev/sda

/dev/sda is the boot partition. In case you wonder which one is yours use lsblk.