Score:0

How to connect Ubuntu 21.10 to tagged VLAN (netplan)

pr flag

I have network

VLAN:      4005
MTU:       1400
Subnet:    157.XX.XX.64/27
Gateway:   157.XX.XX.65
Netmask:   255.255.255.224
Broadcast: 157.XX.XX.95

I want to configure netplan Ubuntu 21.10 to IP 157.XX.XX.87

I have only two idea

network:
  version: 2
  renderer: networkd
  ethernets:
     ens3:
      dhcp: false
      optional: true
 bridges: 
   br2:
     interfaces:
     addresses: 
     - 157.XX.XX.87/32
vlans:
    vlan.4005:
    id: 4005
    link: ens3
    routes:
       - to: 0.0.0.0/0
         via: 157.XX.XX.65
         metric: 100
    mtu:1400

other idea

network:
  version: 2
  renderer: networkd
  ethernets:
     ens3:
      dhcp: false
      optional: true
      addresses: 
      - 157.XX.XX.87/32
 bridges: 
   br2:
     interfaces:
     addresses: 
     - 157.XX.XX.64/27
vlans:
    vlan.4005:
    id: 4005
    link: ens3
    routes:
       - to: 0.0.0.0/0
         via: 157.XX.XX.65
         metric: 100
    mtu:1400

Unfortunately, any my idea don't working. This server working under QEMU/KVM, therefore name of bridges and name of VLAN is define in KVM config.

What right place to setup ubuntu IP address in this case - in interface, in VLAN, in Bridge?

What right place so setup routes - in bridge or in VLAN?

What right place to setup MTU?

Thomas Aichinger avatar
cn flag
Do you want a bridge with vlan, or just the vlan?
Thomas Aichinger avatar
cn flag
And by the way the indentation does not fit!!!
Alex avatar
pr flag
@ThomasAichinger, thank you to attention for my question. I have a bridge with VLAN. If I use Ubuntu 16.04 it working automatically, I simple define IP/Mask/Broadcast/Gateway in /etc/network/interfaces, but I still don't understand what need in new Ubuntu 21, because netplan. If I define simple IP/Mask/Broadcast/Gateway (in Ubuntu 16 style), modern Ubuntu don't working.
us flag
What do you mean, you "have" a bridge with vlan? Your netplan config shows you defining a bridge, but your vlan does not use it, it serves no obvious purpose, the addressing on it in your configuration is incorrect, and it doesn't relate to the initial network config you list. What is the purpose of this bridge?
Alex avatar
pr flag
@slangasek Maybe I don't understand netplan idea at all. I have bridge inside KVM. And can manipulate it by BRCTL command. My KVM contains definition of Bridge and this machine is virtual machine. Any my virtual Ubuntu 16.04 working perfectly with this bridge. KVM Bridge add VLAN tag 4005 to any addr 157.XX.XX.64/27 and route it to main physical interface with VLAN Tag. Then datacenter communicator route tagged packages from IP range 157.XX.XX.64/27 to internet. But if I try to reproduce Ubuntu 16.04 network configuration (/etc/network/interface) by netplan I'm always failed.
Christian Ehrhardt avatar
sl flag
Hi Alex, we have to be careful what is in guest/host, especially when I read "I have bridge inside KVM". You can achieve what you want in two ways "network -> ethev (tags vlan) -> host-bridge -> guest" or "network -> ethdev -> host-bridge -> guest (tags vlan)". Yours sounds a bit like the latter, which isn't safe (the guest can access all). OTOH the first approach doesn't need a bridge or vlan config in the guest at all, the host ensures it is tagged and the guest can't easily escape. That is recommended and what is explained in https://netplan.io/examples/#configuring-network-bridges
Thomas Aichinger avatar
cn flag
If you are unhappy with netplan you also can turn it off and switch back to ifup/down
us flag
The misunderstandings here are not about netplan, but about how network interfaces work (guest vs host). ifupdown is unsupported in Ubuntu 20.04 and later and it is highly recommended you not revert to it. Please see Christian's explanation above; the use of a bridge on the KVM host does not mean you should declare a bridge in your KVM guest.
Score:0
cn flag

Try this configuration:

network:
  version: 2
  renderer: networkd

  ethernets:
    ens3:
              dhcp4: false
              dhcp6: false

  bridges:
    br0:
          interfaces: [ens3]
          addresses: [157.XX.XX.87/27]
          gateway4: 157.XX.XX.65
          mtu: 1500
          nameservers:
                addresses: [8.8.8.8]
          parameters:
                stp: true
                forward-delay: 4
      dhcp4: no
      dhcp6: no

  vlans:
    vlan4005:
      id: 4005
      link: ens3
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.