# qemu network tun interface

## Gotterdammerung

Hi, there!

I am trying to run qemu with network interface. For that I must load tun/tap interface, i.e., eth0 bridged. 

I have tun loaded, but something is not right. Please help!

```
claudio[downloads]$ qemu -boot d -cdrom arch-0.7.2-ftp.iso -m 256 -nics 1 -n /etc/qemu-ifup meu.hd

Connected to host network interface: tun0

Executing /etc/qemu-ifup

Bringing up tun0 for bridged mode...

Adding tun0 to br0...

interface tun0 does not exist!
```

```
claudio[downloads]$ ls -l /dev/net/tun /dev/tun0

crw-rw---- 1 root wheel 10, 200 2006-09-24 10:43 /dev/net/tun

lrwxrwxrwx 1 root root        7 2006-09-24 10:44 /dev/tun0 -> net/tun
```

```
claudio[downloads]$ cat /etc/qemu-ifup

#!/bin/sh

echo "Executing /etc/qemu-ifup"

echo "Bringing up $1 for bridged mode..."

sudo /sbin/ifconfig $1 0.0.0.0 promisc up

echo "Adding $1 to br0..."

sudo /sbin/brctl addif br0 $1

sleep 2
```

----------

## skunk

install qemu 0.8.2 you'll find networking a lot easier to configure.

----------

## Gotterdammerung

 *skunk wrote:*   

> install qemu 0.8.2 you'll find networking a lot easier to configure.

 

Would you mind to send me an example of how I can achieve this? Please.   :Very Happy: 

----------

## skunk

just start qemu with your disk image and you'll get networking working automagically (on my system 10.0.2.2 is the gateway for accessing the net and any service started on the host os).

if you need a samba share specify the -smb <path> option.

----------

## nutznboltz

When using user mode networking with QEMU the QEMU emulator presents a fake firewall, DHCP, DNS and SMB server at  IP addresses the host OS can reach.

```
Qemu Virtual Machine    <------>  Firewall/DHCP server <-----> Internet

     (10.0.2.x)            |          (10.0.2.2)

                           |     

                           ---->  DNS server (10.0.2.3)

                           |

                           ---->  SMB server (10.0.2.4)
```

----------

## dspgen

I've looked around a lot trying to get this to work, and I still can not ping anything (the host 192.168.0.4, or anything else on the lan 192.168.0.7, etc).

I am using 

2.6.18-gentoo-r1

app-emulation/qemu-user-0.8.0

app-emulation/kqemu-1.3.0_pre9

app-emulation/qemu-softmmu-0.8.1-r1

app-emulation/qemu-user-0.8.1

app-emulation/qemu-0.8.1

I started qemu with:

qemu -localtime -cdrom dsl-3.1RC3.iso -boot d -m 256

inside qemu it does create a nic (10.0.2.15), and I can ping it's gateway (10.0.2.2), but thats it.

I have also tried gentoo and winxp clients, network doesn't work on them either.

 :Confused: 

Oh, I guess I'll give 0.8.2 a try   :Embarassed: 

----------

## dspgen

Ok, now I remember why I was on 0.8.1 - GCC 4!

Argh.

I followed the http://gentoo-wiki.com/HOWTO:_Qemu, but that installed 0.8.1.

I am now following the GCC 3 way, and will see how that goes.

----------

## dspgen

Ok, it still doesn't work.

Any ideas on how to diagnose the problem? tcpdump helpful?

----------

## dspgen

 :Smile:   :Evil or Very Mad: 

http works fine to my lan and the internet.  Ping doesn't work to anywhere.

I guess ping is a poor choice when testing for basic network functionality.

----------

## Gotterdammerung

The latest version of qemu has network running just fine. Have you tried it?

----------

## dspgen

I am (now) running 0.8.2, and it works great except for ping.  

That is why I said ping must be a bad choice when testing for basic network functionality.

for the record, I saved all the relevant files (AUTOEXEC.BAT CONFIG.SYS "Documents and Settings" IO.SYS MSDOS.SYS NTDETECT.COM "Program Files" WIN2K boot.ini ntldr) off of the C drive on my Windows 2000 Server.

I installed gentoo (this was the last hold-out in my microsoft purge!!!!) and qemu.  I started a Window XP install to get the boot sector , then copied those WIN2K files to it, and it runs fine.

I start it with this:

qemu -localtime -soundhw es1370 -hda 2kserv.img -m 256 -cdrom 2kcd.iso

mount the .img file with

mount -o loop,offset=32256 -t vfat 2kserv.img 2kmount

My only problem now is C is a 2G fat partition.  I'd like it to be a 4G fat32.

How do I 

create a new .img file : dd if=/dev/zero of=disk.img bs=1M count=4096 or qemu-img create disk.img 4G

make a partition :  fdisk disk.img ????

format it fat32 : mkfs.vfat ??

put the boot sector on it :  dd if=2kserv.img of=disk.img bs=32255 count=1 ??

----------

