Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] installing virtual machine under gentoo
Date: Sun, 02 Jan 2022 18:48:54
Message-Id: CAGfcS_myD+L-4W5LCdPy274PtXwV=1wchmSFXB6E_YBbW4fLrg@mail.gmail.com
In Reply to: Re: [gentoo-user] installing virtual machine under gentoo by Grant Taylor
1 On Sun, Jan 2, 2022 at 1:01 PM Grant Taylor
2 <gtaylor@×××××××××××××××××××××.net> wrote:
3 >
4 > What I remember doing was re-configuring the (primary) network interface
5 > so that it came up without an IP address and was added as a member to a
6 > newly created bridge. As part of that I moved the system's IP
7 > address(es) from the underlying Ethernet interface to the newly created
8 > Bridge interface.
9 >
10
11 That is basically what I had to do.
12
13 With systemd-networkd the relevant stuff in /etc/systemd/network was:
14 eth-bridge.network:
15 [Match]
16 Name=e*
17
18 [Network]
19 Bridge=brkvm
20
21 (you'll need a more specific name I'm guessing since you have more
22 than one interface - the name to match should be the physical
23 interface name)
24
25 brkvm.netdev:
26 [NetDev]
27 Name=brkvm
28 Kind=bridge
29
30 (this creates the bridge interface, which the physical interface will
31 attach to due to the previous file)
32
33 brkvm.network:
34 [Match]
35 Name=brkvm
36
37 [Network]
38 DNS=...
39 Address=...
40 Gateway=...
41
42 (this will give the bridge interface an IP/etc - most likely you'll
43 just set this file up the way you'd otherwise be setting up your
44 physical network. This can use dhcp.)
45
46 Then you'll tell virt-manager to use the brkvm bridge for all your VMs
47 that you want bridged. Note that you can also use this bridge for
48 things like containers if they use virtual interfaces. They'll just
49 see the host network directly, with their own virtual interfaces, so
50 they can use DHCP to obtain IPs on the host network.
51
52 In your case with dual interfaces you'll want to put the bridge on
53 whichever interface you want shared. The other interface can remain
54 untouched.
55
56 The brkvm interface will otherwise behave the way eth0 or whatever
57 used to behave before you attached it to the bridge. Note that the
58 physical interface attached to the bridge will not have an IP. It
59 just relays traffic from the bridge to the physical network.
60
61 You could also just drop the first file if you wanted to have a bridge
62 not attached to any physical networks. VMs could still attach to it
63 and talk to each other. Though, I think virt-manager might provide
64 other ways to do this.
65
66 All of the above are systemd-specific. Most network managers provide
67 some proper way to set up a bridge and you should probably do that.
68 You can do it all with just a shell script instead I suppose.
69
70 --
71 Rich