Score:0

How to use DHCP on multiple VLANs on a single interface with netplan?

pt flag

In my current network topology I have multiple VLANs - each of which has it's own routing:

VLAN 10:
  DHCP:    10.0.10.10-10.0.10.255
  Subnet:  255.255.255.0
  Gateway: 10.0.10.1

VLAN 11
  DHCP:    10.0.11.10-10.0.11.255
  Subnet:  255.255.255.0
  Gateway: 10.0.11.1

The machine(s) I'm automatically provisioning have a single NIC. This is why I would like to avoid using static configurations and rather relay on the DHCP to provide the "correct" settings.

My yaml looks like this:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      # Designate the connection as "critical to the system", meaning that special care will be taken by systemd-networkd 
      # to not release the IP from DHCP when it the daemon is restarted.
      critical: yes
      dhcp4: no

  vlans:
    cloud:
      id: 10
      link: enp5s0
      dhcp4: yes
      dhcp4-overrides:
        route-metric: 200

    office:
      id: 11
      link: enp5s0
      dhcp4: yes
      dhcp4-overrides:
        route-metric: 100

The problem is it only gets the DHCP settings for the cloud vlan and does nothing with the office one. Am I missing something here?

NOTE:
This is not a duplicate of netplan with multiple vlans on single interface - help needed.

ru flag
Are you sure the line you're connected to on enp5s0 is carrying VLAN 10 to your system? Not getting DHCP for a VLAN typically means it's not properly communicating on the network, usually when the specific VLAN ID is not properly transferred down from the network link
pt flag
@ThomasWard yes, I'm sure. If I have only one VLAN in the configuration and switch between `id: 10` and `id: 11` it works just fine and I receive the DHCP configuration. It doesn't seem to be that. If I set `entp5s0` to `dhcp4: yes` and then have only the `cloud` VLAN it works again. It specifically doesn't work when I add a second VLAN like the configuration above for some reason. :/
Score:0
cn flag

Remember, your DHCP-server does not know about your VLAN configurations.

It is getting a request for an IP for the MAC-adress of enp5s0 and then another request, most likely identical to the previous request. Have a look at the DHCP log, it should confirm this. Or use tcpdump to debug the traffic.

us flag
This answer assumes there's only a single DHCP server. That is not at all obvious; typically if you are going to have multiple networks with different subnets, the DHCP server on each is a different machine.
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.