How to add two static IPs for a Xen VM?

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

asked Sep 18, 2016 by anonymous

1 Answer

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.

answered Sep 20, 2016 by Eric Z Ma (44,280 points)

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.

commented Sep 20, 2016 by nshah14285 (100 points)
edited Sep 27, 2016 by nshah14285

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.

commented Sep 20, 2016 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Related questions

0 answers
1 answer
asked Oct 2, 2014 by Eric Z Ma (44,280 points)
1 answer
1 answer
asked Jan 20, 2013 by forum (2,150 points)
1 answer
asked Sep 29, 2016 by harryxiyou (5,830 points)
Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...