Allocate released floating IP in openstack - openstack

How do I allocate Floating IP to a tenant after the tenant releases it from the project in openstack?
Suppose I want IP 10.10.90.95, how can I add this specific IP to my pool available list?

To claim a specific floating-ip for a tenant, you can run the following neutron command. Note that this will succeed only if that IP address is not already claimed by some other tenant:
neutron floatingip-create --floating-ip-address 10.10.90.95 ext-net
Above assumes that your external network is named "ext-net" and the IP address you are trying to allocate is 10.10.90.95.

Once floating IP is released, it gets automatically added to the available floating ip pool.
Use:
nova floating-ip-associate < instance-id > < floating-ip >
to associate specific floating-ip to the instance.

Related

Connect to OpenStack instance via the internet through the router

I've recently found out that the external network for our OpenStack (Ocata) setup has maxed out on the available IP addresses in its allocation table. In fact, it has over-allocated with -9 free IPs. So, to manage the limited IP addresses, is it possible to access an instance in a project directly from an external network (internet) via the project's router? This way only a single IP address needs to be allocated per project instead of allocating to multiple instances per project.
The short answer would be NO, but there are couple of workarounds that came to my mind (not that they will be good, but they will work).
In case any instance in your private network has floatingIP, you can use that host as a jump-host (bastion-host) to SSH into the target host. This also brings the benefits of port forwarding/SSH tunneling to the table if you want to access to some other port.
You can always access to any host on private networks through qdhcp or qrouter namespace from the network node
ip netns exec qdhcp-XXXXXXX ssh user#internal-IP

OpenStack neutron subnet - create port with ip address after network address

I have this neutron private subnet 10.200.206.0/23
when I created a port using this subnet, it should give me 10.200.206.1 as I expected since nobody uses this .1 ip yet.
Instead it gave me 10.200.206.20
Note this subnet had been used previously and deleted all ports/ip that used by other instances. I am 100% that this ip 10.200.206.1 is not in-used.
DHCP is disabled.
Can we actually reset the old info from this subnet in OpenStack DB backend?
Once you start using a subnet, Neutron DB will keep track of used IP addresses and doesn't reassign until all the addresses are used once.
Easiest way to reset is to remove the subnet and recreate it again.

Openstack - how to assign floating IP pool to specific tenant

In OpenStack (regardless of particular release/version), can you assign a specific floating IP pool to specific tenants? i.e. Pool 1 gets used by Tenant 1 and Pool 2 gets used by Tenant 2?
I need a way to distinguish clients from on a network layer.
You can check the command nova floating-ip-associate or if you are using Neutron, try the following:
Select a floating IP address for the new VM instance to use.
Use the neutron floatingip-list command to display floating IP addresses for the tenant you chose in Step 1. If necessary, use the neutron floatingip-create command to create a floating IP address for this tenant. Note the ID of the floating IP address.
Associate the floating IP address with the new VM instance.
Use the neutron floatingip-associate command to associate the floating IP address from Step 6 with the new VM instance.
http://docs.oracle.com/cd/E36784_01/html/E54155/clicreatevm.html
You can check Openstack docs, it explained there just share with the exact command line. But be careful when associate by command line by practice I find its better to de associate by command line.

Bluemix: Cannot create VM with public IP

