Configuration for KVM VM and Netplan

First off, let me say that to me, networking is a black art, practiced by strange men in hooded cloaks, chanting strange incantations. I can ‘do’ basic networking.

The background is that I have created VMs using KVM on my Ubuntu Desktop running Ubuntu Desktop 24.04 for a number of years. I have a Netplan YAML file for bridging that took me a long time to get right and that has served me well to enable the VM to talk to the internet and the host machine. This worked fine and my needs were simple.

I have now created a VM on my Ubuntu Server (no GUI) and am able to configure using the VM Manager on my Ubuntu Desktop. I now want me VM to talk to the internet, and my local network physical machines, and for those machines to talk to the VM. At one point the VM would talk with everything, but not vice versa. I think I have now screwed everything up and it will not talk with anything – don’t know why!

My Ubuntu server is called MERLIN, with IP address 192.168.1.10. My Ubuntu Desktop is called CAMELOT, with IP address 192.168.1.11. My VM is called MORDRED (residing on MERLIN) and I want it to have a static IP adress of 192.168.1.18. MORDRED should be able to talk to CAMELOT and MERLIN. I don’t think this is a big ask, is it?

The Netplan YAML file on the server (MERLIN) is as follows:

network:
  version: 2
  #renderer: NetworkManager
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: false
      dhcp6: false
      addresses: 
        - 192.168.1.10/24
      routes:
      - to: default
        via: 192.168.1.1
        metric: 100
        on-link: true
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8]

  bridges:
    br0:
      interfaces: [enp3s0]
      dhcp4: false
      dhcp6: false
      addresses: 
        - 192.168.1.3/24
      routes:
      - to: default
        via: 192.168.1.1
#        metric: 100
        on-link: true
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8]
      parameters:
        stp: true
        forward-delay: 4

Also in the Netplan folder on the server is an XML file as follows (not really sure what this is for, I put it there a few years ago. It worked so I left it alone):

<network>
  <name>host-bridge</name>
  <forward mode="bridge"/>
  <bridge name="br0"/>
</network>

The YAML file on the VM is as follows:

network:
  version: 2
  # renderer: NetworkManager
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: false
      dhcp6: false
      addresses: 
        - 192.168.1.18/24
      routes:
      - to: default
        via: 192.168.1.1
        metric: 100
        on-link: true
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

The Virtual Network Interface in the VM Manager is set as follows:

Network Source: Bridge Device...
Device Name: br0
Device Model: virtio

When I issue ifconfig on the server, I get the following:

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2a0a:ef40:60:1801:6828:2dff:fee0:ae68  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::6828:2dff:fee0:ae68  prefixlen 64  scopeid 0x20<link>
        ether 6a:28:2d:e0:ae:68  txqueuelen 1000  (Ethernet)
        RX packets 14531  bytes 1269556 (1.2 MB)
        RX errors 0  dropped 216  overruns 0  frame 0
        TX packets 8082  bytes 15347032 (15.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        ether e0:d5:5e:d1:d2:f2  txqueuelen 1000  (Ethernet)
        RX packets 15694  bytes 1543343 (1.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17907  bytes 15946048 (15.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5238  bytes 4812865 (4.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5238  bytes 4812865 (4.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:4e:3b:6e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::fc54:ff:fea6:8243  prefixlen 64  scopeid 0x20<link>
        ether fe:54:00:a6:82:43  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1  bytes 90 (90.0 B)
        TX errors 0  dropped 2927 overruns 0  carrier 0  collisions 0

I don’t know where the virbr0 and vnet0 come from. Probably not important!

But on the VM, I am now only getting:

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 12965  bytes 922705 (922.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12965  bytes 922705 (922.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I was getting a lot more, but with my messing about I think I have totally screwed it up and can’t get back to it.

The annoying thing is that I did momentarily have everything as I wanted it, and decided to reboot everything to ensure that it all persisted – it didn’t, and I am now in the situation I am in at the moment.

So, if there are any strange men who normally wear hooded cloaks would like to whisper some strange incantations in my directions I would VERY much appreciate it.

Regards, StuartM