VLANs in OpenWrt 21

OneMarcFifty
21 Dec 202128:26

Summary

TLDRThis video script provides a comprehensive guide to VLAN configuration in OpenWrt 21, addressing changes from version 19 and introducing new features like Distributed Switch Architecture (DSA) and bridge VLAN filtering. It explains VLAN basics, how to define VLAN interfaces, and configure switch ports. The script also covers setting up a second access point, securing access points, and offers insights into OpenWrt's evolving architecture, ensuring viewers can effectively manage VLANs for network segmentation.

Takeaways

  • 😀 OpenWrt 21 still supports VLAN functionality in the same way as Version 19, despite changes in the user interface and configuration options.
  • 🔄 Two significant updates in OpenWrt 21 are the introduction of Distributed Switch Architecture (DSA) and bridge VLAN filtering, which alter the switch configuration and VLAN handling.
  • 📦 VLANs allow the use of a single physical Ethernet cable to carry multiple virtual networks, segmented by tagging packets with identifiers.
  • 🖇️ VLAN tagging involves adding an identifier to Ethernet packets to determine which network they belong to, akin to attaching a color-coded sticker to packets.
  • 🔌 OpenWrt can create VLAN-aware network interfaces, such as eth0.21 and eth0.56, for different VLANs, which can be connected to physical ports or WiFi networks.
  • 🛠️ The switch configuration in OpenWrt defines how VLANs are dispatched to Ethernet ports, while the VLAN definition itself is about tagging packets and creating interfaces.
  • 📚 OpenWrt 21 introduces a new way to define VLAN interfaces through the 'devices' tab, using VLAN 802.1Q as the device type, which simplifies the process.
  • 📡 For devices without integrated switch hardware, such as Raspberry Pis or virtual machines, VLANs can still be used in conjunction with a managed switch.
  • 🔒 OpenWrt 21's bridge VLAN filtering allows for VLANs to be assigned to a bridge rather than individual physical devices, enhancing flexibility in network segmentation.
  • 🛡️ Security considerations include disabling unnecessary routing on access points and avoiding the use of VLANs 0, 1, and 2 to prevent potential security risks.
  • 📈 Not all architectures in OpenWrt 21 utilize DSA, with some still using the traditional swconfig method, indicating a transition period for some devices.

Q & A

  • What was the general feedback from viewers regarding VLANs in OpenWrt 21?

    -The general feedback was that viewers were wondering where the VLANs went in OpenWrt 21, as everything seemed to have changed.

  • Has the VLAN functionality in OpenWrt 21 changed compared to version 19?

    -Surprisingly, the VLAN functionality in OpenWrt 21 has not changed at all; it still works exactly the same as in version 19.

  • What are the two new features introduced in OpenWrt 21 related to VLANs?

    -The two new features in OpenWrt 21 are Distributed Switch Architecture (DSA), which changes the switch configuration, and bridge VLAN filtering.

  • What is Distributed Switch Architecture (DSA) and how does it affect OpenWrt devices?

    -Distributed Switch Architecture (DSA) changes the way the switch portion of OpenWrt devices is configured, replacing the swconfig.

  • What is the purpose of VLAN tagging in Ethernet packets?

    -VLAN tagging is used to identify which LAN the packets belong to, allowing multiple virtual LANs to be run over a single wire or cable.

  • How can VLANs be defined in OpenWrt versions 19 and 21?

    -VLANs can be defined in OpenWrt by creating interfaces with a VLAN ID appended to the physical interface name, like eth0.21 and eth0.56 for VLANs 21 and 56, respectively.

  • What is the significance of the 'local' box in the bridge VLAN configuration in OpenWrt 21?

    -Ticking the 'local' box in the bridge VLAN configuration allows the VLAN to be used locally on the router to create interfaces, whereas unticking it means the VLAN can only be used on the switch.

  • How does OpenWrt 21 handle the configuration of VLANs differently from version 19?

    -In OpenWrt 21, VLANs are filtered on a bridge rather than on the physical device, and each switch port is shown as a separate network device, thanks to the DSA.

  • What is the difference between 'egress tagged' and 'egress untagged' in the context of VLANs?

    -'Egress tagged' means packets are sent out with a VLAN tag, suitable for connecting to VLAN-aware devices. 'Egress untagged' means packets are sent without a VLAN tag, suitable for connecting to non-VLAN-aware devices.

  • How can one prevent an access point from acting as a router in OpenWrt?

    -To prevent an access point from acting as a router, one can disable routing by setting the ipv4 forwarding flag to 0 and remove IP addresses from all but one interface.

  • Why is it advised not to use VLANs 0, 1, and 2 in OpenWrt?

    -VLANs 0, 1, and 2 are hard-coded on some devices for LAN and WAN and could potentially present a security risk, which is why it's advised not to use them.

  • What is the current status of the Distributed Switch Architecture (DSA) in OpenWrt regarding different architectures?

    -As of December 2021, not all architectures in OpenWrt are using DSA. Some, like the Archer C7, still use swconfig due to limitations in assigning switch ports to multiple Ethernet cards.

