From 0e25076b34fa995161b83996e866c0974cee431f Mon Sep 17 00:00:00 2001 From: Emanuele Giuseppe Esposito Date: Mon, 6 Dec 2021 18:34:26 +0100 Subject: cloudinit/net: handle two different routes for the same ip (#1124) If we set a dhcp server side like this: $ cat /var/tmp/cloud-init/cloud-init-dhcp-f0rie5tm/dhcp.leases lease { ... option classless-static-routes 31.169.254.169.254 0.0.0.0,31.169.254.169.254 10.112.143.127,22.10.112.140 0.0.0.0,0 10.112.140.1; ... } cloud-init fails to configure the routes via 'ip route add' because to there are two different routes for 169.254.169.254: $ ip -4 route add 192.168.1.1/32 via 0.0.0.0 dev eth0 $ ip -4 route add 192.168.1.1/32 via 10.112.140.248 dev eth0 But NetworkManager can handle such scenario successfully as it uses "ip route append". So change cloud-init to also use "ip route append" to fix the issue: $ ip -4 route append 192.168.1.1/32 via 0.0.0.0 dev eth0 $ ip -4 route append 192.168.1.1/32 via 10.112.140.248 dev eth0 Signed-off-by: Emanuele Giuseppe Esposito RHBZ: #2003231 --- cloudinit/net/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cloudinit/net') diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index 7558745f..f81f3a7b 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -1157,7 +1157,7 @@ class EphemeralIPv4Network(object): if gateway != "0.0.0.0": via_arg = ['via', gateway] subp.subp( - ['ip', '-4', 'route', 'add', net_address] + via_arg + + ['ip', '-4', 'route', 'append', net_address] + via_arg + ['dev', self.interface], capture=True) self.cleanup_cmds.insert( 0, ['ip', '-4', 'route', 'del', net_address] + via_arg + -- cgit v1.2.3