From fda9a350a1dfb4a33e9e4bf9e5272d5b4f74f541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jake=20Buchholz=20G=C3=B6kt=C3=BCrk?= Date: Fri, 24 Mar 2023 16:41:37 -0700 Subject: [PATCH] imds-net-sync should only work with secondary ipv4s on an interface --- sbin/imds-net-sync | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sbin/imds-net-sync b/sbin/imds-net-sync index 4004134..9099a98 100755 --- a/sbin/imds-net-sync +++ b/sbin/imds-net-sync @@ -49,14 +49,15 @@ iface_ip6s() { } imds_ip4s() { - local ip4s=$(imds "@nic:$IFACE,@ipv4") + local ip4=$(imds "@nic:$IFACE,@ipv4") + local ip4s=$(echo "$ip4" | tail +2) # secondary IPv4s local ip4p ip4_cidr ip4_gw # non-eth0 interfaces need custom route tables # if [ "$IFACE" != eth0 ] && [ -n "$ip4s" ] && [ -z $(ip +F -4 route show table "$RTABLE" 2>/dev/null) ]; then - ip4p=$(echo "$ip4s" | head -1) # primary IPv4 + ip4p=$(echo "$ip4" | head -1) # primary IPv4 ip4_cidr=$(imds "@nic:$IFACE,@ipv4-net") # TODO: get from iface instead? # TODO: this may not hold true for non-AWS clouds ip4_gw=$(echo "$ip4_cidr" | cut -d/ -f1 | @@ -68,6 +69,8 @@ imds_ip4s() { echo "$ip4s" } +# TODO: 3.18+ when we use dhcpcd for ipv4 & ipv6, we only need to do secondary IPv6s +# circle back and see how amazon-ec2-net-utils is handling everything these days imds_ip6s() { local ip6s gw tries=20 ip6s=$(imds "@nic:$IFACE,@ipv6")