Score:0

creating two net bridges on one phisical computer

uy flag

I have two network cards on my computer. I want to create two net bridges with netplan to add this bridged networks to kernel based virtual machines (KVM). Both network cards are connected to the same router which has access to Internet.

I have the following network configuration using netplan:

network:
    version: 2
    renderer: networkd
    ethernets:
        eth-host0:
          match:
            macaddress: xxx:97:02
          dhcp4: false
          dhcp6: false
        eth-host1:
          match:
            macaddress: xxx:08:61
          dhcp4: false
          dhcp6: false
    bridges:
        br0:
          interfaces: [eth-host0]
          addresses: [192.168.0.9/24]
          gateway4: 192.168.0.1
          mtu: 1500
          nameservers:
            addresses: [8.8.8.8]
          parameters:
            stp: true
            forward-delay: 4
          dhcp4: true
          dhcp6: false
        br1:
          interfaces: [eth-host1]
          addresses: [192.168.1.9/24]
          gateway4: 192.168.0.1
          mtu: 1500
          nameservers:
            addresses: [8.8.8.8]
          parameters:
            stp: true
            forward-delay: 4
          dhcp4: true
          dhcp6: false 

when I issue command

sudo netplan apply

I got the following error "Problem encountered while validating default route consistency.Please set up multiple routing tables and use routing-policy instead. Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in br0 but also in br1"

If I delete default gateway, than apply passes but I do not have any networks on my virtual machine.

How do I properly configure two bridges on the same computer?

Score:1
my flag

I'm not a Netplan expert but you could try to remove the gateway4: 192.168.0.1 from br1 (but leave it on br0).

If that doesn't work, try to add this to br1:

routes:
  - to: 0.0.0.0/0
    via: 192.168.0.1
    table: 101
routing-policy:
  - from: 192.168.1.9/24
    table: 101

BTW before running netplan apply run netplan generate. Then you will se the errors before applying. I have lost connections to the server a couple of times because of simple mistakes :-)

Often I also have to reboot for the changes to fully apply.

Score:0
uy flag

I managed to configure two bridges on one machine that is the host for several KVM VMs to which I passed bridged (virtual) network devices.

I run DHCP server on my router connected to Internet. The router has LAN address 192.168.0.1, so the same address will be default gateway. I assign permanent addresses to each VM based on its MAC on the DHCP server side that runs on the router.

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
          match:
            macaddress: private:01
          set-name: tplink-usb3.0
          dhcp4: true
          dhcp6: false
          optional: true
          mtu: 1500
          nameservers:
            addresses: [8.8.8.8]
        eth-host0:
          match:
            macaddress: private:02
          dhcp4: false
          dhcp6: false
        eth-host1:
          match:
            macaddress: private:03
          dhcp4: true
          dhcp6: false
    bridges:
        br0:
          interfaces: [eth-host0]
          mtu: 1500
          nameservers:
            addresses: [8.8.8.8]
          parameters:
            stp: true
            forward-delay: 4
          dhcp4: true
          dhcp6: false
        br1:
          interfaces: [eth-host1]
          mtu: 1500
          nameservers:
            addresses: [8.8.8.8]
          parameters:
            stp: true
            forward-delay: 4
          dhcp4: true
          dhcp6: false 

IP addresses of both bridges are not relevant in this configuration. The only thing I did is I enabled dhcp4 on both bridges. As a result the KVM (I use libvirt to set VM's configuration) assigns to each VM new MAC address and the DHCP server on the router side assigns to each VM new IP address as well as gateway. Than on the router side I can set the dynamic IP addresses as permanent ones.

The above configuration works.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.