What is the correct way to restart nmcli interface remotely?
Solution 1
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
Solution 2
This worked fine for me.
nmcli device disconnect enp4s6; wait ; nmcli device connect enp4s6
Obviously replace enp4s6 with your device name
Related videos on Youtube
Serfoo
Updated on September 18, 2022Comments
-
Serfoo over 1 year
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.
-
Michael about 4 yearsAre you running the command in a screen/tmux session over ssh? As soon as you run that command and it disconnects I don't think it will run the rest. Try it in a tmux session
tmux new
-
Serfoo about 4 yearsYes, the command seems to have been executed only for the first part, the disconnection. I know there are a lot of tools, but I want to be able to restart the network-manager interface without any extra tool. Screen and tmux are not on Ubuntu or Debian by default.
-
tim over 3 yearsMaybe preface the commands with
nohup
-
-
Sean McCarthy over 3 yearsThis worked for me as well. Cheers