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.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
To achieve this assign the public ip to
host system. Then forward the required port from
host system to
guest is a web server then you need to forward port 80 from
host to port 80 of
guest so that every request for port 80 on public ip will be forwarded to port 80 of
Suppose you have assigned public ip to eth0 and your
guest's ip is 192.168.1.2, 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.
#!/bin/sh GUEST_IP=192.168.1.2 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 $GUEST_IP:80 ### mail server iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 25 -j DNAT --to $GUEST_IP:25 iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 143 -j DNAT --to $GUEST_IP:143 iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 110 -j DNAT --to $GUEST_IP:110
The first two commands enable Nat/Masquerad'ing on
### Port Forwarding ###
Here you put as many rules as you need. This tells
host to forward certain ports to certain destination ports on certain destination IP addresses.