Ask Your Question

Revision history [back]

map VM floating IP to outside IP, to access VM instance.

  • I have the following single host Openstack RDO and everything works fine.
  • I can connect from any host in the network to both CLI and Horizon.
  • Created a VM inside Openstack and assigned a floating IP, which works as expected.

    image description

    openstack server list

+--------------------------------------+---------+--------+-------------------------------+------------+ | ID
| Name | Status | Networks
| Image Name | +--------------------------------------+---------+--------+-------------------------------+------------+ | 0b1f4d14-3a20-4585-9614-3c7fc96005ca | cirros1 | ACTIVE | net11=11.0.0.11, 172.24.4.235 | cirros | +--------------------------------------+---------+--------+-------------------------------+------------+

I can access the VM from withing Openstack using the floating IP, but because the "public" IP is from 172.24.4.0/28 is not accessible from the outside network 192.168.0.0/24.

I added a couple of IP tables to map the VM floating IP (port 22) to the another IP from the outside network (192.168.0.109 port 2222)

iptables -A FORWARD -i eno16777736 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -o br-ex -s 172.24.4.235 -j SNAT --to-source 192.168.0.109
iptables -t nat -A PREROUTING -i eno16777736 -d 192.168.0.109 -p tcp --dport 2222 -j DNAT --to-destination 172.24.4.235:2222

It dosn't work !

I suspect the iptables, any help?

IP inf.

image description