When I try to create a VM with a public IP address on Bluemix, I get the following error:
Your VMs are in error - Resource CREATE failed: Error: Resource CREATE
failed: Error: Resource CREATE failed: NotFound: External network
f242da31-3809-48a4-aa84-46da1c50586c is not reachable from subnet
a78fbf7e-1e4a-4d3a-a039-c05be4846bc3. Therefore, cannot associate Port
6978
Creating a VM without a public IP works, but I cannot connect to the VM without a public IP.
I also tried creating a network on the Horizon dashboard, but I could not figure out how to assign a public IPv4 or IPv6 address.
I understand that IPv4 addresses may be short in supply and would be happy with an "IPv6 only" VM, but I could not figure out how to request a "public" IPv6 prefix on Bluemix.
I have not seen that error. I think the problem you ran into may be intermittent. I just created a VM an hour ago using the Bluemix dashboard and that worked no problem. As usual, the VM was assigned two IP's, one internal and one public.
As you've discovered, in the Horizon dashboard, when you create a VM, by default it only has an internal IP. To add a public IP takes a few steps that aren't exactly obvious:
From the Cloud Management Dashboard, select the Instances tab
In the Actions column for your VM, select Associate Floating IP
In the IP Address field, select an IP address
By default, there won't be any IP addresses to select. To allocate one, press the plus (+) sign.
In the Allocate Floating IP dialog, set the Pool to Public-Network and press Allocate IP.
Now select that IP address you've just allocated.
For Port to be associated, choose the internal IP and press Associate.
Now the Instances tab will display the VM with two IP addresses.
If this doesn't work: There is a limit to how many public IPs you get, so maybe you've hit that limit. Looks like Horizon shows the limit as 10; I think that's public, but it may be public and private.
To see the list of IPs allocated to your account (and whether that list has reached 10):
From the Cloud Management Dashboard, go to the Access & Security tab.
Go to the Floating IPs sub-tab.
That shows your list of public IPs and their mapping to internal IPs. If you've reached you max, you'll need to move an IP from one VM to another. You can delete the first VM to make its IP available. Or you can disassociate the IP from one VM (don't release the IP, disassociate it) and then assign it to another VM has described above.
This screen is another place to allocate IPs to your account. The only network I see is Public-Network, and it has IPv4 addresses. I don't see any way to allocate IPv6 addresses.

How does open stack assign ip to virtual machines?

I want to know how does the openstack assign ip to virtual machines ? and how to find out port and ips used by the VM. Is it possible for us to find out the IP and ports being used by an application running inside the VM ?
To assign an IP to your VM you can use this command:
openstack floating ip create public
To associate your VM and the IP use the command below:
openstack server add floating ip your-vm-name your-ip-number
To list all the ports used by applications, ssh to your instance and run:
sudo lsof -i
Assuming you know the VM name
do the following:
On controller run
nova interface-list VM-NAME
It will give you port-id, IP-address and mac address of VM interface.
You can login to VM and run
netstat -tlnp to see which IP and ports being used by applications running inside the VM.
As to how a VM gets IP, it depends on your deployment. On a basic openstack deployment when you create a network and create a subnet under that network, you will see on the network node a dhcp namespace getting created. (do ip netns on network node). The namespace name would be qdhcp-network-id. The dnsmasq process running inside the dhcp namespace allots IPs to VM. This is just one of the many ways in which VM gets IP.
This particular End User page of the official documentation could be a good start:
"Each instance can have a private, or fixed, IP address and a public, or floating, one.
Private IP addresses are used for communication between instances, and public ones are used for communication with the outside world.
When you launch an instance, it is automatically assigned a private IP address that stays the same until you explicitly terminate the instance. Rebooting an instance has no effect on the private IP address.
A pool of floating IPs, configured by the cloud operator, is available in OpenStack Compute.
You can allocate a certain number of these to a project: The maximum number of floating IP addresses per project is defined by the quota.
You can add a floating IP address from this set to an instance of the project. Floating IP addresses can be dynamically disassociated and associated with other instances of the same project at any time.
Before you can assign a floating IP address to an instance, you first must allocate floating IPs to a project. After floating IP addresses have been allocated to the current project, you can assign them to running instances.
You can assign a floating IP address to one instance at a time."
There are of course deeper layers to look at in this section of the Admin Guide
Regarding how to find out about ports and IPs, you have two options: command line interface or API.
For example, if you are using Neutron* and want to find out the IPs or networks in use with the API:
GET v2.0/networks
And using the CLI:
$ neutron net-list
You can use similar commands for ports and subnets, however I haven't personally tested if you can get information about the application running in the VM this way.
*Check out which OpenStack release you're running. If it's an old one, chances are it's using the Compute node (Nova) for networking.

Resources