This tutorial shows how to connect guest OS - Solaris 2.6 installed into Qemu image to the real world.
Depending how Qemu is configured, Qemu image can be started either in NAT or bridged mode.
When no network parameter is specified for Qemu to start, the default NAT mode is used. In this mode Qemu image acts as a virtual router with its own DHCP server. DHCP server assigns IP address 10.0.2.15/24 to the Ethernet interface presented in guest OS (Solaris). Packets destined outside subnet 10.0.2.x/24 are forwarded to to the default gateway IP address 10.0.2.2/24.
NAT is good enough for connection initialized from guest OS to the outside world. For instance, if it was ssh installed on guest OS we could copy files with scp command. Unfortunately, ssh is not installed on Solaris 2.6 by default. Other protocols such as FTP or NFS may not be working in NAT mode. For this reason we are not going to use this method.
The second method is based on bridging an Ethernet interface of host (Fedora 15) with a virtual tap interface. Firstly, the virtual tap interface must be created in Fedora before actual bridging. Then both interfaces - Ethernet and tap interface presented in Fedora may be added to the bridge interfaces thus to be bridged together. As a last step, Qemu has to be said to start with configuration that bridges the virtual tap interface and the guest Ethernet interfaces together.
Connected via bridge, the guest and host OS can have their IP addresses from the same subnet. Benefit of the solution is obvious - no incoming connection is blocked by NAT thus file transfer protocol such as FTP is supposed to be working.
First, I was thinking about to describe the exact steps of bridging Qemu image with Ethernet interface. Then I decided not to do it as they are many tutorial describing the same topic on the Internet.
Instead of it I provide an installation script that installs necessary rpm packages, create a bridge an bridge chosen Ethernet with tap interface. Finally, it restores network connection. Always run this script before start Qemu VM. The script is available here.
echo -e "nChecking if bridge interface is presented"
bridge=`ifconfig -a | grep br | cut -d " " -f1`
if [ "$bridge" == "" ]; then
echo "No bridge interface was found"
echo -e "Checking if package 'bridge-utils' is installed"
if [ `rpm -qa | grep bridge-utils` ]; then
echo -e "Package 'bridge-utils' is installed, nothing to do"
echo -e "No package 'bridge-utils' was found, trying to install it"
sudo yum install bridge-utils -y
sudo /usr/sbin/brctl addbr virbr0
echo -e "Interface $bridge was created"
echo "Interface $bridge is presented, nothing to do"
sudo /sbin/ifconfig $bridge up
echo -e "nChecking if a virtual tap interface is presented"
tap=`ifconfig -a | grep tap | cut -d " " -f1`
if [ "$tap" == "" ]; then
echo "No tap interface was found"
echo "Checking if 'tunctl' package is installed"
if [ `rpm -qa | grep tunctl` ]; then
echo "Package 'tunctl' is installed, nothing to do"
echo "No package 'tunctl' was found, trying to install it"
sudo yum install tunctl -y
echo -e "Checking if module 'tun' is loaded in kernel"
check=`lsmod | grep tun | cut -d " " -f1`
if [ "$check" == "" ]; then
echo "Module 'tun' is not loaded, trying to load it"
sudo modprobe tun
echo "Module 'tun' is loaded, nothing to do"
sudo /usr/sbin/tunctl -u $(whoami) -t tap0
echo "Interface $tap was created"
echo "Interface $tap is presented, nothing to do"
sudo /sbin/ifconfig $tap up
echo "Checking if $tap is presented in the bridge $bridge"
check=`/usr/sbin/brctl show $bridge | grep $tap`
if [ "$check" == "" ]; then
sudo /usr/sbin/brctl addif $bridge $tap
echo "Interface $tap was added to $bridge"
echo "Interface $tap is presented in $bridge, nothing to do"
echo -e "nChecking if Ethernet interface is presented"
interface_list=`ifconfig -a | grep Ethernet | cut -d " " -f1`
if [ "$interface_list" != "" ]; then
echo -e "nThe following Ethernet interfaces were found"
echo -e "n$interface_list"
while [ $a == 0 ]; do
echo -n -e "nPlease, enter the interface name and press [ENTER]: "
b=`echo $interface_list | grep $interface`
if [ "$b" == "" ]; then
echo "Interface $interface cannot be found, try again"
echo -e "nChecking if interface $interface is presented in $bridge"
check=`/usr/sbin/brctl show $bridge | grep $interface`
if [ "$check" == "" ]; then
sudo /usr/sbin/brctl addif $bridge $interface
echo "Interface $interface was added to $bridge"
echo "Interface $interface is presented in $bridge, nothing to do"
echo "No Ethernet interfaces were found, script exits"
echo -e "nSwitching off Ethernet filtering"
for file in /proc/sys/net/bridge/bridge*
echo 0 | sudo tee $file > /dev/null
echo "Ethernet filtering was switched off"
echo -e "nTrying to restore your network connectivity"
ip=`ip addr show $interface | grep -w inet | cut -d "t" -f2 | cut -d "b" -f1`
default=`ip route | grep default | cut -d " " -f3`
if [ "$ip" == "" ]; then
echo "No valid IP address is configured on interface $interface"
echo "Sorry, your network connection cannot be restored"
sudo ifconfig $bridge $ip up
sudo ifconfig $interface 0.0.0.0 up
sudo route add default gw $default
echo -e "nNote:"
echo "IP address $ip was configured on interface $bridge"
echo "IP address 0.0.0.0 was configured on interface $interface"
echo "Default gateway address $default was restored"
Note: You must assign run privileges to the script. Also be aware that script needs to be either started under root account or sudo user must be configured.
$ chmod +x ./bridge_interfaces
Finnaly, we can start Qemu.
$ /usr/local/bin/qemu-system-sparc -bios /usr/local/share/qemu/ss5-170.bin -M SS-5
-nographic -boot c -hda ./36G.disk -m 256 -serial telnet:0.0.0.0:3000,server
-net nic,vlan=0,macaddr=00:aa:00:60:00:01,model=lance -net tap,vlan=0,ifname=tap0,script=no
Now, telnet to the Qemu and start Solaris with boot disk0 -v command. After Solaris is booted, check if connection is working. You should be able to ping at least a bridge interface.
$ telnet localhost 3000
Here is a nice tutorial about bridging. It shows sudo configuration in detail and a Qemu start up script for the Ethernet interface.