[libvirt-users] public IP for VM

Daniel Romero romero.cl at gmail.com
Thu Dec 7 16:30:21 UTC 2017


Hi Chandler,

since host and guest are in the same network they can't have the same IP.

On the host, try to create a virtual network (using virsh or config files)
attached to the bridge, then set up eth0 with the primary IP and add it to
the bridge. After that set up the guest VM with an interface attached to
the virtual network using the secondary IP. At this moment you should have
access to both machines using their own IP.

If you want to use multiple IPs on the same NIC, you have to use aliases to
setup eth0 without IP, and eth0:0 and eth0:1 with the primary and secondary
IPs, but I don't see where this can help to your use case.

Supposing you want to have two web servers (I don't understand what you
want to achieve exactly), for load balancing or failover, you should set up
a different environment like:

- 1 main server in charge of virtualization (host), connected to the public
network (lets use eth0 for that), but not necesarily with a public IP, with
a virtual network connected to the public network (virtual network attached
to a bridge that contains eth0), and a private virtual network.
- 1 VM for the primary web server connected to the private virtual network
- 1 VM for the secondary web server connected to the private virtual network
- 1 VM running a load balancer connected to the private and public virtual
networks. This VM accept requests on the public interface and then forward
it to primary or secondary server following your rules. (this role could
also be played by primary web server, but I like to keep it apart)

this way you can have a single web server (for users it will look like
this) with a single IP that forward requests to one or multiple webservers
that are only visible in the private network, so also is a little more
secure.

hope it helps.

Atte.
Daniel Romero P.


On Thu, Dec 7, 2017 at 2:36 AM, Chandler <admin at genome.arizona.edu> wrote:

> I can't seem to figure out how to setup a public IP for the VM so we could
> use it as a second public webserver.  The host machine runs our primary
> webserver with CentOS 6.9 and one public ipv4 address configured on
> physical interface eth0.  Now i have configured a new bridge interface br0:
> DEVICE=br0
> TYPE=Bridge
> BOOTPROTO=static
>
> The IP settings are for a second public ipv4 address in the same network.
> Now i setup the VM to use br0 for the NIC and set the same IP settings
> inside the VM... but it doesn't work.  The VM can't resolve any hosts, and
> if i try to ssh to the second public IP, it just sends me to the host
> machine instead of the VM.  I read the Bridged Networking section but it
> seems to want to set br0 to the public IP and not use eth0.  I want to use
> two public IP's over the same shared phys interface, eth0 with our first IP
> and br0 with the second IP for the VM... or another similar configuration
> that will have the same effect.
> Thanks
>
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20171207/cf8a02db/attachment.htm>


More information about the libvirt-users mailing list