Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible for both Xen host and Xen guest to share same IP (albeit with different ports)?

We have a single public IP, and want to have both the Xen host (as host only, no other role) and the Xen guest, to use it.


share|improve this question
If you explain what exactly you want to achieve, then we might help you to achieve it. – Sachin Divekar Nov 28 '11 at 21:01
Tried to clarify better. – SyRenity Nov 28 '11 at 21:28
I have answered how you can achieve it. – Sachin Divekar Nov 28 '11 at 21:54
up vote 3 down vote accepted

To achieve this assign the public ip to host system. Then forward the required port from host system to guest system.

Suppose your guest is a web server then you need to forward port 80 from host system to port 80 of guest system so that every request for port 80 on public ip will be forwarded to port 80 of the guest.

Suppose you have assigned public ip to eth0 and your guest's ip is, then you have to tell host that it should do NAT/MASQUERADE so that the virtual machines have internet access. You also have to tell host which ports it should forward to which IP address. You can refer following script.


echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

### Port Forwarding ###

### web server 
iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 80 -j DNAT --to

### mail server 
iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 25 -j DNAT --to
iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 143 -j DNAT --to
iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 110 -j DNAT --to

The first two commands enable Nat/Masquerad'ing on host. In the section after ### Port Forwarding ### you put as many rules as you need. This tells host to forward certain ports to certain destination ports on certain destination IP addresses.

share|improve this answer

You should think about the virtualized machine as about real machine. You shouldn't have two machines with the same IP in your network. But you may use some bridge, NAT, port forwarding, if your goal is to hide the presence of virtualized environment.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.