Outlines

00:00

📝 Introduction to OpenWrt 21 VLANs and DSA

The script begins with an acknowledgment of feedback regarding the disappearance of VLANs in OpenWrt 21. The narrator clarifies that VLAN functionality remains unchanged and introduces two new features in OpenWrt 21: Distributed Switch Architecture (DSA) and bridge VLAN filtering. The episode's agenda is presented, including a recap of VLANs, their purpose, and how they allow for multiple virtual LANs over a single wire by tagging Ethernet packets. The script also provides a brief on how VLANs can be configured in OpenWrt, comparing the process between versions 19 and 21.

05:07

🔌 Understanding VLAN Configuration and Switch Settings

This paragraph delves into the distinction between VLAN definition and switch configuration within OpenWrt. It explains how VLANs are created and how packets are tagged and dispatched to different Ethernet ports. The script outlines the process of defining VLAN interfaces directly through the network interface settings and highlights the flexibility of VLANs, even on devices without integrated switch hardware. It concludes with a call to action, inviting viewers to share their interest in seeing a video about using OpenWrt on a Raspberry Pi with VLANs over a managed switch.

10:07

🛠️ Configuring VLANs in OpenWrt 21 with Bridge VLAN Filtering

The script describes the changes in OpenWrt 21's interface for VLAN configuration, focusing on the new distributed switch architecture and the bridge VLAN filtering feature. It provides a step-by-step guide on defining VLANs, setting up a bridge, and applying VLAN filtering rules. The explanation includes the importance of the 'Local' setting for VLANs, which allows for local use of the VLAN on the router. The paragraph also discusses the implications of these settings for network segmentation and security.

15:08

🔄 Real-time Demonstration of VLAN Configuration Changes

The narrator provides a real-time demonstration of how VLAN configurations are reflected in OpenWrt's network configuration files. By using the 'diff' command, they show the changes made to the /etc/config/network file when VLAN devices and interfaces are defined or reset. This live example illustrates the direct impact of GUI configuration changes on the underlying system files, offering a transparent view of the VLAN setup process.

20:11

🌐 Extending VLANs and Wi-Fi Networks with a Second Access Point

This section outlines the process of extending VLANs and Wi-Fi networks to a second access point, which is configured as a 'dumb' access point without routing capabilities. The script explains how to set up VLANs on the second device, using the WAN port as an uplink and configuring the bridge for VLAN tagging. It also covers the setup of DHCP clients and Wi-Fi interfaces on the second access point, emphasizing the importance of security measures to prevent unintended routing between networks.

25:13

🔒 Security Considerations and Final Summary of OpenWrt 21 VLANs

The final paragraph addresses security considerations for VLAN configurations in OpenWrt, such as disabling routing on access points and managing IP addresses to prevent unauthorized network access. It summarizes the key points covered in the script, including the explicit and implicit definition of VLANs, the use of DSA, and the application of bridge VLAN filtering. The narrator also notes that not all architectures support DSA and provides guidance on choosing between DSA and the traditional swconfig method based on the device's capabilities.

Mindmap

Keywords

💡OpenWrt

OpenWrt is a flexible, open-source operating system for embedded devices such as routers. It is known for its extensibility and customization options, which include the ability to configure VLANs. In the video, OpenWrt is the platform used to demonstrate VLAN configuration from version 19 to version 21, highlighting the changes and updates in VLAN handling.

💡VLAN (Virtual Local Area Network)

A VLAN is a logically separate network within the same physical network infrastructure. It allows for the segmentation of networks to enhance security and organization. In the video, the concept of VLANs is central, explaining how to configure them in OpenWrt to create separate networks over a single cable.

💡DSA (Distributed Switch Architecture)

DSA is a feature in Linux that allows each port of a network switch to be treated as a separate network device. This changes the way VLANs are configured, as each switch port can be individually managed. The video discusses how DSA impacts VLAN configuration in OpenWrt 21 compared to previous versions.

💡Bridge VLAN Filtering

Bridge VLAN Filtering is a feature introduced in OpenWrt 21 that allows VLANs to be filtered on a bridge device rather than on the physical device. This provides a more flexible way to handle VLAN traffic. The video explains how to use this feature to assign VLANs to different network interfaces.

