How to add two static IPs for a Xen VM?

Posted on In QA

Hello,

I have installed Xen4Centos on Centos7, having single NIC card with bridge network and have two VMs on that.

In one VM, I want to add two static IP one for webserver and one for mail server.

So I have created IP alias in guest VM, it was created but it was not pinging from outside public network or from the host.

So if you have any idea how to add second IP in the guest VM then please let me know.

I have searched on Google but most of the tutorials had given example for one IP only.

Nishit

For bridged network in Xen, it should be good to set 2 IPs on the NIC for the VM.

In the VM configuration file, first make sure the vif has no IP specified. A good one is like

vif=['bridge=xenbr0']

Inside of the VM, you can configure 2 IPs for one NIC following your VM OS’ instructions.


Thank You so much for posting this issue and replying to my comment.

Finally, I have figure out the way to listen the second IP from public network.

I have added second interface in the VM configuration file with MAC address, so inside VM it looks like eth0 and eth1.

Then I have created a routing table for eth1 and added default gateway and rule to eth1 table
[ ip route add default via XXX.XX.XXX.112 dev eth1 table eth1 ]
[ ip rule add from XXX.XX.XXX.112 table eth1 ]

So doing this way second IP in VM was reachable from public network.


Great to know you have resolved the problem!

You method of using an additional interface sounds a nice one too.

For traffic that you would like to route to eth0, you may need to create some specific routing rules.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *