Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] libvirt guest same subnet as host?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 10:45 am    Post subject: [solved] libvirt guest same subnet as host? Reply with quote

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:
Code:
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?
_________________
-=human without Windows®=-
sorry for my bad english!


Last edited by dasPaul on Sun Feb 25, 2018 5:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 40979
Location: 56N 3W

PostPosted: Sun Feb 25, 2018 11:21 am    Post subject: Reply with quote

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.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 1:19 pm    Post subject: Reply with quote

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:
Code:
/etc/init.d/net.eth0 stop
rc-update del net.eth0 default
rm /etc/init.d/net.eth0

created the bridge:
Code:
ip link add br0 type bridge

added eth0 to it:
Code:
ip link set dev enp1s0 master br0


The wiki at:

Host configuration
OpenRC
As an example, bridge configuration with DHCP:

Code:
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:
Code:

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...
_________________
-=human without Windows®=-
sorry for my bad english!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 40979
Location: 56N 3W

PostPosted: Sun Feb 25, 2018 1:45 pm    Post subject: Reply with quote

dasPaul,

eth0 should not have an IP address any more.

From my KVM host. Create the bridges.
Code:
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.
Code:
#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.

Code:
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
Code:
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.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 2:22 pm    Post subject: Reply with quote

NeddySeagoon wrote:

You talk about
Code:
ip link set dev enp1s0 master br0

So it looks like your....


Sorry, typo, of cause I used "eth0"... :roll:
Quote:
eth0 should not have an IP address any more.

I needed a reboot, now eth0 is up without ip:
Code:
#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 :)
_________________
-=human without Windows®=-
sorry for my bad english!
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 3:59 pm    Post subject: Reply with quote

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

Code:
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?
_________________
-=human without Windows®=-
sorry for my bad english!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 40979
Location: 56N 3W

PostPosted: Sun Feb 25, 2018 4:29 pm    Post subject: Reply with quote

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
Code:
ping 216.58.213.78
that's google.
If that fails, you are missing a default route. If it works, continue below.

Try
Code:
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
Code:
http://216.58.213.78
will work too.
The windows dhcpcd should set up all of these things.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 4:59 pm    Post subject: Reply with quote

Code:
ping 216.58.213.78

works
Code:
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:

Code:
...

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...
_________________
-=human without Windows®=-
sorry for my bad english!
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 5:01 pm    Post subject: Reply with quote

maybe I should compile app-emulation/libvirt without firewalld?
_________________
-=human without Windows®=-
sorry for my bad english!
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 170
Location: Dresden

PostPosted: Sun Feb 25, 2018 5:33 pm    Post subject: Reply with quote

success! 8)
I re-emerged libvirt without firewalld and virt-network and did a
Code:
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!
_________________
-=human without Windows®=-
sorry for my bad english!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum