# libvirt network setup [solved]

## DaggyStyle

Greeting,

I have a gentoo guest on kvm on gentoo host which can access the internet but cannot see the host.

what is the right config which will maintain current behavior but will be able to see the host?

e.g. a vm that will be visible in the network like it is standalone computer.

Thanks.

----------

## szatox

oh, man, you are speaking aobut 2 or 3 different things there and I'm not sure which one you want.

Good news is, those things do not really depend or exclude each other, so here are bricks you might need:

1) make use libvirt creates a bridge for your virtual machine. It did for me, but I'm not sure it does with all modes you select.

2a) attach your physical NIC to the bridge to directly attach your VMs to the external network. Physical NIC must not have IP.

2b) configure IP on the brdge to let your host see the VM

use both, b and c to have host and guests attached directly to network.

----------

## DaggyStyle

 *szatox wrote:*   

> oh, man, you are speaking aobut 2 or 3 different things there and I'm not sure which one you want.
> 
> Good news is, those things do not really depend or exclude each other, so here are bricks you might need:
> 
> 1) make use libvirt creates a bridge for your virtual machine. It did for me, but I'm not sure it does with all modes you select.
> ...

 

I'll try to explain, I have a windows vm atop of virtual box, when I boot that vm, the router sees it as another computer on the net and allocates it a ip.

see this network example:

linux box, ip 192.168.0.1

windows laptop, ip 192.168.0.2

windows laptop, ip 192.168.0.3

windows vm running on the linux box (using VB), ip 192.168.0.4

I want to add the following entry to that list:

linux vm running on the linux box (using kvm), ip 192.168.0.5

I was able to do so by passing the using passthrough, the problem is that I was not able to access any box from 192.168.0.5 but I could access 192.168.0.5 from 192.168.0.1

----------

## szatox

Uhm... So which hypervisor you actually have there, VB or KVM?

I gave you the best short answer I had for KVM, for VB you're out of luck with me.

In the meantime, show us your network configuration on host:

ifconfig

route -n

brctl show

Also, what firewall rules you have on VM host and how you configure network on your guests?

----------

## DaggyStyle

 *szatox wrote:*   

> Uhm... So which hypervisor you actually have there, VB or KVM?
> 
> I gave you the best short answer I had for KVM, for VB you're out of luck with me.
> 
> In the meantime, show us your network configuration on host:
> ...

 

I use both but the question is on kvm.

I used my win8 VB vm to explain what I want to achieve.

my current fw rules are broken, haven't had the time to fix it yet.

here are the requested outputs:

```

dagg@NCC-5001-D ~ $ ifconfig

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

        inet 10.0.0.2  netmask 255.255.255.0  broadcast 10.0.0.255

        inet6 fe80::52e5:49ff:fe54:5245  prefixlen 64  scopeid 0x20<link>

        ether 50:e5:49:54:52:45  txqueuelen 1000  (Ethernet)

        RX packets 1061642  bytes 1300811567 (1.2 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 643503  bytes 82892336 (79.0 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 0  (Local Loopback)

        RX packets 284  bytes 22590 (22.0 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 284  bytes 22590 (22.0 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

dagg@NCC-5001-D ~ $ route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    4      0        0 eth0

10.0.0.0        0.0.0.0         255.255.255.0   U     4      0        0 eth0

127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

dagg@NCC-5001-D ~ $ brctl show

bridge name     bridge id               STP enabled     interfaces

```

currently I don't have any bridge set.

let me see if I understood you correctly, I need to:

create a bridge and instruct libvirt to use it.

configure ip for both the host and guest on that bridge.

if so, why can't I have the router assign ip to the host and guest?

----------

## DaggyStyle

issue solved.

I needed to enable CONFIG_IP_NF_NAT in the kernel, recompile it and run

```
sysctl -w net.bridge.bridge-nf-call-iptables=0
```

----------

## Schnulli

why not to PSX-Boot a VM ?

----------

## DaggyStyle

 *Schnulli wrote:*   

> why not to PSX-Boot a VM ?

 

PSX? you mean PXE?

----------

## Schnulli

oops, yes ^^ sorry

----------

## DaggyStyle

 *Schnulli wrote:*   

> oops, yes ^^ sorry

 

what's the gain in that?

----------

## szatox

 *Quote:*   

> what's the gain in that?

  Basicaly you would know, if you needed it. You asking this question means there is no benefit for you. As simple as that, it's not worth the effort of setting up DHCP, tftp, nfs, bootloader and perhaps other things unless you KNOW you want it.

However, for sake of satisfying your curiosity the second part comes:

It's good to know such an option exists, so you can have your VM scan some random network you connect to searching for OS provider. Or you can test your plug-and-forget install image for massive deployment on real hardware. Or do something copletly useless like a performance cluster on a single machine which efectively gives you performance of your host reduced by virtualisation overhead (let's say I just enjoy breaking my toys) - so you can run all nodes from a single, shared image. And deal with stuff like not overwriting temporary data from other nodes  :Smile: 

So, if you ever found a real-life application where you find PXE usefull, it's a neat test environment waiting for you to pick it and use it

----------

## DaggyStyle

 *szatox wrote:*   

>  *Quote:*   what's the gain in that?  Basicaly you would know, if you needed it. You asking this question means there is no benefit for you. As simple as that, it's not worth the effort of setting up DHCP, tftp, nfs, bootloader and perhaps other things unless you KNOW you want it.
> 
> However, for sake of satisfying your curiosity the second part comes:
> 
> It's good to know such an option exists, so you can have your VM scan some random network you connect to searching for OS provider. Or you can test your plug-and-forget install image for massive deployment on real hardware. Or do something copletly useless like a performance cluster on a single machine which efectively gives you performance of your host reduced by virtualisation overhead (let's say I just enjoy breaking my toys) - so you can run all nodes from a single, shared image. And deal with stuff like not overwriting temporary data from other nodes 
> ...

 

I know what PXE is and what is the gain in general (I work with pxe boots in my workplace) but I don't see how this is useful for me or to my issue.

my issue was that gentoo on kvm guest couldn't ssh or even ping the host.

----------

