Overview
Various network samples can utilize common code to enable generic features like VLAN support.
The source code for the common sample can be found at: samples/net/common.
VLAN
If you want to enable VLAN support to network sample application,
then add overlay-vlan.conf to your sample application compilation
like in this example for echo-server sample application:
west build -b native_sim samples/net/sockets/echo_server -- -DCONF_FILE="prj.conf overlay-vlan.conf"
west build -t run
You host setup for the VLAN can be done like this:
$ cd tools/net-setup
$ ./net-setup.sh -c zeth-vlan.conf
The example configuration will create this kind of configuration:
In host side:
Normal
zethinterface is created. It has192.0.2.2/24address. All the network traffic to Zephyr will go through this interface.VLAN interface
vlan.100is used for VLAN tag 100 network traffic. It has198.51.100.2IPv4 and2001:db8:100::2IPv6 addresses.VLAN interface
vlan.200is used for VLAN tag 200 network traffic. It has203.0.113.2IPv4 and2001:db8:200::2IPv6 addresses.
The network interfaces and addresses in Zephyr side:
The
eth0is the main interface, it has192.0.2.1/24address and it has connection to the host.The
VLAN-100is a virtual interface for VLAN tag 100 traffic. It has198.51.100.1/24IPv4 and2001:db8:100::1/64addresses.The
VLAN-200is a virtual interface for VLAN tag 200 traffic. It has203.0.113.1/24IPv4 and2001:db8:200::1/64addresses.
Warning
The IPv4 and IPv6 addresses used in the samples are not to be used in any live network and are only meant for these network samples. These IPv4 and IPv6 addresses are meant for documentation use only and are not routable.