How to create VLAN interface for EtherCAT forwarding using netplan

On Ubuntu, use Netplan to create a VLAN sub-interface (e.g. enp1s0f0.1999 on enp1s0f0) for EtherCAT forwarding. Since Netplan does not expose the VLAN reorder_hdr flag directly, enforce it persistently using a systemd-networkd drop-in so the kernel keeps VLAN tags in the packet payload — which is required when forwarding or inspecting raw EtherCAT frames.

1. Create the VLAN Interface in Netplan

Edit /etc/netplan/60-ethercat.yaml and keep only valid Netplan keys:

/etc/netplan/60-ethercat.yaml
network:
  version: 2
  vlans:
    enp1s0f0.1999:
      id: 1999
      link: enp1s0f0
      dhcp4: false
      dhcp6: false
      link-local: []

Apply the configuration:

example.sh
sudo netplan apply

Verification: Run ip link show enp1s0f0.1999 to ensure Netplan creates the VLAN interface without syntax errors.

2. Enforce reorder_hdr=1 Persistently

Create the systemd-networkd override directory for the VLAN netdev:

example.sh
sudo mkdir -p /etc/systemd/network/10-netplan-enp1s0f0.1999.netdev.d

Create /etc/systemd/network/10-netplan-enp1s0f0.1999.netdev.d/override.conf:

/etc/systemd/network/10-netplan-enp1s0f0.1999.netdev.d/override.conf
[VLAN]
ReorderHeader=yes

Restart systemd-networkd to apply:

example.sh
sudo systemctl restart systemd-networkd

Verification: Check the systemd-networkd logs using sudo journalctl -u systemd-networkd -n 20 to verify no configuration parsing errors occurred.

3. Verify the Kernel State

Check the active VLAN flags in the kernel:

example.sh
ip -d link show dev enp1s0f0.1999
output.txt
6: enp1s0f0.1999@enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 6c:4b:90:c0:e7:94 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 0 maxmtu 65535
    vlan protocol 802.1Q id 1999 <REORDER_HDR> addrgenmode none numtxqueues 1 numrxqueues 1 gso_max_size 64000 gso_max_segs 64 tso_max_size 64000 tso_max_segs 64 gro_max_size 65536 gso_ipv4_max_size 64000 gro_ipv4_max_size 65536

Verification: In the command output under the vlan section, look for reorder_hdr 1 or REORDER_HDR to confirm the flag is active.

References


Check out similar posts by category: Linux Ubuntu Networking EtherCAT