Skip to content

Instantly share code, notes, and snippets.

@devulrix
Created March 5, 2022 20:35
Show Gist options
  • Select an option

  • Save devulrix/84a2ce581662a464f788aa040cd63c41 to your computer and use it in GitHub Desktop.

Select an option

Save devulrix/84a2ce581662a464f788aa040cd63c41 to your computer and use it in GitHub Desktop.
Enable XFF on NSX-T LB with non NSX-T Ingress for TKGi
#!/usr/bin/env bash
#
usage() {
echo "Usage: $0 [ -n CONTROLLER URL ] [-u ADMIN ] [-p PASSWORD ] [-s SERVER_POOL ]"
}
exit_abnormal() {
usage
exit 1
}
while getopts n:u:p:s: flag
do
case "${flag}" in
n) NSXT_URL=${OPTARG};;
u) NSXT_ADMIN=${OPTARG};;
p) NSXT_PASSWORD=${OPTARG};;
s) NSXT_SERVERPOOL=${OPTARG};;
*) exit_abnormal;;
esac
done
PAYLOAD=$(curl -k -s -u ${NSXT_ADMIN}:${NSXT_PASSWORD} -X GET "${NSXT_URL}/api/v1/loadbalancer/pools/${NSXT_SERVERPOOL}" | jq -r 'del(.snat_translation)')
curl -k -s -u ${NSXT_ADMIN}:${NSXT_PASSWORD} -H "Content-Type: application/json" -X PUT "${NSXT_URL}/api/v1/loadbalancer/pools/${NSXT_SERVERPOOL}" -d "${PAYLOAD}" -H "X-Allow-Overwrite: true"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment