Restart network on RHEL8/CentOs8 thru ssh using nmcli with testing that the operation has finished
Thru ssh I’m updating the network configuration and then I want to restart the network.
systemctl restart NetworkManager
doesn’t work very well with ipv6 static changes.
So I tried:
nmcli connection reload && nmcli networking off && nmcli networking on
The above doesn’t work as expected but using also -w
to set a timeout works most of the time.
I’m looking for a more reliable option like do a sort of a test in the command and if is not ok, to retry the commands for a number of times.
Everything needs to be done in one step, because when network is going down, the ssh connection will be lost. A probe will check later with the new configuration.