Virtual interface in netplan

After some investigation, I found out that the current netplan does not suport it. It is possible to do:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp7s0f0:
      addresses: [aaa.aaa.aaa.aaa/24, bbb.bbb.bbb/24]
      gateway4: aaa.aaa.aaa.1

ip addr shows both adresses and the computer can communicate with the bbb.bbb.bbb/24 network. The downside is that there is a single interface name for both networks, which can be a problem while defining the iptables rules.


Just go back to ifupdown. It's super easy

apt install ifupdown

delete/rename any .yaml file in /etc/netplan - the important part is to be sure the file extension is not yaml

Done!


Try something like that:

network:
    version: 2
    renderer: networkd
    ethernets:
        enp7s0f0:
            addresses: [aaa.aaa.aaa.aaa/24]
            gateway4: aaa.aaa.aaa.1
    vlans:
        veth0:
            id: 0
            link: enp7s0f0
            addresses: [bbb.bbb.bbb.bbb/24]

I don't know if you need to define the gateway again for the virtual interface. Add it if it doesn't work.