This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down list at the bottom of the left panel and select the desired version.

Virtual LAN


The VLAN sample application for Zephyr will setup two virtual LAN networks. The application sample enables net-shell and allows users to view VLAN settings.

The source code for this sample application can be found at: samples/net/vlan.


Building and Running

A good way to run this VLAN application is with QEMU as described in Networking with QEMU Ethernet. You can use zeth-vlan.conf configuration file when running script in Linux like this:

./ -c zeth-vlan.conf

Note that VLAN is only supported for boards that have an ethernet port or that support USB networking.

Follow these steps to build the VLAN sample application:

west build -b <board to use> samples/net/vlan -- -DCONF_FILE=prj.conf

The default configuration file samples/net/vlan/prj.conf creates two virtual LAN networks with these settings:

  • VLAN tag 100: IPv4 and IPv6 2001:db8:100::1

  • VLAN tag 200: IPv4 and IPv6 2001:db8:200::1

Setting up Linux Host

The samples/net/vlan/ provides a script that can be executed on the Linux host. It creates two VLAN interfaces vlan.100 and vlan.200 on the Linux host and creates routes to Zephyr.

If everything is configured correctly, you will be able to successfully execute the following commands on the Linux host.

ping -c 1 2001:db8:100::1
ping -c 1
ping -c 1 2001:db8:200::1
ping -c 1

The network packets to 2001:db8:100::1 or will have VLAN tag 100 set to them. The vlan tag 200 will be set to network packets to 2001:db8:200::1 or