NEmu

Network Emulator for Mobile Universes

Documentation - Real Network (VSlirp)

A Slirp is a particular virtual point-to-point link which enables a virtual node to communicate with the real world, i.e. the physical host and Internet through a NATed system. Slirp link already contains internal DHCP and DNS servers.

VSlirp(name, net, restrict, forwards)

A Slirp can be used and manipulated as a standard VLink.
name is the name of the virtual link.
net is the network address managed by the Slirp (default: 192.168.0.0/24).
restrict is a boolean which enables/disables the virtual node isolation from the external world. If this flag is activated, only forward rules will be authorized (default: False).
forwards is a list of Forward elements (default: empty list).

Forward(host, guest, proto)

Enables a port forwarding between the physical machine to a virtual node linked to a Slirp.
host is the {ip address}:port on the physical host.
guest is the {ip address}:port on the virtual node.
proto is the protocole of the Slirp port forwarding, i.e. udp or tcp (default: tcp).

Here an example of use of NEmu configuration:

InitNemu()

VHost("alice", hds=[VFs('debian.img', type='cow')]
             , nics=[VNic(hw="0a:55:78:32:e5:7f")])

VSlirp("slirp", net='192.160.0.0/24
              , forwards=[Forward(host=2222, guest=22)])

SetIface("slirp")

Link('alice', 'slirp')

And, here is the result inside the virtual machine:

root\@alice# dhclient eth0
root\@alice# ifconfig eth0 |head -n 2
eth0      Link encap:Ethernet  HWaddr 0a:55:78:32:e5:7f 
          inet adr:192.168.0.15  Bcast:192.168.0.255 
root\@alice# ls
root\@alice# wget --quiet www.google.fr
root\@alice# ls
index.html
root\@alice# /usr/sbin/services sshd start

You can now access to the virtual machine from the real physical host:

$ ssh -p 2222 root\@127.0.0.1
root\@alice#

Please note that a VSlirp can never be placed as a client in the Link function. Also, it can only be linked with a VNode.