From dea38edcead6b1aee399c8557076ab9a373da5b3 Mon Sep 17 00:00:00 2001 From: Frederik Nordahl Jul Sabroe Date: Fri, 12 May 2023 17:55:33 +0200 Subject: [PATCH] Fix port-forward name clash If you have two pods, with similar hostnames, such as: - somepod - somepod2 Then the grep would previously capture both, and try to assign IPs like `192.168.252.10\n11`, which is obviously not quite valid. This should make it such that the grep will only match when the name is complete --- bin/client_init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/client_init.sh b/bin/client_init.sh index 00b75ed..aaf12ee 100755 --- a/bin/client_init.sh +++ b/bin/client_init.sh @@ -37,7 +37,7 @@ ip route # Derived settings K8S_DNS_IP="$(cut -d ' ' -f 1 <<< "$K8S_DNS_IPS")" GATEWAY_IP="$(dig +short "$GATEWAY_NAME" "@${K8S_DNS_IP}")" -NAT_ENTRY="$(grep "$(hostname)" /config/nat.conf || true)" +NAT_ENTRY="$(grep "^$(hostname) " /config/nat.conf || true)" VXLAN_GATEWAY_IP="${VXLAN_IP_NETWORK}.1" # Make sure there is correct route for gateway