💡MAC Address

A MAC (Media Access Control) address is a unique identifier assigned to network interfaces for communications on a physical network segment. In the context of the video, MAC addresses are used to identify devices on an Ethernet LAN, which is fundamental to understanding how VLANs operate within the network.

💡Ethernet Packet

An Ethernet packet is the unit of data transmission in Ethernet networks, consisting of a header, source and destination MAC addresses, data, and a checksum. The video uses the Ethernet packet as an example to illustrate how VLAN tags are added to differentiate traffic belonging to different VLANs.

💡VLAN Tag

A VLAN tag is an identifier added to Ethernet frames to indicate the VLAN to which the frame belongs. The video explains that VLAN tags are used to segregate traffic on a single physical link, allowing multiple virtual networks to coexist.

💡Managed Switch

A managed switch is a device that can be configured to handle VLAN traffic, recognizing and forwarding packets based on their VLAN tags. The video mentions managed switches in the context of VLAN-aware devices that can receive and dispatch VLAN-tagged packets.

💡Luci

Luci is a user-friendly interface for OpenWrt that allows users to configure their devices through a web interface. The video uses Luci to demonstrate the steps for configuring VLANs in OpenWrt, showing the changes in real-time as they are made.

💡Firewall Zone

In the context of network security, a firewall zone is a logical grouping of network interfaces that are subject to the same security policies. The video discusses assigning VLAN interfaces to different firewall zones to control the flow of traffic between different network segments.

💡DHCP Server

A DHCP (Dynamic Host Configuration Protocol) server is responsible for assigning IP addresses to devices on a network automatically. The video explains how to configure VLAN interfaces to act as DHCP servers, providing IP addresses to devices within their respective VLANs.

💡Access Point

An access point is a device that allows wireless devices to connect to a wired network. In the video, setting up a second router as an access point involves configuring it to extend Wi-Fi coverage without routing traffic between VLANs, emphasizing the security measures to prevent unintended routing.

Highlights

VLAN functionality in OpenWrt 21 remains unchanged from version 19, despite significant changes in switch configuration and VLAN filtering.

Introduction of Distributed Switch Architecture (DSA) in OpenWrt 21 changes the switch configuration process, replacing swconfig.

New bridge VLAN filtering feature in OpenWrt 21 allows for more flexible VLAN configurations.

Explanation of VLAN basics, including how VLANs segment networks and the use of MAC addresses and packet tagging.

Demonstration of creating VLAN interfaces in OpenWrt, including the use of custom interface names and the significance of tagging.

Clarification on the difference between VLAN definition and switch configuration in OpenWrt.

The ability to use VLANs on devices without integrated switch hardware, such as Raspberry Pis or virtual machines.

Instructions on defining VLAN-aware network interfaces in OpenWrt versions 19 and 21.

How to configure VLANs using the new devices tab in OpenWrt 21 for easier setup.

Real-time demonstration of VLAN configuration changes in OpenWrt's network configuration file.

Differences in switch port representation in OpenWrt 19 versus the distributed switch architecture in OpenWrt 21.

Guide on implementing network segmentation using bridge VLAN filtering in OpenWrt 21.

Security measures for access points in OpenWrt, including disabling routing and managing IP addresses.

How to set up a second access point as a 'dumb' access point without routing capabilities.

The importance of not using VLANs 0, 1, and 2 due to hardcoded associations and potential security risks.

Summary of OpenWrt 21 VLAN capabilities, including explicit VLAN device definition and the use of bridge VLAN filtering.

Note on the availability of Distributed Switch Architecture (DSA) across different OpenWrt-supported architectures.

Transcripts

play00:01

Many of you left me comments for my OpenWrt VLAN videos.

play00:06

Many thanks for that.

play00:07

The general feed back was „Where have the VLANs gone in OpenWrt 21 ? Everything has

play00:14

changed.“

play00:15

Well, surprisingly enough – the VLAN functionality in OpenWrt 21 has not changed at all – it

play00:23

still works exactly the same like in Version 19, but two things are new in OpenWrt 21 – one

play00:30

is called Distributed Switch Architecture or DSA – which in fact changes the way we

play00:36

configure the switch portion of our OpenWrt devices and replaces swconfig – and the

play00:43

second profound change is bridge VLAN filtering.

play00:47

Stay tuned.

play00:51

(intro)

play00:55

Guys, here is the breakdown of this episode.

play01:01

Do not hesitate to use the chapter markers if you want to skip or fast forward.

play01:06

For those who have seen the previous videos, we do the Version 21 configuration at this

play01:11

time marker here.

play01:12

Many thanks.

play01:15

First let’s quickly recap what a VLAN is.

play01:18

