Test openwrt under qemu-system-x86

I have ar9331 wifi module, It is better to emulate openwrt on QEMU, and learn it under x86, then try ar9331.

After searching on Google, I found openwrt for x86 and qemu 2.5.0.

QEMU-all http://qemu.weilnetz.de/w32/qemu-w32-setup-20160215.exe This setup have x86,arm,mips target insided.

Openwrt-x86 https://downloads.openwrt.org/chaos_calmer/15.05/x86/generic/

Just down the “combined” version, which contain grub-bootloader and ext4 rootfs, easy for install https://downloads.openwrt.org/chaos_calmer/15.05/x86/generic/openwrt-15.05-x86-generic-combined-ext4.img.gz

Run QEMU like this:

qemu-system-i386.exe \
-vga none \
-drive file=openwrt-15.05-x86-generic-combined-ext4.img,if=none,id=openwrtdisk \
-device ich9-ahci,id=ahci \
-device ide-drive,drive=openwrtdisk,bus=ahci.0 \
-net nic,vlan=0,macaddr=52-54-00-AF-53-81,model=pcnet \
-net user,vlan=0 \
-redir tcp:10022::22 \
-redir tcp:10080::80 \
-localtime

-driver alias img file to openwrtdisk.
-device attach openwrtdisk as an IDE harddisk. select intel ahci controler.
-net nic install client netcard.
-net user install host user-mode netcard.
-redir redirect host 10022 to client 22.

Booting, login to serial vc.

Because this openwrt system want two nic, eth0 for bridge, eth1 for wan. And the machine I create in QEMU just have one nic only.
We need to modify network setting.

Open file:

vi /etc/config/network

Comment like this, and append “option type ‘dhcp'”

config interface 'lan'
#option type 'bridge'
#option proto 'static'
#option ipaddr '192.168.1.1'
#option netmask '255.255.255.0'
option type 'dhcp'

reboot, this will let linux make sure eth0 used qemu’s DHCP server.

Install some packages


passwd #change your root password
opkg update
opkg install openssh-client
opkg install openssh-server
opkg install luci
/etc/init.d/sshd enable
/etc/init.d/sshd start

Open file:

vi /etc/ssh/sshd_config

Append this:

PermitRootLogin yes

So you car open a browser on host, type “127.0.0.1:10080”, have fun

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

This entry was posted in Memo and tagged , . Bookmark the permalink.