10

On Ubuntu 18.04, NetworkManager is used. After modifying the configuration of an interface remotely, using the NetworkManager CLI.

Example:

nmcli connection modify (interface_profile_name) ipv4.addresses (XXX.XXX.XXX.XXX/XX)

How can I make it taken into account without shutting down my remote access?

I tried:

nmcli device disconnect (interface_name) && sleep 5 && nmcli connection up (interface_name)

Because it is recommended to disconnect, and then reconnect the modified interface, but it cuts my access to the computer, the old and the new IP address are unreachable. I have to move on the targeted computer to make locally the modifications.

I want to be able to make the modifications taken into account remotely, with nmcli by an SSH connection, and without restarting the computer (nothing extraordinary ^^).

The restart of the NetworkManager service doesn't change anything.

Thank you.

Serfoo
  • 101

2 Answers2

23

If you use nmcli's device reapply command, it will apply the changes. Replacing devicename with the actual device name of course.

nmcli device reapply devicename
zx485
  • 2,865
Adam Gibson
  • 331
  • 2
  • 2
4

This worked fine for me.

nmcli device disconnect enp4s6; wait ; nmcli device connect enp4s6

Obviously replace enp4s6 with your device name

The wait is just there to confirm the first command completes, the semicolon would allow the command to fail. You could rewrite it like this to avoid using wait.

nmcli device disconnect enp4s6 && nmcli device connect enp4s6

The symbols && will run the second command after the first command completes successfully.

Dan H
  • 41