Running OpenWRT on qemu

These are insrtuctions to get OpenWRT running on qemu.


$ git clone git://
$ git clone git://

Copy whatever seems necessary:

$ cd openwrt
$ cp -a ../packages/utils/strace \
$ cp -a ../packages/utils/valgrind \

Configure and build OpenWRT

If you have your own packages for OpenWRT, you may now put them under package/ before running the following command.

$ make menuconfig

choose to build for malta; in “Target images” -> “Root filesystem images”, choose ext4. configure packages

$ make target/linux/clean world

The above command will build a full OpenWRT image with TinyScheme and any other language you selected in menuconfig included.

$ cp bin/malta/openwrt-malta-le-vmlinux.elf \
$ cp bin/malta/openwrt-malta-le-root.ext4 \

See if it works:

$ qemu-system-mipsel -kernel my-openwrt-image.elf M malta \
                     -hda openwrt-malta-le-root.ext4 \
                     -append "root=/dev/sda console=ttyS0" \

Connect from inside OpenWRT to outside only

The following will give you a 10.0.*.* IP:

# udhcpc -i br-lan

The host is, you can ping,

# ping

or log in, transfer files, etc.

# ssh

Set up bridge

Make sure network bridging is compiled into the host kernel.

# ifdown eth0

edit: /etc/network/interfaces

from: auto eth0 iface eth0 inet blah (eth0 config here)

to: auto br1 iface br1 inet blah (eth0 config here) bridge_ports eth0

# ifup br1

Start qemu giving the target a network interface:

$ qemu-system-mipsel -kernel my-openwrt-image.elf -net nic -net tap -nographic

If the router can’t reach the host, see if there’s an interface configured with an IP. If not:

edit: /etc/config/network remove IP and netmask, switch from static to dhcp or use an IP in the same subnet of your host…

If you have chosen to get an IP via DHCP:

# ifup lan
# ifconfig

(It should have picked an IP from your DHCP server)