Skip to content

Instantly share code, notes, and snippets.

@flavio-fernandes
Last active January 8, 2021 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flavio-fernandes/863e48f012b7975e1d46c896b262dfc9 to your computer and use it in GitHub Desktop.
Save flavio-fernandes/863e48f012b7975e1d46c896b262dfc9 to your computer and use it in GitHub Desktop.
floating ip port forwarding status test
#!/usr/bin/env bash
#
# ref: https://bugs.launchpad.net/neutron/+bug/1910334
[ $EUID -eq 0 ] && { echo 'must NOT be root' >&2; exit 1; } ||:
. ${HOME}/devstack/openrc admin
set -o xtrace
set -o errexit
openstack server create --nic net-id=private,v4-fixed-ip=10.0.0.10 --flavor m1.nano --image $IMAGE_ID -f value -c id --key-name demo d
sleep 3 && openstack port set --name dp $(openstack port list --server d -f value -c ID)
openstack server create --nic net-id=private,v4-fixed-ip=10.0.0.11 --flavor m1.nano --image $IMAGE_ID -f value -c id --wait --key-name demo e
sleep 3 && openstack port set --name ep $(openstack port list --server e -f value -c ID)
FIP=172.24.4.8
openstack floating ip create --floating-ip-address ${FIP} public
openstack floating ip show ${FIP}
FIP_UUID=$(openstack floating ip show ${FIP} -f value -c id) ; echo $FIP_UUID
# create pf for server d
openstack floating ip port forwarding create --internal-ip-address 10.0.0.10 --internal-protocol-port 22 \
--port dp --external-protocol-port 2020 --protocol tcp $FIP_UUID
PF_ID=$(openstack floating ip port forwarding list ${FIP_UUID} -f value -c 'Internal IP Address' -c ID | \
grep 10.0.0.10 | cut -d' ' -f1) ; echo $PF_ID
openstack floating ip show ${FIP}
openstack floating ip port forwarding delete ${FIP} $PF_ID
openstack floating ip show ${FIP}
openstack floating ip port forwarding create --internal-ip-address 10.0.0.10 --internal-protocol-port 22 \
--port dp --external-protocol-port 2020 --protocol tcp $FIP_UUID
PF_ID=$(openstack floating ip port forwarding list ${FIP_UUID} -f value -c 'Internal IP Address' -c ID | \
grep 10.0.0.10 | cut -d' ' -f1) ; echo $PF_ID
openstack floating ip show ${FIP}
openstack floating ip port forwarding create --internal-ip-address 10.0.0.11 --internal-protocol-port 22 \
--port ep --external-protocol-port 2021 --protocol tcp $FIP_UUID
openstack floating ip show ${FIP}
openstack floating ip port forwarding list $FIP_UUID
openstack floating ip port forwarding delete ${FIP} $PF_ID
openstack floating ip show ${FIP}
echo ok
@flavio-fernandes
Copy link
Author

this is the output when running that script under openstack ml2/ovn: https://gist.github.com/flavio-fernandes/f6fdd6cdce461c5e7ba07bedfbc23750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment