Cloud Resource
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Network

Let’s setup the Ubuntu 22.04 KVM/Libvirt network NIC with a bridge type configuration.

First, disable IPv6:

cat <<EOF |sudo tee /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
EOF

Next, apply the sysctl settings:

sudo sysctl -p

Then, disable IPv6 in the hosts file:

sed -i 's/^[[:space:]]*::/#::/' /etc/hosts

Alternatively, you can add hosts in the /etc/hosts file and remove IPv6 records:

cat <<EOF |sudo tee /etc/hosts
127.0.0.1 localhost
192.168.0.201 host-01
192.168.0.202 host-02
192.168.0.203 host-03
EOF

Now, setup a bridge network for each KVM host:

cat <<EOF |tee /etc/netplan/00-installer-config.yaml
network:
  ethernets:
    eno1:
      dhcp4: false
      dhcp6: false
    eno2:
      dhcp4: false
      dhcp6: false
  # add configuration for bridge interface
  bridges:
    br0:
      interfaces: [eno1]
      dhcp4: false
      dhcp6: false
      addresses: [192.168.0.201/24]
      macaddress: 9c:b6:54:bb:3e:f0
      routes:
        - to: default
          via: 192.168.0.1
          metric: 100
      nameservers:
        addresses: [1.1.1.1]
      parameters:
        stp: false
  version: 2
EOF

Apply the network configuration with netplan apply:

netplan apply

Finally, verify the NIC status for the br0 NIC:

ip a