A physical Ethernet LAN is basically a wire or cable.

play01:23

Data is sent over that wire in packets.

play01:27

Devices on the Ethernet are identified with MAC addresses.

play01:30

So a typical Ethernet packet would look like this.

play01:33

We have a small header, then the source MAC address and the destination MAC address, some

play01:39

more information and then the payload, so the data that we want to transmit.

play01:45

Plus a checksum at the end.

play01:47

This way every switch in the network knows where to send the data to.

play01:53

If we want to segment our Network let’s say into a guest zone and a LAN zone then

play02:00

we would hence need two wires.

play02:03

One Wire would go to the Guest WiFi access point and the other one to the LAN access

play02:09

point here.

play02:10

Or – we can do with one wire running two virtual LANs, two VLANs.

play02:17

Rather than pulling a second wire we use one wire and identify the packets inside with

play02:22

an additional tag in order to figure out which LAN they belong to.

play02:27

In essence it’s like putting a yellow or red or blue post it on the packets saying

play02:34

the blue packets belong to guest and let’s say the yellow packets are for the LAN.

play02:39

Of course we don’t do colors here but rather bits and bytes which we just insert into the

play02:45

packet here.

play02:46

A VLAN aware device like a managed switch or an OpenWrt Access point can then receive

play02:53

those packets and dispatch them to either a physical Ethernet port or to a separate

play02:59

WiFi Network.

play03:00

Just like we did in the Guest Wi-Fi video.

play03:03

In case you haven’t seen it – here is a link.

play03:07

Another way of thinking of VLANs is this: On your router you have physical Ethernet

play03:12

ports.

play03:13

You can plug in a wire to those.

play03:15

With VLANs you can create multiple virtual ports on one physical port.

play03:20

You can do pretty much everything with such a virtual port.

play03:24

You can even connect a virtual port to a physical port or to a Wifi.

play03:30

On Linux – you remember – OpenWrt is Linux - this can easily be done by defining interfaces

play03:37

that are attached to a physical interface like eth0 for example.

play03:42

If I wanted to call my VLANs 21 and 56 then I would create interfaces called eth0.21 and

play03:50

eth0.56 – that would tag the packets on one VLAN with 21 and with 56 on the other.

play04:00

We have seen that a VLAN can be used to run multiple networks over one wire or cable.

play04:05

The packets are assigned to the right network by an additional identifier that is inserted

play04:11

into the Ethernet packet.

play04:13

When a VLAN aware network device is attached to a physical device such as eth0 on linux,

play04:20

one can define it just by appending a dot and the VLAN number.

play04:24

Let’s see how to define those in OpenWrt.

play04:28

So – I told you in the beginning that this has not changed from Version 19 to Version

play04:33

21.

play04:34

Let’s have a look at Version 19.

play04:36

In my last videos I showed you how to do that in the switch menu.

play04:41

We went to Network – then switch and klicked on “add VLAN” and then we selected the

play04:47

parameters such as the VLAN ID and the ports which we wanted to have in the VLAN either

play04:52

tagged or untagged or not participating at all.

play04:57

This actually did a couple of things.

play05:00

It created the eth0.x interface and then updated the switch configuration to reflect the port

play05:06

assignment.

play05:07

So we defined the VLAN and we defined the switch configuration.

play05:11

Two distinct things here.

play05:13

The VLAN definition only tells the system to add an interface and tag packets.

play05:20

The switch configuration tells the system which VLAN has to be dispatched or distributed

play05:26

to which Ethernet port at the back of the device.

play05:30

The “proper” way of just defining the VLAN interface would have been to actually

play05:35

go to network –

play05:37

then interfaces,

play05:40

click edit on the desired interface,

play05:43

then go to the “Physical Settings” tab

play05:47

and then select or create the interface where we want to have the VLAN on and type it into

play05:53

the custom field down here directly.

play05:56

For example if I type eth0.123 that would create a VLAN 123 aware network device attached

play06:03

to eth0.

play06:06

We haven’t told the switch what to do with it or in other words – which port of the

play06:10

switch should actually use that VLAN – so why would we want to do it that way ? Well,

play06:16

think of hardware that does NOT have an integrated switch, such as your laptop or a raspberry

play06:22

Pi or a virtual machine or a container.

play06:25

You could in fact use VLANs on those devices and then attach a managed switch which would

play06:31

take care of the tagging and dispatching etc.

play06:36

So we have seen that the Network interface and the switch are two distinct parts of our

play06:40

Wifi-Router or generally speaking of our device.

play06:45

We know how to define VLAN aware devices and we know how to dispatch or distribute the

play06:51

VLANs across the ports of our switch.

play06:54

