Configure KVM Bridge Network using netplan
On Ubuntu 20.04 server we have the following network configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@mail:~# ip a 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: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether d8:cb:8a:e3:c7:c9 brd ff:ff:ff:ff:ff:ff inet 37.157.249.137/32 scope global enp2s0 valid_lft forever preferred_lft forever inet6 fe80::dacb:8aff:fee3:c7c9/64 scope link valid_lft forever preferred_lft forever root@mail:~# |
“netplan get all” command show following
netplan config file has the following
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
root@mail:~# cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp2s0: addresses: [ 37.157.249.137/32 ] nameservers: search: [ venus.dedi.server-hosting.expert ] addresses: - "8.8.8.8" - "1.1.1.1" routes: - to: 0.0.0.0/0 via: 37.157.249.129 on-link: true root@mail:~# |
To configure bridge networking, modify the file as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
network: version: 2 renderer: networkd ethernets: enp2s0: dhcp4: no dhcp6: no bridges: br0: dhcp4: no dhcp6: no interfaces: [enp2s0] addresses: [ 37.157.249.137/32 ] nameservers: addresses: - "8.8.8.8" - "1.1.1.1" routes: - to: 0.0.0.0/0 via: 37.157.249.129 on-link: true |
To check if there is any error in netplan configuration, run
1 |
netplan generate |
To test the configuration, run
1 |
netplan try |