VLAN - Interface and bridge question and setup

I think i'm confusing myself more than needed. So i've been wanting to segment my network little to make it more secure and i've done some VLAN a LONG time ago on cisco. I've watched videos and read some documentations and don't why it just don't stick and confuse me more.

The plan was i wanted to split it into 3-4 VLANs
VLAN 10 - Mgmt to maintain router, switch and access points
VLAN 20 - Home for daily PC
VLAN 30 - LoT devices which i do not wish to grain too much access to the whole LAN, but able to get WAN
VLAN 40 - which im unsure if needed or just overcomplicate stuff, which i though about placing my PI servers and media server

Current config is simple since i've not really had the time to configure and delve deeper into how to set it up more advanced. So it just Router with a simple bridge which contains the LAN interfaces. Same goes for the switch.

This is a diagram of how it sorta looks like now.

What i think that confuses me is how to get he VLANs setup correctly since there is the VLAN tab in Bridge and in Interfaces

Starting with Bridge VLAN.
When i press "New" under the Bridge VLAN tap. Then i have to select a Bridge. Does this mean that selected bridge and its interfaces get either tagged or untagged with the VLAN ID that is set?

Then there is Interface VLAN
Which i think confuses me the most. have the Interface VLAN, which needs a interface or bridge assigned.

Take like Cisco where you create a VLAN and name it and then assign it to a port.

Hope someone can explain or point me to something that would make it less confusion for me.

Thanks in advance

If you mean strictly layer 2 (switched) VLANs you create them in the bridge menu. Then you can assign it tagged or untagged to all ports you added to the bridge.

Interface - VLAN is like a tagged subinterface in a Cisco IOS router, not a switch. It doesn't help that e.g. a Cat 6500 can do both :slightly_smiling_face:

From bitter experience a lot of the material out there is useless for being downright confusing for telling you what buttons to press on obsolete versions of RouterOS and not explaining from a principles perspective.

My best advice is to read lots and watch lots and don't be put off. If something is not helpful, move on to the next, may be visiting everything 2 or 3 times. My own list of sources which helped me is:

Really helpful Mikrotik documentation Bridging and Switching - RouterOS - MikroTik Documentation [This is on the now unmaintained old help site]
A forum thread How to create most basic VLAN - Beginner Basics - MikroTik community forum
Another thread Using RouterOS to VLAN your network - Useful user articles - MikroTik community forum [This one is often oversold - it is somewhat useful for understanding vLANs but not so good for doing one yourself.]
A video by TheNetworkBerg https://www.youtube.com/watch?v=4BOYqtV4MCY
Another video https://www.youtube.com/watch?v=fFtA0IlnMVk
Post by Buckeye here Basic VLAN Access Port - #6 by Buckeye

The other advice I can give is only create 1 vLAN at a time until you are confident about the process. It is great that you have thought about all the vLANs you want, but don't overreach to start.

And here are the same example sections in the new manual site Bridging and Switching | RouterOS Manual.

If you have not read at least the first post of RouterOS bridge mysteries explained by sindy, then you should read it. Be aware that MikroTik has added dynamic configuration since that was written, so not all entried in the /interace bridge vlan section are required in special circumstances. For example, when a pvid is specified for a port in /interface bridge port, then the vlan specified by the pvid will have a "hidden" dynamic entry for the port in the untagged part of /interface bridge vlan. And when vlan interface is created under the bridge, then the bridge will be included as tagged in the /interface bridge vlan for the specified vlan.

It has been a while since I worked with Cisco switches. So my recollection may be inaccurate.

In a cisco switch, all the ports are preconfigured as being switch-ports, and in the default config all switch-ports are part of the pre-configured Default vlan (vlan 1) and are configured as access ports for vlan 1.

If you are going to use multiple vlans in a Cisco switch, you first need to add the vlan. This is setting up the vlan table of valid vlan values. Each vlan defined is like a vitural switch (or a separate pair of conductors in a cable). And different vlans are kept separate from each other, each vlan is it own broadcast domain. Only switch ports that are members of the vlan can communicate directy at the MAC L2 layer. Whether a port is set to use tagged or untagged for a specific vlan depends on the port setting; the broadcast domain is the same (and each defined vlan has its own broadcast domain). That's all well covered by Ed Harmouse's stuff from Basic VLAN Access Port - #6 by Buckeye

Some differences between Cisco (IOS) and Mikrotik (Linux)

In Cisco, the switch is always operating in vlan-aware mode, it just has a default config where all ports are members of the default vlan (1) and are configured as access ports (but may be allowed to become trunk port dynamically with Dynamic Trunking Protocol, something that can be exploited if not disabled)

