README.rst
1.. zephyr:code-sample:: vlan
2 :name: Virtual LAN
3 :relevant-api: vlan_api net_l2 net_if
4
5 Setup two virtual LAN networks and use net-shell to view the networks' settings.
6
7Overview
8********
9
10The VLAN sample application for Zephyr will setup two virtual LAN networks.
11The application sample enables net-shell and allows users to view VLAN settings.
12
13The source code for this sample application can be found at:
14:zephyr_file:`samples/net/vlan`.
15
16Requirements
17************
18
19- :ref:`networking_with_host`
20
21Building and Running
22********************
23
24A good way to run this VLAN application is with QEMU as described in
25:ref:`networking_with_eth_qemu`. You can use :file:`zeth-vlan.conf` configuration
26file when running :file:`net-setup.sh` script in Linux like this:
27
28.. code-block:: console
29
30 ./net-setup.sh -c zeth-vlan.conf
31
32Note that VLAN is only supported for boards that have an ethernet port or
33that support USB networking.
34
35Follow these steps to build the VLAN sample application:
36
37.. zephyr-app-commands::
38 :zephyr-app: samples/net/vlan
39 :board: <board to use>
40 :conf: prj.conf
41 :goals: build
42 :compact:
43
44The default configuration file :zephyr_file:`samples/net/vlan/prj.conf` creates
45two virtual LAN networks with these settings:
46
47- VLAN tag 100: IPv4 198.51.100.1 and IPv6 2001:db8:100::1
48- VLAN tag 200: IPv4 203.0.113.1 and IPv6 2001:db8:200::1
49
50Setting up Linux Host
51=====================
52
53The :zephyr_file:`samples/net/vlan/vlan-setup-linux.sh` provides a script that
54can be executed on the Linux host. It creates two VLAN interfaces ``vlan.100``
55and ``vlan.200`` on the Linux host and creates routes to Zephyr.
56
57If everything is configured correctly, you will be able to successfully execute
58the following commands on the Linux host.
59
60.. code-block:: console
61
62 ping -c 1 2001:db8:100::1
63 ping -c 1 198.51.100.1
64 ping -c 1 2001:db8:200::1
65 ping -c 1 203.0.113.1
66
67The network packets to ``2001:db8:100::1`` or ``198.51.100.1`` will have VLAN
68tag 100 set to them. The vlan tag 200 will be set to network packets to
69``2001:db8:200::1`` or ``203.0.113.1``.
70