Menu Close

Simple NAT configuration with Xen Hypervisor Guest

A simple NAT configuration that can be used to access host network/internet from Xen DomU.

This example used ubuntu DomU and static configuration is used to assign IP address to DomU.

Dom0 Configuration

Enable IP forward

sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1

#Apply sysctl.conf
sudo sysctl -p

Setup IP Tables for Forwarding

iptables -t nat -A POSTROUTING -o eth0 -s 192.168.100.0/24 -j MASQUERADE

DomU Guest Configuration

vif = [ 'script=vif-nat, ip=192.168.100.10' ]

Assign static IP address to DomU

sudo ip addr add 192.168.100.10/24 dev eth0

Setup Routing Information on DomU

sudo ip route add default dev eth0

Add DNS resolve information on DomU

sudo vi /etc/resolv.conf
nameserver 8.8.4.4
nameserver 8.8.8.8