# Assign public IP to instances

Hi all,

I have a server with a public IP that is running Devstack (Pike release). Also, i have available a range of public IPs. What i'm trying to do is assign a public IP to each instance, so i can access them from anywhere. However, i'm having a hard time doing this.

I've been following two approaches:

1. Edit local.conf file

From this https://docs.openstack.org/devstack/latest/networking.html#shared-guest-interface (guide) i've added the following parameters to my local.conf:

[[local|localrc]]
PUBLIC_INTERFACE=eth0
HOST_IP=10.42.0.52
FLOATING_RANGE=10.42.0.52/24
PUBLIC_NETWORK_GATEWAY=10.42.0.1
Q_FLOATING_ALLOCATION_POOL=start=10.42.0.250,end=10.42.0.254


Where:

• HOST_IP is the public IP used to access the server and where devstack is running.
• FLOATING_RANGE is the range of public IPs i have available.
• PUBLIC_NETWORK_GATEWAY it's my public gateway.

But when i run this configuration, my public interface receives another IP (something like 172.x.y.z) and i lose the connection to the server.

2.Creating another network manually:

I have followed these steps:

• Creating the network: network type local, checked admin state and external network.
• Creating the subnet: manually typed the public CIDR (x.y.z.192/26) and my public gateway. In the subnet details, i've added the public IP range (x.y.z.201, x.y.z.250) and set DNS.
• To create the router i've assigned it to my previously created network.
• Created security groups for ICMP and SSH.
• Instantiate a cirros image with the following command:

openstack server create --flavor d1 --image cirros-0.3.5-x86_64-disk --network ext-network --security-group default --security-group ssh --security-group icmp cirros

However, i get the following error: No sql_connection parameter is established. But i can instantiate this cirros image with the same command in another network (e.g. net0).

Would anyone have any idea how to do this setup?

edit retag close merge delete

The External network Should be created for Assigning Public IP to Instances,

To get a Detailed idea for this, post your Exact Requirement

( 2018-09-21 02:30:59 -0500 )edit

Sort by » oldest newest most voted

You need an external network whose subnet includes those IP addresses. Your instances are connected to virtual networks that are routed to the external network. Then you can associate floating IP addresses to the instances.

To get more specific help, explain how you created the external network and its subnet(s), how the instances are connected, how you associate floating IPs and what doesn’t work.

EDIT Sep 22 AFTER YOU UPDATED THE QUESTION

I have never attempted to map Devstack's external network to the physical network, but let me raise a few points I find noteworthy.

my public interface receives another IP (something like 172.x.y.z) and i lose the connection to the server

This is strange. A default Devstack setup uses 172.24.4.0/24 for external networks that are simulated inside the server. Since you mapped the external network to the outside world, where does this range come from?

What I don't understand either - if you lose connection, and your external interface has this address, how can you connect?

Creating the network: network type local

local means that the network is created inside your server. This doesn't make sense in your case. To create a Neutron network that maps to the physical network, use flat instead.

Also, by default Devstack provisions an external network named public. You should not have to do that manually.

However, i get the following error: No sql_connection parameter is established

When you google this error, you will find an unresolved bug. Consider using a more recent Devstack version than Pike.

Also, by default, only an admin can connect instances to the external network, even though the error message should be different. Perhaps it's related to the local network type.

But i can instantiate this cirros image with the same command in another network (e.g. net0).

I guess that net0 is a tenant network, i.e. a virtual network created and managed by Neutron and possibly connected to the external network by a router. Correct? Since external networks and tenant networks are different, it's not surprising that you only see the problem in one case and not in the other.

Normally, people set up their Devstack in a virtual machine. If you did that, you should have no problem adding a NIC and using the instructions for a dedicated guest interface. That's probably simpler (but remember, I have no experience with this setup).

more

Hi Bernd, thank you for your quick response. I've update my original question with more information. My problem is how exactly should i configure the external network.

( 2018-09-21 10:56:08 -0500 )edit

Please start posting anonymously - your entry will be published after you log in or create a new account.