LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 04-08-2020, 07:58 AM   #1
jasonmelbye
LQ Newbie
 
Registered: Apr 2015
Posts: 16

Rep: Reputation: Disabled
Adding Guest Systems to Network, libvirt, Fedora Host


Hello,

I'm taking my first foray into virtualization. I would like to get a web server running on a virtual system accessible to the outside world.

I've been reading up and learning a lot, but wanted to go over my setup step by step from the beginning to better my understanding. Below is an overview of what I am trying to accomplish, and what my understanding is so far. In the end, I am asking specifically how I set up a network bridge, but if I have gone astray anywhere, I would also appreciate any corrections to my understanding or feedback on the approach.

The host is a Fedora 31 system
The guest that will run the web server is a Debian 10 system
I'm using libvirt, virt-manager, etc.
The guest is running under the QEMU/KVM hypervisor

The host system is running on my home network.
We'll say my public IP is 1.1.1.1
The host system on my home network is 192.168.0.100/24
The home network router/gateway is 192.168.0.1/24
My home router is set up to forward traffic on ports 80 and 443 to the host system.

The network interfaces on the host currently are:
lo: loopback device
enp8s0: wired ethernet interface between the host and home network (192.168.0.100/24)
virbr0: My understanding is libvirt creates this virtual bridge interface. It is set up for NAT by default. (192.168.122.1/24)
virbr0-nic: To be honest, I don't know what this is. I assume it is related to virbr0. (Does not currently show an IP address)

If I fire up the guest system now, it gets an IP address on the 192.168.122.0 network.

What I understand from reading up on networking is there are two general networking approaches with VMs:
1) NAT
2) Bridged

The current/default setup with libvirt is NAT.

Under this setup, all the virtual machines live on a separate network, 192.168.122.0. I believe I could achieve the result I want (publicly accessible web server running on the guest system) under the NAT setup. It would require that I set up firewall rules on the host to forward traffic to the guest and track connection etc. I think that will be harder to set up and maintain than using a bridged network.

My understanding is that under a bridged network setup, the virtual systems will live on the same network as the host (192.168.0.0). This seems appealing. If I understand correctly, I would not need to set up firewall rules on the host or configure the host system to track connections, etc. The guest system would get an IP address on the 192.168.0.0 network (perhaps a static address maintained by my router's DHCP server?) and I could directly configure the router to forward traffic to the guest rather than to the host. Do I have that right so far?

If so, the steps where I really get lost are for setting up the bridge. I worry that some of the information out there is outdated (disable NetworkManager?, use brctl or ip?) and I am not sure the role of different tools (ip, nmcli, virsh, etc.)

It seems like using ip is preferred.
I have just created a new bridge interface, br0 with the command:
Code:
sudo ip link add br0 type bridge
Now I think I need to associate interfaces with the bridge. How to I perform this step?
 
Old 04-08-2020, 04:42 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Code:
ip link set dev enp8s0 master br0
However, this won't survive a reboot. Furthermore, I am not sure if NetworkManager is happy when you poke around in the lower configuration layers. Thus, try nmcli to create the bridge and add the interface to it:
Code:
$ sudo nmcli con add ifname br0 type bridge con-name br0
$ sudo nmcli con add type bridge-slave ifname enp8s0 master br0
(I haven't tried it; source https://www.cyberciti.biz/faq/how-to...ager-on-linux/)

EDIT: Also the official nmcli-examples manual page, example 9: https://developer.gnome.org/NetworkM...-examples.html.

Last edited by berndbausch; 04-08-2020 at 04:47 PM.
 
1 members found this post helpful.
Old 04-08-2020, 07:06 PM   #3
jasonmelbye
LQ Newbie
 
Registered: Apr 2015
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Code:
ip link set dev enp8s0 master br0
However, this won't survive a reboot.
You are correct, bridge interface was not present after rebooting. I was seeing examples that created the bridge with ip, and examples that created it with nmcli. I guess one is for temporary setup while the other is for persistent setup.

Quote:
Originally Posted by berndbausch View Post
Furthermore, I am not sure if NetworkManager is happy when you poke around in the lower configuration layers. Thus, try nmcli to create the bridge and add the interface to it:
Code:
$ sudo nmcli con add ifname br0 type bridge con-name br0
$ sudo nmcli con add type bridge-slave ifname enp8s0 master br0
(I haven't tried it; source https://www.cyberciti.biz/faq/how-to...ager-on-linux/)

EDIT: Also the official nmcli-examples manual page, example 9: https://developer.gnome.org/NetworkM...-examples.html.
This almost did it. After making these edits, I fired up the VM and it was not getting assigned an IP address. On the host, the bridge interface still did not have an IP address.

The missing step was about half way down the first link you provided. It says you must turn off the wired connection and turn on the bridge. Edited for my setup:

Code:
$ sudo nmcli con down "Wired 1"
$ sudo nmcli con up br0
As soon as I executed that second line, output was sent to the terminal indicating that the bridge was active and awaiting connections.

At that point I started my VM up again, and it was assigned an IP address on the 192.168.0.0 network. The host and the guest both had network access. Success!

To test the persistence of the configuration, I rebooted one more time. After reboot, ip link shows that both interfaces are UP:
Code:
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 70:85:c2:d9:dc:b1 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether d6:52:51:f4:ae:fd brd ff:ff:ff:ff:ff:ff
I was wondering if I would have to take the wired interface down again. But I left it as is, fired up the VM, and everything was still working.

Last edited by jasonmelbye; 04-08-2020 at 07:08 PM. Reason: Edited for a bad markup
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bridged host and guest: worked until reboot [libvirt] GAVollink Linux - Virtualization and Cloud 5 11-29-2019 03:45 PM
[SOLVED] I get this error on shutdown: "libvirt-guest.sh: Running guest on default URI: no running guests" linustalman Debian 18 02-22-2017 05:13 AM
libvirt: execute command on host initiated by guest atelszewski Linux - Virtualization and Cloud 15 11-23-2016 03:22 PM
Host Can't Guest Libvirt/KVM via SSH DJOtaku Linux - Virtualization and Cloud 4 01-19-2016 01:44 PM
Guest to Host message passing - guest's memory usage statistics & guest's IP address Prince_Pangeni Linux - Virtualization and Cloud 2 03-03-2012 03:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 04:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration