Skip to content

Instantly share code, notes, and snippets.

@martinkennelly
Created April 23, 2025 11:11
Show Gist options
  • Select an option

  • Save martinkennelly/3f008215d0b0846eb43dc1a9c4127488 to your computer and use it in GitHub Desktop.

Select an option

Save martinkennelly/3f008215d0b0846eb43dc1a9c4127488 to your computer and use it in GitHub Desktop.
OCP 4.14-4.17: remove EgressIP SNAT from gateway router
#!/bin/bash
# Version 1.0 (23 Apr 2025)
# Martin Kennelly (OCP Networking)
# Designed to assist with https://issues.redhat.com/browse/OCPBUGS-42303
# Requires ovn-northd+ovn-controller to sync at least once for SNAT removal changes to propagate to data plane
# Must be executed before ovnkube-controller is started
DATE=$(date +"%Y-%m-%d-%H-%M")
echo "$DATE"
for NAT_UUID in $(ovn-nbctl --bare --column _uuid find nat external-ids:\"name\"!=\"\") ; do \
GW_Router_NAT_UUID=$(ovn-nbctl --bare --column _uuid,nat find logical_router | grep -B1 "$NAT_UUID" | awk {'print $1'} | head -n1)
if [[ -n "${GW_Router_NAT_UUID}" ]]; then
ovn-nbctl remove logical_router "${GW_Router_NAT_UUID}" nat "${NAT_UUID}"
echo "Removed EgressIP (S)NAT with NAT UUID ${NAT_UUID} from Gateway Logical Router UUID ${GW_Router_NAT_UUID}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment