# list all floating IPs openstack floating ip list openstack floating ip show 1.2.3.4 openstack floating ip list --project ${PROJECT_ID} --long # Allocate floating IP openstack floating ip create public # Allocate specific floating IP for a project (as cloud admin) openstack floating ip create public --floating-ip-address 10.11.12.13 --project foo-project FLOATING_IP=$(openstack floating ip create public -c floating_ip_address -f value --floating-ip-address 10.11.12.13) # Associate floating IP to instance openstack server add floating ip ${INSTANCE_NAME_OR_ID} ${FLOATING_IP} # Disassociate floating IP openstack server remove floating ip ${INSTANCE_NAME_OR_ID} ${FLOATING_IP} # Release floating IP openstack floating ip delete ${FLOATING_IP} # show used floating IPs NETWORK_ID=$(openstack subnet list --network public -c Network -f value) openstack ip availability show -c total_ips -c used_ips ${NETWORK_ID} # Add floating IP to port openstack floating ip set --port ${PORT_ID} ${FLOATING_IP}
List reserved floating IPs per project
PROJECT_IDS=$(openstack floating ip list --status DOWN -f value -c Project | sort -u) for PROJECT_ID in ${PROJECT_IDS}; do PROJECT_NAME="$(openstack project show ${PROJECT_ID} -c name -f value)" DOMAIN_ID="$(openstack project show ${PROJECT_ID} -c domain_id -f value)" DOMAIN_NAME="$(openstack domain show ${DOMAIN_ID} -c name -f value)" echo "# ${DOMAIN_NAME} > ${PROJECT_NAME} (${PROJECT_ID})" openstack floating ip list --status DOWN --project ${PROJECT_ID} -c "Floating IP Address" -f value echo done
Links
https://docs.openstack.org/ocata/user-guide/cli-manage-ip-addresses.html
https://help.dreamhost.com/hc/en-us/articles/215912768-Managing-floating-IP-addresses-using-the-OpenStack-CLI