We also know that there are devices that do NOT have switch hardware, such as Raspberry

play06:59

Pis or Virtual Machines.

play07:02

That actually was the buzzword for a – CALL TO ACTION – I need you to get involved please.

play07:09

I have seen that there are a couple of videos here on YouTube about turning a Raspberry

play07:14

Pi into a router.

play07:16

There are also some about VLANs on the raspberry Pi.

play07:21

However, I found that they are either kind of klick here, klick there style without really

play07:26

explaining why or they tell you to use a USB Ethernet device.

play07:31

So here’s my question – would you be interested in seeing a video on how to use OpenWrt on

play07:36

the raspberry pi ? Presumably together with VLANs over a managed switch.

play07:42

Or maybe we can use it as a VPN gateway with Wireguard or I could think of integrating

play07:49

PiHole or Adguard.

play07:51

Let me know what you think.

play07:53

The same question can be asked with regards to virtual Machines – that means using OpenWrt

play08:00

with VLANs inside let’s say Proxmox – let me know if you would like to see anything

play08:05

of that kind.

play08:06

Please do leave me a comment!

play08:09

Thanks guys ! Let’s get back to OpenWrt 21.

play08:15

This device menu with the custom interface option still exists on OpenWrt 21.

play08:21

So we can do exactly the same like we did on Version 19 here in version 21.

play08:26

Or – there is a more comfortable way to do that on this new devices tab here.

play08:31

If we click on “Add device configuration” then we can select VLAN 802.1Q as the device

play08:38

type, select a base device, for example eth0 and specify the VLAN ID.

play08:45

You can see the device name that would be created here.

play08:48

while true; do clear ; diff network network.old ; sleep 1 ; done

play08:52

Actually let me try something here.

play08:55

I want to show you the changes in real time.

play08:59

The configuration of the network devices and interfaces which is read by OpenWrt at boot

play09:05

time is stored in the file /etc/config/network.

play09:12

I have ssh’d into the router, moved into the /etc/config folder, and I have taken a

play09:18

copy of that file.

play09:20

I just need the software package diffutils installed in order to have the diff command

play09:25

available.

play09:26

With this small one-liner here I am monitoring the changes of the file compared to the copy

play09:32

that I have just taken.

play09:34

That will make it clear what actually gets defined when we do changes in luci here.

play09:39

First I define the VLAN device in the device tab.

play09:42

Hitting save and apply creates that config device section in the file.

play09:47

On the command line we would do UCI commit.

play09:50

That actually saves the configuration.

play09:52

You can see the name, type and vid defined here.

play09:56

When I define the device on the interface then you can see those changes added in the

play10:02

config interface section in this option device line here.

play10:07

What happens if I reset the VLAN device config ?

play10:10

It disappears in the config file but is still listed in luci.

play10:14

So it is kind of an implicit configuration as opposed to an explicit definition in the

play10:19

first case.

play10:20

Both scenarios will work.

play10:22

Let me do the interface definition on Version 19 here and as you can see it is kind of the

play10:27

same result just the option name is not called device but rather ifname.

play10:35

We have just seen that we can define VLAN aware network interfaces in exactly the same

play10:40

way on OpenWrt versions 19 and 21.

play10:43

Now what HAS changed is how switch ports are presented to the user.

play10:49

In OpenWrt 19 we had the switch menu and could tag and untag the ports there.

play10:55

In OpenWrt 21 each port of the switch is actually shown as a network device, in this case lan1,

play11:02

lan2 and wan.

play11:04

So each of these devices corresponds to a port on the switch.

play11:08

This is called distributed switch architecture or DSA.

play11:12

If you want to know more about DSA and why it had been introduced then check out the

play11:17

Linux Kernel documentation.

play11:18

I’ll put a link into the description.

play11:21

Just so much that with DSA each port of the switch is now shown as a separate network

play11:26

device.

play11:28

Another thing that has changed is the fact that when we create an Interface such as GUEST

play11:32

or IOT or LAN, in Openwrt 19 we could say – this device is a bridge – directly on

play11:39

the interface.

play11:40

We could then select multiple devices that should be on that bridge from the dropdown

play11:46

in the physical settings tab.

play11:48

In OpenWrt 21 we don’t have that option any more.

play11:52

Here again we define a bridge on the devices tab under Network- Interfaces.

play11:58

The device type is “Bridge device” and the Ports of that bridge can be selected in

play12:02

the Bridge ports dropdown.

play12:05

By default you should at least have a br-lan bridge that bridges all the lan ports together

play12:11

of course.

play12:13

Cool – we already know a lot of things here.

play12:17

We know what a VLAN is, we know that there is a switch part and a network interface part

