How do I force NM to try and make lan connection.

If I have disconnected a lan connection which has a manual ip address in order to select another connection which has a different subnet configuration I frequently find NM just gives up and says there is no connection available even though the lan cable is connected and the device powered on.

This problem usually occurs when I am connecting to a device using a default fixed address and when no DHCP sever is available, for example when connecting to a new and unconfigured switch or AP.

When I am confronted with this problem all I can do at present is reboot. Is there a better way?
Budge

This is far too vague to make any guess. Explain what “disconnect a lan connection” means and how you select another connection. Show logs when it happens and connection(s) definition(s).

Hi arvidjaar,
Will have to come back to this later when I have time to take proper record of issues. Am working on site but much more slowly because of this problem.

I am with @avidjaar that you probably should do less of prose, but more a step wise explanation of what you do…

But it is possible that I more or less understand what you mean.

  1. You configure NM with a fixed IP address, thus telling it explicitly that you do not want it to use DHCP to get an IP address from any source.
  2. You disconnect the ethernet cable and connect it to another network.
  3. NM still tries to use the IP you told it to use and that fails of course because there is no partner within the subnet now connected.

IMHO this is a logical situation. I do not know of any way how NM can decide that your configuration all of a sudden should be changed from not using DHCP into using it. NM fails the feature of mind reading.

I do not really understand what you did and what you wanted to achieve. But hopefully some of the following hints are helpful for you:

  • By default, NetworkManager
    creates a temporary wired connection for any Ethernet device that is managed and doesn’t have a connection configured. To avoid this behaviour i created a file /etc/NetworkManager/conf.d/20-cable_autoconnect.conf with no-auto-default=* in it. This disables that behaviour and gives me full control (when will which port be activated / de-activated) on all my LAN connections. - For each connection there is a file in /etc/NetworkManager/system-connections
    in which the connection specific parameters (LAN/WLAN, DHCP/manual IP address, …) are defined. I have one file to connect to any network that provides DHCP-connection. And many different files with manual setup (IP, DNS, …) connections. How to create these connection files and how to switch between them depends on your desktop environment (in KDE i use plasma-nm5). But as far as i know the NetworkManager package will always provide nmcli and nmtui (to be used from the command line) for that purpose. - I always de-activate an active connection (with one of the tools mentioned above) before i unplug/change the LAN cable.

Regards

susejunky

Perfect. You understand my problem and have a solution. Many thanks.

Only one question; is the de-activation of an active connection as you describe essential? What are implications of crashing out by just unplugging or by rebooting the device to a new subnet?

For example, say I have used a default ip on a new device to log in, reconfigured the device connection as required and then rebooted it, of course I lose the connection. What I wish is to be able to go straight to NM and be able to select the new, already preconfigured connection. It might be for DHCP if I have enabled DHCP on my laptop but more usually it is for a new fixed subnet to which I can connect, log in and continue with configuration of the device.

I am thinking that once the original connection has been broken and after a sensible timeout, I would like to connect to the new connection and have NM succeed. Is the crude disconnection going to cause further problems with NM?

Many thanks again for your help. Will try as you suggest and report back if there are issues.
Budge

I have multiple ethernet connection definitions (and some VPN connections) configured, and frequently change networks as you describe without issue. I have them set up to reach various network devices (usually for config purposes), as well as a DHCP connection for when that i required.

Hi Deano,
You clearly understand the procedure. Glad you don’t have any problems with NM.

My own NM experience has been just about acceptable until recently when NM stopped working for me until I had to reboot. NM has been irritating in the past and in fact my office workstation has been using wicked for the last couple of years because of the problems I have had previously. For work on site however the laptop with NM is what I use but now has become impossible. To do testing and write up the symptoms accurately requires time I do not have, hence my hasty post.

I now have some other options to work on. Not sure the blanket no-auto-default is quite right for me until I learn how to bring some options back, in particular when turning on for normal use rather than playing with switches and aps. If you have any suggestions on an intermediate configuration please say.
Regards,
Budge

I am not sure if it is essential. I just do so in order to avoid potential (?) problems.

As long as you have a connection file that represents your new connection setup you should be able to switch NetworkManager to that connection (as soon as the device has booted completely).

If you do not have a connection file available you still can create it (using nmcli, nmtui, plasma-nm5, … or even just a text editor) but then you might have to restart NetworkManager to set the new connection file active…

