Wbm2009v2/VirtualizingOpenWRT
Parent: Wbm2009v2
[edit] User Mode Linux
(Note: Another way to do simulations using QEMU and vde_switch is described here: [1] )
[edit] Building and installing
You can easily build an openwrt image for UML, this creates the executable openwrt-uml-vmlinux (uml-kernel) and openwrt-uml-ext2.img, the filesystem. Running this is easy, you have to install uml-utilities:
$ sudo apt-get install uml-utilities
Start it up using:
$ ./openwrt-uml-vmlinux ubd0=openwrt-uml-ext2.img con=null ssl=null ssl0=fd:0,fd:1 con0=null,fd:2 init=/etc/preinit
This is easy but won't give you network connectivity (not in between uml instances, nor with the host machine...
[edit] Network configuration
- add the user under which you start the uml-instances to the uml-net group
- add a tap interface in /etc/network/interfaces (ubuntu/debian) + some added wizardry to startup the uml-switch (a switch interconnecting our uml-instances)
auto tap0
iface tap0 inet static
address 192.168.1.254
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
tunctl_user uml-net
up iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE ||:
down iptables -t nat -D POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE ||:
up start-stop-daemon --start --pidfile /var/run/tap0.pid --make-pidfile --background --chuid uml-net --exec /usr/bin/uml_switch -- -tap tap0 -unix /tmp/tap0.ctl && chmod g+w /tmp/tap0.ctl || :
down start-stop-daemon --stop --quiet --pidfile /var/run/tap0.pid --oknodo --exec /usr/bin/uml_switch && rm /tmp/tap0.ctl || :
- add your user-id to the group uml-net in /etc/group
- chmod the /tmp/tap0.ctl socket to be world writable (or at least for the user starting up the uml instances)
- now startup the openwrt uml instance -- but with the added parameter defining eth0 - connecting to the uml_switch (over the socket /tmp/tap0.ctl -- which is also used in our tap0 description above...)
./openwrt-uml-vmlinux ubd0=openwrt-uml-ext2.img con=null ssl=null ssl0=fd:0,fd:1 con0=null,fd:2 init=/etc/preinit eth0=daemon,,,/tmp/tap0.ctl
i (ptr_) had quite some issues to get connectivity over this virtual uml_switch... seems to boil down to the bridge settings -- one solution is to disable the br-lan bridge (the openwrt instance, nor tap0 on the host, did respond to ARP requests) another (easier) is to create a new interface, starting up you uml instance, not using eth0, but to create a eth1 virtual interface
./openwrt-uml-vmlinux ubd0=openwrt-uml-ext2.img con=null ssl=null ssl0=fd:0,fd:1 con0=null,fd:2 init=/etc/preinit eth1=daemon,,,/tmp/tap0.ctl
configure eth1 the usual way
ifconfig eth1 192.168.2.2 up
and you're ready to roll