# KVM Network Bridge (starting tuntap device)

## zolom

Hi all,

I'm trying to get a Windows VM set up in KVM/QEMU under Gentoo for gaming. I thought getting the VGA passthrough working would be the hard part but instead I'm having trouble with the network bridge! I don't think there's anything seriously wrong here, I'm sure I'm just missing a step. 

I'm not sure how the tun device is supposed to be created through rc. From rc.log: 

```

 * Bringing up interface br0

 *   Creating bridge br0 ...

set hello timer failed: Numerical result out of range

 *   Adding ports to br0

 *     enp3s0 ...

 [ ok ]

 *     tap0 ...

 *     Cannot add non-existent interface tap0 to br0

```

If I run "tunctl -t tap0" and reset the br0 service after the computer starts then everything works great (so far I have not planned past running the VM as root). I can think of a few things to try to make tunctl happen before it tries to start br0, but I know that everything I'm thinking of is the Wrong Way so I thought I'd come here to see if anyone knew the Right Way.

Thanks for any help! 

My /etc/conf.d/net:

```

config_enp3s0="null" 

bridge_br0="enp3s0 tap0"

config_br0="dhcp" 

brctl_br0="setfd 0

             sethello 30

             stp off"

config_tap0="null"

tuntap_tap0="tap"
```

----------

## Hu

You told openrc not to configure tap0, so it did not configure it.  You should tell openrc how to configure the interface, so that it can prepare it before adding it to the bridge.

```
config_tap0="192.168.0.1 netmask 255.255.255.0"

mac_tap0="52:54:00:00:00:01"

modules_tap0='iproute2 !plug'

tuntap_tap0='tap'

tunctl_tap0='-u kvmuser'
```

----------

## AngelKnight

 *zolom wrote:*   

> I'm not sure how the tun device is supposed to be created through rc. From rc.log: 
> 
> ```
> 
>  * Bringing up interface br0
> ...

 

That bit looks bad.  It looks a lot like rc was failing to set up your bridge device for this reason.

With the option "stp off", you're turning Spanning Tree off anyway.  Remove the "setfd 0" line

 *zolom wrote:*   

> My /etc/conf.d/net:
> 
> ```
> 
> config_enp3s0="null" 
> ...

 

----------

## zolom

AngelKnight,

I removed the setfd line as you suggested and it removed the out of range error.

Hu,

I gave your changes a shot but I'm still getting the same in rc.log:

```
 *     tap0 ...

 *     Cannot add non-existent interface tap0 to br0

 
```

The settings did decrease the amount of time it takes to get a dhcp lease when I bring the bridge up after booting. I based my /etc/conf.d/net off of these two sources:

http://www.linux-kvm.org/page/KvmOnGentoo

https://forums.gentoo.org/viewtopic-t-918390-start-0.html

What I want to do is write an init script to run tunctl before it tries to bring up the bridge, but I feel that this must be achievable through configuring /etc/conf.d/net correctly. 

My current /etc/conf.d/net:

```
config_enp3s0="null" 

bridge_br0="enp3s0 tap0"

config_br0="dhcp" 

brctl_br0=" sethello 30

            stp off"

config_tap0="192.168.0.1 netmask 255.255.255.0"

mac_tap0="52:54:00:00:00:01" 

tuntap_tap0="tap"

tunctl_tap0="-u zolom"

modules_tap0='iproute2 !plug'

```

----------

## Hu

What happens when you run /etc/init.d/net.tap0 start?

----------

## zolom

Ah-ha! That's where I misunderstood. I hadn't seen anything about adding net.tap0 so I didn't. Because you are supposed to remove net.eth0 from rc and because eth0 and tap0 were supposed to be "null" in /etc/conf.d/net, I presumed that you wouldn't make an init script for tap0. That was pretty dumb! 

It also wanted to start net.br0 first so I had to tack net.tap0 into the boot section instead of the default section.

Thanks for the help!

----------

## Hu

The bridge_br0 declaration should have caused it to start the tap device before starting the bridge.  However, as you discovered, you must have a net.tap0 initscript.

----------