Regards

susejunky

You could examine the NetworkManager logging to gain a better understanding of what is not working as expected. There should be no need to reboot either. (You can just restart the NetworkManager service if necessary.)

Hi and many thanks for the quick reply. I am using KDE Plasma 5.21.3 so am shadowing your advice closely.

Having tried your suggestion I had one surprise after booting. NM didn’t run at all. Not sure is this what should happen or not.

My problem, moving forward, is largely confined to lan connections when working with devices which have copper connections. Once wifi is enabled, NM presents all the wifi options, usually already set up and all I have to do is select the right SSID. Because only one lan connection potential can be made at a time, and this only when plugged in. There is no wifi analogy. It is the absence of any lan connection list from which to make a selection which becomes the problem.

A good intermediate position might be to leave the wifi connections on auto and have NM running. How should I do this?
I might then use nmtui to select lan connection.

Of course it would also be good to get the list of connections showing from the plasma widget and not have to use nmtui but not sure if this would be possible.
Thanks again,
Budge

Hi Deano,
Ok will do but I need a bit of help with the commands please!

Budge

Examine the journal. For example…

sudo journalctl -u NetworkManager

To watch the service on the fly in a terminal window…

sudo journalctl -fu NetworkManager

Too vague…do you mean NetworkManager is not active, or the desired connection was not activated as expected? For the former, check

sudo systemctl status NetworkManager

For the latter, you’d need to examine/share the connection profiles you have configured. These are located in the /etc/NetworkManager/system-connections/ directory.

For a more comprehensive understanding of NetworkManager, take your time to read the following…

https://doc.opensuse.org/documentation/leap/reference/html/book-opensuse-reference/cha-nm.html

man NetworkManager

Hi Deano,
Thanks for the reference article which was clear and helpful. I also spent some time reading man pages for NetworkManager and NetworkManager.conf.

By way of background on why I have this problem, I have required to access a bunch of hardware devices; multi SSID APs and L2+ switches in order to set new static ips, passwords and half a dozen vlans on each device in order to reconfigure our network. This has meant more than my usual need to play around with network connections and subnets and in the middle of doing this work I suddenly find there are no connections offered on my applet and I am stopped in my tracks.

I still cannot pin down the sequence of my actions which provokes the total loss of network connections (all lan connections as wifi turned off) from appearing in my applet for selection but I am confident it is a matter of tuning my configuration. The details are beyond me but it appears a change of connection is failing to offer again my list of connections for selection. Possibly a timing thing or just the wrong option in the configuration defaults on my system.

I am as sure as I can be that this is not a bug but only my ignorance on how to tune NM for my purposes.

I am now struggling with what I can do to reproduce the problem so I can examine the logs before and after I have lost all connections.

Meanwhile I thought I might try something different. If I use the configuration suggested above earlier,

**/etc/NetworkManager/conf.d/20-cable_autoconnect.conf** with ***no-auto-default=****

With this configuration I find NM does not start on re-boot. What I am thinking is, after re-boot I can try and start NM and then run

nmtui

which will then enable me to select the connection I require. Is this an idea worth pursuing, modified by somebody who knows, to make it work?

Just a thought.
Budge

When this happens, check link status…

ip link

NM connectivity interface status…

nmcli d

Current connections available and in use…

nmcli c

Meanwhile I thought I might try something different. If I use the configuration suggested above earlier,

**/etc/NetworkManager/conf.d/20-cable_autoconnect.conf** with ***no-auto-default=****

With this configuration I find NM does not start on re-boot. What I am thinking is, after re-boot I can try and start NM and then run

nmtui

which will then enable me to select the connection I require. Is this an idea worth pursuing, modified by somebody who knows, to make it work?

Just a thought.
Budge

Yes, nmtui (curses-based) or nmcli (CLI) both provide alternative means to manage NM connectivity.

Setting no-auto-default=* should NOT stop NetworkManger from starting on re-boot.

If that happens then something different is wrong with your system!

no-auto-default=* only keeps NetworkManager from creating default wired connections (on any available ethernet device) automatically.

Regards

susejunky

Use USB LAN cards (devices).
With that you can:

  1. Physically plug and unplug it.
  2. Get as many LAN ports as you wish.
  3. Configure settings depend on MAC.
    … etc.

Very useful with laptops. Even works with tablets and smartphones.