creating two net bridges on one phisical computer
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?
Solution 1:
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.