David Byng
David Byng

Reputation: 21

XEN VM networking, public IP binding

I need some information about routing public IP addresses assigned to the hypervisor into a VM.

I have installed XEN hypervisor on Centos 6.5, I have one NIC with IP 80.86.84.34 & Mask:255.255.255.0 I have an additional IP 85.25.14.195 & Mask: 255.255.255.255

Dom0 has eth0 & virbr0 with a virtual dhcp, the VM has address 192.168.122.4 & Mask:255.255.255.0 the VM has working outbound internet connection.

How do I correctly set dom0 to route connections for 85.25.14.195 into the VM?

Many thanks for your help and apologies if this is a basic question that has been answered before, please point me in the right direction.

First EDIT

I have managed to route the public IP by adding the below route in Dom0, DomU now correctly responds to packets received by Dom0 for the public IP forwarded over virbr0.

route add -net 85.25.14.195 gw 192.168.122.1 netmask 255.255.255.255

My follow up question is what rule is required in IP tables to allow traffic? As currently it is blocked when the firewall is running.

Second EDIT

OK, so I figured out the iptables, I had to remove the REJECT line on virbr0, I also had to add the following rule to make the outbound IP from Dom0 appear correctly:

-A POSTROUTING -s 192.168.122.2 -p tcp -j SNAT --to 85.25.14.195

Upvotes: 2

Views: 1555

Answers (1)

Rushikesh J
Rushikesh J

Reputation: 705

You should be able to assign 85.25.14.195 as alias IP on virbr0 ( may be virbr0:1 ) and do simple IP Nat or forwarding. You need to do # sysctl -w net.ipv4.ip_forward=1 to be able to forward traffic coming on Public IP to internal Private IP.

Upvotes: 1

Related Questions