fix(transfer): actually drop a RHEL guest's IPv6 on a host that has none
A container moving to a host with no IPv6 has to lose the address it carried, and on RHEL-family guests that means telling NetworkManager, not editing a file. NetworkManager will not accept the change in the obvious order — a method of "manual" requires an address, and an address is not allowed under a method of "disabled" — so the guest still came up with the address from the host it left. Setting the whole final state in one request is what it accepts. Verified with an AlmaLinux 9 guest in both directions against a prefix-mode and a pool-mode host: moved to the prefix host it came back up with one bridged NIC carrying this host's IPv4 and IPv6 (which required re-enabling the IPv4 that the pool-mode layout had disabled on that NIC); moved to the pool host it came up pure IPv4 with ipv6.method disabled and no global address at all. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
1 parent
fc31a1e3d4
commit
64a3b97a96
1 file changed
+5
-1
@@ -567,7 +567,11 @@ if command -v nmcli >/dev/null 2>&1 && ! systemctl is-active systemd-networkd >/
|
||||
CONN=$(nmcli -t -f NAME,DEVICE con show 2>/dev/null | awk -F: '$2 == "eth0" {print $1; exit}')
|
||||
[ -z "$CONN" ] && CONN=$(nmcli -t -f NAME con show 2>/dev/null | grep -i eth0 | head -1)
|
||||
if [ -n "$CONN" ]; then
|
||||
nmcli con mod "$CONN" ipv6.method disabled >/dev/null 2>&1 || true
|
||||
# The address and the method have to be cleared together: NetworkManager
|
||||
# refuses a method of "manual" with no address left, and refuses an
|
||||
# address under a method of "disabled", so only the final state, set in
|
||||
# one request, is accepted.
|
||||
nmcli con mod "$CONN" ipv6.method disabled ipv6.addresses "" ipv6.gateway "" >/dev/null 2>&1 || true
|
||||
nmcli con up "$CONN" >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user