Tag: KVM Bridge

  • Configure KVM Bridge Network using netplan

    Configure KVM Bridge Network using netplan

    On Ubuntu 20.04 server we have the following network configuration

    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 get all

    netplan config file has the following

    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:~# 

    Before you can use bridge in netplan, you need to install bridge-utils

    apt-get install bridge-utils

    To configure bridge networking, modify the file as follows

    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

    netplan generate

    To test the configuration, run

    netplan try

    Here is an example https://gist.github.com/serverok/712b85432d188f16c9d32e44455b419a

    Back to netplan