play12:21

in our system and we know how they are defined in the GUI.

play12:26

Now with this knowledge let’s see how we can implement the GUEST-IOT-LAN segmentation

play12:31

from the earlier videos in OpenWrt 21 – for this we will use the second new feature which

play12:38

is called bridge VLAN filtering.

play12:41

I want to define the following VLANs – 3 for the IOT network, 4 for the GUEST network

play12:49

and 99 for the LAN.

play12:53

I want to have all of them tagged on let’s say the lan1 port, I then want to have let’s

play12:58

say LAN on the lan2 port of the switch untagged.

play13:02

The wan port will remain the wan port connected to my ISP.

play13:06

I also want to have three Wi-Fi Interfaces attached to each one of those VLANs.

play13:12

So if a guest connects to the guest Wi-Fi then they should be on the guest VLAN and

play13:16

not see anything in my LAN.

play13:18

In the second step I will attach a second Access point to the lan1 port which covers

play13:24

let’s say the 2nd floor of my house and that should of course also have all three

play13:28

Wi-Fi’s.

play13:29

Guys, for the firewall configuration of this please see my earlier video . Link up here.

play13:36

Let’s go.

play13:38

The first thing that I do is that I define the bridge.

play13:41

By default all lan ports are bridged together.

play13:44

We will keep it that way and do the VLAN filtering later.

play13:47

Let’s go to Network – Interfaces – Devices tab – select the br-lan and click on configure.

play13:55

If there is no bridge, then click on “Add device configuration” down here and select

play14:00

bridge device as the device type and let’s call it br-lan.

play14:06

On the General device options tab make sure that the lan1 and lan2 port are selected in

play14:10

the bridge ports dropdown.

play14:12

If you have more lan ports then you can add them of course.

play14:16

Next, let’s select the “Bridge VLAN filtering” tab.

play14:20

Here we need to tick the box “Enable VLAN filtering” of course.

play14:24

Now we add the VLANs.

play14:26

We just click on Add three times and then let’s review the settings.

play14:31

Change the VLAN IDs to reflect the numbers which we want to use, so 3, 4 and 99.

play14:38

Tick the “Local” box next to each VLAN – I’ll explain that in a second.

play14:43

While you do this please make sure that your laptop or PC where you do that on is actually

play14:48

connected to the port that you want to have untagged on the LAN, in my case that’s lan2.

play14:55

Very important, otherwise you will be locked out.

play14:59

Quick remark here – if ever you lock yourself out – the easiest way of getting back in

play15:04

is to – do nothing.

play15:07

If the connection to the router is not re-established within 90 seconds after having clicked “Save

play15:12

and Apply” then Luci will revert the changes.

play15:16

So don’t click, unplug etc.

play15:18

Just wait a minute and a half and you should be back in business.

play15:22

Might be a life saver ;-)

play15:26

I want to have all VLANs tagged on the lan1 port – this is the port where we will connect

play15:32

the second access point later – so I select “egress tagged” on all VLANs on that lan1

play15:39

port.

play15:40

The VLAN 99 is my internal LAN so I set the lan2 port to “egress untagged” and also

play15:46

I select the “primary VLAN” tickbox – or “Port VLAN” as it should be called or

play15:52

as it is called – that’s actually the PVID on many switches.

play15:57

Do NOT click save and apply yet – we will need to let the LAN interface know about the

play16:04

new VLAN first.

play16:05

But first let me explain these settings.

play16:07

We need to take two aspects into consideration here: The first one is ingress vs. egress

play16:14

and the second one is tagged vs. untagged.

play16:18

When we select “t” or “egress tagged” on a port then this means that packets that

play16:23

we send to the VLAN 99 will also be sent out to that port.

play16:28

They will be kind of “dispatched” or “distributed” to that port.

play16:32

Outgoing – hence the word egress.

play16:35

The “t” means that we actually write the VLAN tag into the Ethernet packet.

play16:40

A non-VLAN-aware device would in fact not know what to do with such a packet, so we

play16:45

need a VLAN-aware device such as a managed switch or of course our access point at the

play16:50

other end.

play16:52

If we select “u” for “egress untagged” that means that we also write to that port

play16:58

but we do not add a VLAN tag.

play17:01

You could then attach a normal PC to that port and it wouldn’t ever know that it’s

play17:05

on a VLAN.

play17:07

In simple terms – if you have multiple VLANs going over a cable and you want to connect

play17:12

two switches or access points etc. then use tagged.

play17:17

If you just want to attach a laptop or PC to that port then assign it to one single

play17:23

VLAN and select “untagged”.

play17:25

So “untagged” actually means that we are assigning this single port to that VLAN without

