Setting up bridged connection between VM (virt-manager 1.5.0) and CentOS 7.9 host

Hello,

I need to be able to access a process on my host (CentOS 7.9) from a guest VM I created with virt-manager. I followed the steps here,

6.4. Bridged Networking

Procedure 6.1. Creating a bridge with virt-manager

that seemed to be what I was looking for. This is what I did,

  1. with the VM shutdown, edit > connection details > network interfaces
  2. click “+” to configure a new interface
  3. select “bridge” and click “forward”
  4. the name was br1 so I just left that, set “start mode” to “on boot”
  5. the instructions say to make necessary changes to “IP settings” or “Bridge settings”, there is no indication as to what those changes should be, under IP configuration the options are to copy the configuration or configure manually. I have no idea what to do here so I just let it as it was. It seems like it should at least have an address but I have no idea.
  6. choose the physical interface to connect to, the options are lo Ethernet or vibro-0-nic Ethernet. I chose vibro because I know that was installed with KVM and is running (at least some of the time) on the host.
  7. click “finish”
  8. the instructions say to select the new bridge from the list and click “apply” but the apply button is grayed out and doesn’t do anything. I just closed the window because there were no other options.

After completing these steps I opened my VM and clicked on the hardware details icon (light bulb). I clicked on the add hardware “+” and chose “network”. This VM was set up without a network adapter. For network source, I chose the new bridge adapter that now appears in the list with device model rtl8139 and whatever MAC was already listed and clicked on “finish”.

When I start the VM I immediately get the error,

Error starting domain: Cannot get interface MTU on 'br1': No such device

traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 89, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 125, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 82, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/domain.py", line 1506, in startup
    self._backend.create()
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 1080, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: Cannot get interface MTU on 'br1': No such device

I thought I was making progress. The output of ip a is

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 10:bf:48:7f:33:b1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.27/24 brd 192.168.10.255 scope global noprefixroute dynamic eno1
       valid_lft 207450sec preferred_lft 207450sec
    inet6 fe80::df21:9a3e:254b:fd01/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:1f:1c:b3 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:1f:1c:b3 brd ff:ff:ff:ff:ff:ff

in case that is useful. I expect that I should see my new “br1” in this output but I don’t. I think that is a bad sign.

Can anyone let me know what to do next?

LMHmedchem

This is how it works on Fedora:
How to make a Virtual Machine present itself to my home network as if it were another physical computer - #7 by vgaetera

1 Like

CentOS Linux 7 does not have a way to automatically ‘create’ a bridge network, and the instructions are assuming that a bridge network exists. The reason it can’t automatically create one is that work needs to be done via a different set of tools. You will need to instead need to convert your eno1 into a bridge interface. The instructions here can help TipsAndTricks/BridgeAndNmcli , but there are a lot of things which can go wrong depending on:

  • network card
  • network setup
  • other services and configs.

I have done this many times and still find ways to make a system not able to reach the network in new ways. I would look up the above and other resources then be on the console of the host system to make the bridge to make sure you don’t get locked out because br1 didn’t come up correctly and eno1 went down.

2 Likes

Thanks for the advice, and thanks to Vladislav Grigoryev as well.

The post by Vladislav Grigoryev used nmcli as well. Do those instructions look correct if you have had a chance to look?

It almost seems as if it would be worth spending a few dollars on a second network card so that the host system would have two possible hardware networks to use. Maybe the bridge could be setup on the new network card and if it didn’t work, the host could go back to using eno1.

At any rate, I will make a clonezilla image of the host system before going ahead in case I get lost and didn’t leave enough breadcrumbs to find my way back.

LMHmedchem

I have another quick question before I try this. I have several computers on this local network. Right now, I am trying to set up a network in to allow a VM to make connections to the host computer. This has to be a bridged network as I understand it.

If I just set up the VM with whatever is used as the typical network connection for a VM (not a bridged network) that would allow connections from the VM to the internet by a browser, etc, can I use that to connect to a different computer here on my local network (not the host computer)? If so, I can run the server process I need on a different computer (not the host) and bypass having to create a bridge. This would involve some firewall configuration on my router and such but that isn’t a big deal (because I actually know how to do that).

Is that correct or am I still not getting this?

LMHmedchem

You just need to create a bridge as described above.
There is no need to make it more complicated.
This is a relatively simple task, not rocket science.

1 Like

It does seem as if I already have a bridge adapter.

$ sudo brctl show
bridge name	  bridge id		      STP enabled   interfaces
virbr0		  8000.5254001f1cb3   yes           virbr0-nic

I assume this was created by default at some point. Can I just disregard that this is here and make another one or do I need to delete it?

LMHmedchem

The default virtual network bridge relies on NAT and can be ignored or removed after the shared host bridge is configured.