# [solved] libvirt guest same subnet as host?

## dasPaul

Hi

If finished to install my Nvidia GPU passthrough guest system with Windows10 on my gentoo host. Everthing works fine except the LAN.

I currently passthrough my pci wifi adapter to connect to my router (192.168.1.1) from Win10.

But I would like to use the network interface of the gentoo host (eth0) that is connected to the router and no nat.

I want that Win10 DHCP requests go straight to my router (through eth0) and I also dont want any filtering (thats the job of my router...)

my /etc/conf.d/net looks like that:

```
config_eth0="192.168.1.100/24"

routes_eth0="default via 192.168.1.1"

dns_servers_eth0="192.168.1.1"
```

Unfortunatley there is no such a wiki like "Gentoo and libvirt-manager".

Now I am totally confused by what I read about libvirt-manager networking options and gentoo native options.

I sometimes read I need to create a network bridge in gentoo, but then I see that virt-manager can also create a bridge.

Which one should I create, should I create both, is this totally wrong?...

Any ideas where/how I should start?

----------

## NeddySeagoon

dasPaul,

You should create a bridge in your gentoo then use virt-manager to set up the guest to connect to the bridge.

Donate eth0 to the bridge. It must not have an IP at this point, then set up the bridge, it will be br0 as the interface on your gentoo.

A bridge is the software equivalent of a network hub.

Once br0 exists, you can choose it in virt-manager for the guest NIC.

----------

## dasPaul

Ok, thanks, I looked at the wiki and there are already some issues arising:

The wiki uses two interfaces added to the bridge, so I try it with the one that I have (eth0)...

I deleted my old if:

```
/etc/init.d/net.eth0 stop

rc-update del net.eth0 default

rm /etc/init.d/net.eth0
```

created the bridge:

```
ip link add br0 type bridge 
```

added eth0 to it:

```
ip link set dev enp1s0 master br0
```

The wiki at:

 Host configuration

 OpenRC

As an example, bridge configuration with DHCP:

```
config_br0="192.168.26.199 netmask 255.255.255.0"

routes_br0="default via 192.168.26.254"
```

doesn't work, I dont see where dhcp comes into play here... If I use that config br0 gets that ip  192.168.26.199 assigned, and my eth0 gets an DHCP adress from my router, I cannot access the internet anymore on my gentoo.

I think that's not intended?

So I changed the config to this:

 /etc/conf.d/net to:

```

bridge_br0="eth0"

config_br0="dhcp"

config_eth0="null"

bridge_forward_delay_br0=0

bridge_hello_time_br0=1000
```

With that br0 now gets a ip from the router, eth0 gets a ip from the router, internet access is working again on gentoo..

Now I try to configure virt-manager...

----------

## NeddySeagoon

dasPaul,

eth0 should not have an IP address any more. 

From my KVM host. Create the bridges.

```
config_eth0="null"

config_eth1="null"

config_eth2="null"

config_eth3="null"

config_eth4="null"

bridge_br0="eth1"

bridge_br1="eth2"

bridge_br2="eth3"

bridge_br3="eth4"
```

Then do the IP assignments.

```
#for ppp0 - fake IP 

#config_br0="1.1.1.1"

config_br1="192.168.10.254/24"

config_br2="192.168.54.254/24"

config_br3="192.168.100.254/24"
```

dhcp works just as well.

```
rc-update del net.eth0 default

rm /etc/init.d/net.eth0
```

is correct but for it to auto start, you need to add net.br0 back in its place.

You will need to make the symlink.

The example you followed is just a template for a static setup.

You talk about 

```
ip link set dev enp1s0 master br0
```

So it looks like your eth0 gets renamed to enp1s0 by udev.

Either turn off the renaming or add enp1s0 to the bridge.  

Replace eth0 with enp1s0 everywhere.

----------

## dasPaul

 *NeddySeagoon wrote:*   

> 
> 
> You talk about 
> 
> ```
> ...

 

Sorry, typo, of cause I used "eth0"...   :Rolling Eyes: 

 *Quote:*   

> eth0 should not have an IP address any more. 

 

I needed a reboot, now eth0 is up without ip:

```
#ifconfig 

br0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500

        inet 192.168.1.157  netmask 255.255.255.0  broadcast 192.168.1.255

        ether 1c:1b:0d:xx:xx:xx  txqueuelen 1000  (Ethernet)

        RX packets 1101  bytes 1262930 (1.2 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 1187  bytes 154703 (151.0 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        ether 1c:1b:0d:xx:xx:xx  txqueuelen 1000  (Ethernet)

        RX packets 1531  bytes 1306790 (1.2 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 1201  bytes 155819 (152.1 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        device memory 0xef200000-ef21ffff
```

.. and everything else works so far.

I now disable dhcp on br0 and set a static ip and go over to start libvirtd service... that starts a few more services 

with errors, I'll report back   :Smile: 

----------

## dasPaul

static ip works now on br0, my /etc/conf.d/net is now:

```
bridge_br0="eth0"

config_br0="192.168.1.100/24"

routes_br0="default via 192.168.1.1"

dns_servers_br0="192.168.1.1"

config_eth0="null"

bridge_forward_delay_br0=0

bridge_hello_time_br0=1000
```

Now I added a new "Network" device in my virt-manager guest:

set model to virtio (just because someone else in a youtube tutorial did it...)

and source to "Bridge br0: Host eth0":

 [img]http://imgur.com/K23Rfmnl.png[/img]

I then start the guest system, installed the virtio driver, then the adapter tries to get an IP but never gets one.

I then tried to set a manual IP (192.168.1.88, netm. 255.255.255.0,gw 192.168.1.1, dns=gw)... 

Then I can ping the IP of HOST br0 (192.168.1.100) and the router (192.168.1.1) sucessfully, but no internet access

Could it be that I need to enable something like forewarding on my gentoo host? Or did I choose the wrong adapter in 

the guest nic settings?

----------

## NeddySeagoon

dasPaul,

To get to the internet you need an IP address that works.

A default route ... you may have that.

A nameserver is useful but not essential.

In windows run cmd.exe and in the black window, try

```
ping 216.58.213.78
```

that's google.

If that fails, you are missing a default route. If it works, continue below.

Try

```
ping google.com
```

 if that fails, Windows is missing a nameserver.

I forget the windows commands to see these things.

route and ipshow maybe?

Provided ping 216.58.213.78 works, browsing to 

```
http://216.58.213.78
```

 will work too.

The windows dhcpcd should set up all of these things.

----------

## dasPaul

```
ping 216.58.213.78
```

works

```
ping google.com
```

fails, but I set nameserver to 192.168.1.1 in the adapter settings...

thats weired! My assumption was that I dont need to care about this settings if I leave

the adapter in dhcp mode but obviously something prevents the dhcp request going 

from the Win Guest through br0 to my router...

Well I found another error that might have to do with it.. I found this in my syslog while starting

/etc/init.d/libvirtd:

```
...

Feb 25 16:28:29 Gummi dnsmasq[6331]: read /etc/hosts - 9 addresses

Feb 25 16:28:29 Gummi dnsmasq[6331]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses

Feb 25 16:28:29 Gummi dnsmasq-dhcp[6331]: read /var/lib/libvirt/dnsmasq/default.hostsfile

Feb 25 16:28:30 Gummi firewalld[8122]: WARNING: ebtables not usable, disabling ethernet bridge firewall.

Feb 25 16:28:37 Gummi su[6843]: pam_unix(su:session): session closed for user root

Feb 25 16:28:39 Gummi su[5586]: pam_unix(su:session): session closed for user root

Feb 25 16:29:44 Gummi kernel: br0: port 2(vnet0) entered blocking state

Feb 25 16:29:44 Gummi kernel: br0: port 2(vnet0) entered disabled state

...

```

I dont know if this "disabling ethernet bridge firewall." has an impact on my setup...

----------

## dasPaul

maybe I should compile app-emulation/libvirt without firewalld?

----------

## dasPaul

success!   :Cool: 

I re-emerged libvirt without firewalld and virt-network and did a

```
emerge -ac
```

to clean the system and VIOLA, Windows gets it dhcp adress from the router and http is working.

marking as solved & thanks for your help NeddySeagoon!

----------