play17:31

letting a connected device know that there is actually VLANs involved here.

play17:37

So far for egress.

play17:39

But what if a packet comes in ? How do we know which VLAN it belongs to ? Of course

play17:45

if there is a tag in the packet then we can assign it easily.

play17:50

But how about untagged packets ? This is what the PVID – the primary or port VLAN ID it

play17:57

should rather be called - does.

play18:00

On this lan port 2 we have set this on the VLAN 99.

play18:04

So every packet that comes in untagged will be assumed to go to VLAN 99.

play18:11

Perfect.

play18:12

Let’s save.

play18:13

Again - don’t save and apply yet.

play18:15

What happened here is that three new devices have been created.

play18:19

Br-lan.3, 4 and 99.

play18:23

So that’s a big difference compared to OpenWrt 19 – it’s not the physical interface such

play18:28

as eth0 that gets the VLAN id but it is the bridge.

play18:33

Next step is to actually assign that bridge to interfaces.

play18:36

And we need to do this before we apply, otherwise we will be locked out.

play18:41

So let’s go to the Interface tab.

play18:43

Click on edit next to the LAN interface.

play18:46

You can see that the Device is set to br-lan – we need to change this to br-lan.99 because

play18:53

our LAN will now be the VLAN 99.

play18:57

Now we can save and apply.

play18:59

Alternatively we can click on that “unsaved changes” icon in the upper right corner

play19:03

here and review the changes and click “Save and apply” there.

play19:07

If everything went well then you should be reconnected to your device.

play19:12

Just now you are on the VLAN 99 – but you don’t notice because the port that you are

play19:18

connected to is set to untagged.

play19:21

If you connected your PC to the lan port 1 you would not be able to connect.

play19:26

Perfect.

play19:28

This showed the first big change in Version 21 – VLANs can be filtered on a bridge rather

play19:33

than on the physical device.

play19:35

First we bridge all the switch ports and then we tell the bridge where to assign the VLANs

play19:40

to.

play19:41

Actually, shall we quickly compare the Version 19 switch tagging to the version 21 bridge

play19:46

vlan filtering from a config file perspective ? Let’s monitor both network configs on

play19:51

this Version 19 and this version 21 router.

play19:55

First the switch on Version 19.

play19:58

Then the bridge on Version 21.

play20:03

Now the interface on Version 19.

play20:07

And the interface on Version 21

play20:11

So you can see here that the config option is called switch_vlan in version 19 and bridge-vlan

play20:18

in version 21.

play20:20

Awesome – now let’s add the other interfaces and the WiFi interfaces.

play20:24

Click on add new interface for each one of them, select the br-lan.x device to be the

play20:29

physical device and assign it to the right firewall zone.

play20:33

Also we want each one of them to act as a DHCP server on different IP address ranges.

play20:39

Again – firewall setup is in an older video.

play20:42

Next we go to Network-Wireless and create the corresponding wireless settings.

play20:47

Now here is another change in OpenWrt 21 – in order to assign the WiFi to the right network

play20:53

you need to open that dropdown box here that reads “Network” and tick the box next

play20:58

to the right network.

play20:59

Guys, for Wireless setup see my two videos about WiFi fast roaming and the other one

play21:06

about how to add a second Access point to an existing network – the links are up here

play21:10

again and in the description.

play21:13

Thanks.

play21:14

Cool.

play21:16

That’s all on the first router.

play21:18

Oh – hang on – you remember that I told you to tick that “local” box next to the

play21:22

VLANs in the bridge VLAN configuration ? Let’s see what happens if we don’t do this.

play21:27

Let me add another VLAN 55 here and NOT tick the box.

play21:32

As you can see, no br-lan.55 has been created, so we can tag or untag that VLAN on the switch

play21:41

but we can not use it locally on the router to create an interface.

play21:44

That’s the difference.

play21:48

Now we know so many things – how to define the VLANs on the bridge, how to tag or untag

play21:54

them on the bridge, we know how to assign Interfaces to a VLAN and we know how to hook

play21:59

up W-Fi to them.

play22:01

Let’s move to the second device now.

play22:06

The second router should act as an access point only – a “dumb” access point as

play22:11

it’s often called in the OpenWrt forums.

play22:15

That means that it should NOT act as a router and NOT serve IP addresses over DHCP and also

play22:21

it should not have a firewall.

play22:24

The basic steps are actually outlined in this older video here – how to extend a Wifi

play22:30

to a second access point so I will not go over all of them.

play22:35

Just the high level overview here.

play22:37

On the VLAN side the configuration is quite similar.

play22:41

In my case I want to use the wan port as the uplink to the main router so rather than having

play22:46