In Cisco when you set the native vlan, it affects both ingress and egress traffic; untagged ingress traffic will be classfied as belonging to the native vlan, and any egress traffic for the vlan associated with the native vlan will be sent without a vlan tag. In MikroTik the ingress behavior and egress behavior are controlled separately. The ingress behavior is controlled by /interface bridge port (where PVID the port vlan ID - very similar to native vlan, or access vlan in Cisco, it is the IEEE 802.1Q spec's terminolgy for which vlan untagged ingress traffic will use in the switch). The egress behavior is controlled by the /interface bridge vlan section that controls the vlan table, and in recent versions (7.16+) of ROS there can be dynamic configurations of the vlan table.

Note that the /interface bridge port (primarily ingress related) and /interface bridge vlan (primarily egress related) sections deal with the virtual switch configuration, and the some of the things are only applicable when the vlan-aware bridge is entabled.

Unlike Cisco, the default configuration of the bridge is not vlan-aware, but it is vlan-transparent. I.e. it acts like a "dumb switch" that does not treat ethertype 0x8100 (the TPID Tab Protocol Identifier) as anything special, valid ethernet frames received will be forwarded as-is, ingress untagged will be forwarded as untagged on egress, tagged ingress will be forwarded as tagged on egress.

When vlan-aware mode is enabled (with /interface bridge vlan-filtering=yes), it fundamentally changes the behavior of the virtual switch, which will then process the vlan tag and ports can be set to use ether untagged or tagged traffic for a vlan.

I find it helpful to use a spreadsheet to plan the configuration, then creating the config from the spreadsheet is a straight forward translation. For example see the two threads:
Beginners journey into VLANs and its continuation VLANed home network, 2nd try

The vlan interface is like an SVI on cisco. It it the "router engine's connection" to a specific vlan in the switch. The vlan interface is two things, 1. the software data struction that the linux kernel communicates with; it is what has the ip address attached to. 2. it rewrites the frame to include a tag on egress traffic, and demultiplexes and removes the tag on ingress packets. Then the linux ip stack just has to be able to deal with one format without the tag.

See 2 ways to associate bridge and VLAN

Thanks all for the advice and links. I'll look more into it. But a small question to add.

For best practice for a homelab/home network, what options would be best

To configure/access devices on a managment vlan. Would you create a sorta local VPN that gives access to that vlan or give primary vlan (Home/PC clients) access to the VLAN?

You have TWO options/methods to stay on the safe side, corresponding to 1st and 2nd posts of this thread (without and with VLAN):
Once and for all COMPLETE Offbridge Port setup

In a business you would definitly want your management on its own vlan that most users would not have access to. There isn't a reason they would need management access to the switches or routers.

At home where you control who has access, then only you can decide if the extra security is worth the inconvenience of access. At my home, I have one vlan for most of the family that does not have access to any of the management, and another vlan for my stuff (used for my pc and management of switches).

I am not sure what you mean by VPN. When I use the term it usually in in reference to something leaving my home.

What I do for remote management is a combination of things. My PC that I normally use is in a tailscale network (tailnet) so I can connect to my home pc with remote desktop (RDP) over tailscale into my pc at home, and from there I can manage my network devices. But normally I am at the same location as the network equipment, so that is only used when I am not at home.

In your situation, I would configure the RB5009 with vlan interfaces for each of the vlans, and all inter-vlan routing would be done by the RB5009. I would also configure the switch in the RB5009 as vlan-aware (with vlan-filtering=yes); then you would be able to use the remaining ethernet ports as an extension to the ports on the CRS-310 (and be able to configure each port as access port for a specific vlan, or as a trunk, or you could remove a port from the bridge and use it as a "emergency access" port. e.g. see Once and for all COMPLETE Offbridge Port setup

When you are switching to vlan-aware mode the first time, its common to lock yourself out. Having a port that isn't part of the bridge is the closest thing to a console port that the RB5009 comes with. It is possible to configure without a dedicated port, but until you are familiar with how ROS works, have a port that is dedicated to emergency access is worthwhile. Once you understand things, it is less important.

So on the RB5009 (ether1 WAN will not be part of the bridge), for learning mode, I would also remove ether8 (then the port becomes an interface) see previous link for how this is done. The other ports (ether2-ether7 and SFP1 will be part of the bridge. I would start with the "defconf" where ether1 is WAN with firewall etc, and all other ports are part of the bridge. Then remove ether8, turn on vlan-aware mode, create vlan interfaces, dhcp servers etc. There are several threads about how to do this, in the technical topics tag (poorly named rtfum), the one that may be most useful for you is Tutorial: Home VLAN configuration (RB5009, cAP ACs, multiple SSIDs) although it does not have an attached switch, but the access points are similar (with a trunk connection). One thing I don't like about the tutorial, is that it starts from an empty config, and if this is your only router, it may be exposed to the internet without any firewall until that has been configured. I prefer to start with the defconf, then add the vlans, but I can't find a tutorial that has the procedure to do that. Here is another thread that does cover vlans on RB5009 Help with vlans on RB5009

The CRS310 should have only one vlan interface, the one used to manage it. The bridge should be setup in vlan-aware mode, and it will contain all ports (possibly removing one during setup, but since the CRS310 has a proper serial console port, that isn't as necessary; the console (which is compatible with the RJ45 cisco serial console) is your ultimate get out of jail free card.

On the CRS310 use the /interface bridge port and /interface bridge vlan to configure the vlans on the ports. But you want only a single vlan interface (SVI in cisco lingo) for the management, then the CRS won't try to route traffic between vlans. The SPF will be a member of all vlans, (probably with every vlan tagged). The bridge itself will have pvid 1 by default in defconf and the bridge will have ip address 192.168.88.1 (if you remove the ip address, it will make switching to vlan-aware mode a bit more complex.

On the RB5009 and the CRS310 for access, think about the vlans, not the ports. This is similar to the way that Cisco switch work, a port is a member of possibly multiple vlans, with each vlan in a separate broadcast domain and (usually) its own single subnet (so dhcp will work correctly).

If you get stuck, feel free to ask more questions, but you will probably be requested to provide more information (like a spreadsheet similar to what are in this post).

And as always, a sanitized export of your config, and an explanation of the problem. Useful guidelines for what is useful in a problem report here.

I think what he may be referring to is the practice of admin on a VLAN, but not routing that VLAN. Therefore, even internal admin access requires a local VPN connection (and possibly from outside, although that's not a given. Sometimes VPN to a system allowed to VPN to admin, login there, and then VPNto admin . . . . depends on how far you want to go.)

Some might consider it overkill for home, some might want to do it. The bottom line is that ROS will support any of these methods.

Myself, general users are on default VLAN 1, and my lab, admin, test equipment and a more "raw" internet access are on VLANs, and all are presented on trunks between switches and routers, and appropriate PVIDs set on ports for things like the test gear that are not VLAN aware. Using VLAN 1 also makes it harder to lock yourself out . . . .

Its good practice to have a management vlan that no one has access to except the admin himself, who may very well reside on a different vlan ( usually a home trusted vlan for example).

In addition every device should have IMO have an offbridge emerg access as well.

Through the use of interface lists and firewall rules, one limits access further to the management vlan and off port access.

Lets say home vlan admin is on, is vlan-home ( and never use vlan-id=1 bad juju, its the bridge glue already working in the background )

Then create an interface list of BASE
add interface=offbridgeportX list=BASE
add interface=vlan-home list=BASE
add interface=wireguard list=BASE.

neighours discovery is tied to BASE
tools mac-server max-winbox tied to BASE

Firewall address list includes
admin on pc
admin on laptop
admin on smartphone
admin on ipad
admin on laptop via wireguard
admin on smartphone via wireguard
all belonging to the firewall address list Authorized.
TWO RULES

add action=accept chain=input in-interface-list=BASE src-address-list=Authorized
add action=accept chain=forward in-interface-list=BASE src-address-list=Authorized out-interface-list=LAN

Uh, then why is it basically industry best practice, and taught by the majors? It was a standard config when I took my CCNA . . . . it's the default, you (well, I) don't tag it . . . Seems to work great and fast as well here . . .

1 - UNtagged

12 - tagged

13 - tagged

14 - tagged

15 - tagged

to clarify . . .

Probably the first major vendor, rolling out 802.1Q compatible switches, came up with this scheme and everybody else (and their dogs) followed down into same abyss. And since then nobody wants to piss against the wind hence this becoming "best practice" (even though it sucks ... but if everybody knows about it, it hurts the least).

Some vendors (who allow for less flexibility in their NOSes thanROS does) even hard-coded management to "native VLAN" with VID=1.

And, BTW, @anav was talking about not using VID 1 knowingly because it is all around default ROS config (so it's somehow still following the "best practice") ... and you don't want to piss against this wind and get your pants wet. If, OTOH, you feel lucky, you can go around and carefully change PVID and/or frame-types all around with something else ... and you'll break the spell and VID=1 will become as benign as half-dead viruses ... in best case it'll make your network stronger, in worst case it'll kill your network.

And of course there are reasons behind the Rules:
The twelve Rules of Mikrotik Club

I've read that (but it appears my equipmemt hasn't . . . never seen a single issue or interop problem). Also had no desire to rebuild an entire network based on it, again, when zero issues have been seen.

(And since I would need to set most switch ports to PVID 1 anyhow, it just made sense to start there in the first place.)

Folks say this config "sucks" but I have never heard an explanation why . . . Locking yourself out would appear to be more a user error, not an overall config issue.

Maybe I'm just lucky . . .

YMMV

Coming from Cisco I use VLANs 1, 2, 3, ... everywhere. But on trunk ports I only allow tagged frames or when the product in question does not permit that set the native VLAN or PVID to something unused in the entire layer 2 domain. Luckily Router OS has so far been flexible and reliable enough - no issues.

Just realised Nietzsche must have been talking about vLANs