help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static-networking-service-type: Using a static network bridge


From: Denis 'GNUtoo' Carikli
Subject: Re: static-networking-service-type: Using a static network bridge
Date: Mon, 27 Mar 2023 19:37:53 +0200

On Fri, 24 Mar 2023 18:14:48 +0100
Julien Lepiller <julien@lepiller.eu> wrote:

> The type should be a string, so "bridge" would be correct. However,
> it's not supported by guile-netlink yet, sorry. Do you think you
> could send me a scenario with iproute2 commands so I ean test an
> implementation?
What is a scenario here?

If it's about reproducing a setup with bridges something like that is
probably the easiest for the creation of the bridge:

                    +-->[eth0]<---->Local network<-->Router<-->Internet
                    |
+----------+        v      +----------+
| VM1 [eth0]<--> [br0] <-->[eth0] VM2 |
+----------+               +----------+

The bridge would be created with:
> sudo ip link add br0 type bridge
> ip link set dev br0 up

Then the host eth0 can joint it like that:
> sudo ip link set dev eth0 master br0
> sudo ip link set dev eth0 up

I've only tested that setup with eth0 being unconfigured (no IP
address), and by having br0 get the IP address instead.

So if you use DHCP, you can use 'dhclient br0' instead of the usual
'dhclient eth0', or you can set the static IP address to br0 instead of
eth0.

For the VM, you'd need to setup two qemu-kvm VMs with virt-manager.

Once you have a VM, there is a "Add hardware" button. You then need to
select "Network" for the type of hardware to add and fill some
information: "Network source" should be set to Bridge device, and
"Device name:" should be set to the bridge name on the host (like br0
for instance).

The equivalent libvirt XML for the VM network interface looks like that:
> <interface type="bridge">
>   <mac address="XX:XX:XX:XX:XX:XX"/>
>   <source bridge="lan0"/>
>   <model type="virtio"/>
>   <address type="pci" domain="0x0000" bus="0x00" slot="0x03"
> function="0x0"/> </interface>

Then you can setup a static IP address to the Ethernet interface inside
the VMs, and ping the static IP address of one VM from the other VM or
ping your router from a VM or vice versa.

Maybe there are easier ways to test that without VMs or physical
network but I don't have ideas about that yet.

In my case the bridge is used for 2 different things:
- making the VMs join the local network and be treated like any other
  physical machine.
- Enabling GNU/Linux smartphones connected to my laptop though USB to
  also join the local network: when a smartphone is connected, an usb0
  Ethernet interface appears, and an udev rule makes it join the bridge.

Thanks a lot for the infos and the help.

Denis.

Attachment: pgpz4ueNXiiTV.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]