everything tagged on lan1 I’ll move that to wan – but it doesn’t really matter

play22:52

– the wan port is just another switch port – very much like the lan ports – and we

play22:58

are totally free to assign it to one VLAN or the other.

play23:02

In fact, naming it lan or wan is just a convention.

play23:05

I could as well call them Fritz or Hans or Otto.

play23:10

Let’s remove the wan and the wan6 interface and then go back to the br-lan bridge, add

play23:18

the wan port and tag the port there accordingly on the Bridge VLAN configuration.

play23:24

Once this is set up then the final result should look like this: three interfaces, again

play23:30

called GUEST, IOT and LAN on br-lan.4,3 and 99.

play23:37

If we set those interfaces to be DHCP clients then each one of them should get an IP address

play23:42

from the router out of the respective IP address range.

play23:46

We set up the Wi-Fis with the same SSID and passwords like on the first one but you may

play23:52

use different channels here.

play23:53

Again – that’s very well outlined in my WiFi fast Roaming video.

play23:58

Actually I have a whole playlist of videos about OpenWrt – the link is up here.

play24:03

You might want to bookmark that or actually subscribe to my channel and check out the

play24:07

channel page.

play24:08

All links are in the description as well.

play24:12

Cool.

play24:14

Now we have a real network.

play24:16

We have a main router with access to the internet, we have three VLANs going over one single

play24:22

wire to a second access point which extends our three Wi-Fi networks for example to another

play24:29

floor in the house.

play24:32

Once we have checked everything there are however a couple of things that we should

play24:36

do on the access point for security reasons.

play24:39

The access point still thinks that it should act as a router.

play24:42

As we have no firewall here that means if someone changed his or her default gateway

play24:47

to be that access point then they would actually potentially be able to route from one network

play24:53

to the other.

play24:55

In order to prevent that we can do two things:

play24:58

First, we disable routing on that access point by setting the ipv4 forwarding flag to 0.

play25:06

Second, we can also remove the IP addresses from all but one interfaces.

play25:13

If there are no IP addresses on that device then it can’t route.

play25:17

You need to keep one however in order to be able to access luci.

play25:21

We do that by setting the protocol to “unmanaged” on the IOT and GUEST and just keep dhcp client

play25:28

on the LAN interface.

play25:30

Now we can still access luci over the LAN address but the access point has become invisible

play25:35

from an IP standpoint in the other networks.

play25:40

Yet another tip here – don’t use VLANs 0, 1 and 2 – they are hard coded on some

play25:46

devices for LAN and WAN and could also potentially present a security risk.

play25:53

So – let’s sum this all up.

play25:56

Here is what we now know about VLANs and so on in OpenWrt 21:

play26:01

First – VLANs can be explicitly defined as VLAN 802.1Q devices under Network-Interfaces

play26:08

then device tab or implicitly on the Interface by typing in the device name into the custom

play26:15

field.

play26:17

Second – the Distributed Switch architecture DSA shows every port of the switch as a network

play26:23

device, for example lan1, lan2 and wan

play26:26

Third – VLAN filtering can be done on the bridge by selecting the “Bridge VLAN Filtering”

play26:34

tab.

play26:35

This will generate devices like br-whatevername.x

play26:39

Last but not least – we know how to attach interfaces and Wi-Fi’s to those VLANs and

play26:44

we know how to do basic security on the access point.

play26:48

Awesome – that’s pretty much it – Oh – maybe one last thing.

play26:54

At the time of making this video, that is in December 2021, not all architectures are

play27:00

using the Distributed switch architecture DSA.

play27:03

Some of them still use swconfig, that means the “old” way of assigning VLANs to switch

play27:10

ports.

play27:11

One example is the Archer C7, a very popular router for OpenWrt.

play27:15

One of the reasons is that on devices with multiple Ethernet cards, like eth0 and eth1

play27:22

in the Archer C7, currently there is no way with DSA to assign the switch ports to one

play27:28

or the other interface.

play27:29

So I guess we will just have to wait on those.

play27:31

I’ll see if I can find a page on the OpenWrt web site that summarizes the supported architectures

play27:38

and put into the description.

play27:40

You will actually have to decide if you only use one card and DSA or if you want to use

play27:46

VLAN distribution to the switch the old way.

play27:51

Guys – that’s it for today, many thanks for liking, subscribing and sharing the video

play27:57

with others.

play27:58

Please don’t forget to leave a comment.

play28:01

Many thanks for watching – stay safe, stay healthy, bye for now.

Rate This

5.0 / 5 (0 votes)

Related Tags
OpenWrtVLANNetworkConfigurationDSABridgeEthernetSwitchAccess PointSecurity