VLAN - help with setting up

Hello all Mikrotik enthusiasts, I would like to turn to you in moments of utmost need :smiley: and many attempts at setup. As you may already know from the title I would need help with setting up VLANs, I have tried many videos, done many tests but still unsuccessful.
What is involved and old and new tutorials.

So to the point, I am now using these three wonderful devices:
Mikrotik-RB5009Pr+S+IN (main router, PPOE connection)
Mikrotik-CRS112-8P-4S-IN (switch connected to the router via SFP+)
Mikrotik-cAP ax (Main Wi-Fi, CAps)

Local Setup (LAN):
10.0.0.0 / 8 (DHCP)

Router: 10.0.0.1 (PPOE Eth1) [version → 7.14]
Switch: 10.0.0.2 (Router SFP+ → SFP 9) [version → 6.49.13]
Wi-Fi (cAP ax): 10.0.0.3 (Router Eth8 → Eth1) [version → 7.14]

I set all the devices I have in my home to a fixed IP address but I would also like to put them in a VLAN so I can then set individual rules for the groups.

The VLAN should be as follows:
VLAN 1 - 10.1.0.0/8 (Router and Switch / Cameras)
DHCP 1 - 10.1.0.1-10.1.0.254
VLAN 2 - 10.2.0.0/8 (All connections from Switch)
DHCP 2 - 10.2.0.1-10.2.0.254
VLAN 3 - 10.3.0.0/8 (Wi-Fi Devices / Mobiles)
DHCP 3 - 10.3.0.1-10.3.0.254
VLAN 4 - 10.4.0.0/8 (Wi-Fi devices / IoT )
DHCP 4 - 10.4.0.1-10.4.0.254
VLAN 5 - 10.5.0.0/8 (Router / Servers Eth3, Eth4)
DHCP 5 - 10.5.0.1-10.1.255.254
VLAN 6 - 10.6.0.0/8 (Wi-Fi devices / laptops)
DHCP 6 - 10.6.0.1-10.6.0.254

Do I have to set all this up from the terminal or is the Winbox application sufficient ?
I have currently tried the following tutorials →

https://www.youtube.com/watch?v=4Z32oOPqCqc&t=984s
https://www.youtube.com/watch?v=3QKSQepqZac
https://www.youtube.com/watch?v=US2EU6cgHQU
https://www.youtube.com/watch?v=4BOYqtV4MCY

No matter how I tried, I always died at the point that the individual devices were still connecting to the basic configuration / bridge but no access to the outside (WAN) was working at all
Yes I have also visited the documentation from Mirkotik but I am not very wise from it, it shows more on the terminal than using Winbox.

If you need more information I’ll be happy to provide if you say which ones and how to get them :slight_smile:

Winbox is fine for setting up VLANs.

Strongly suggest avoiding VLAN 1. Many devices treat VLAN 1 as something special (usually without telling you).

Please don’t post screen captures to show your configuration. Export and post your configuration.
To export and paste your configuration (and I’m assuming you are using WebFig or Winbox), open a terminal window,
and type (without the quotes) “/export hide-sensitive file=any-filename-you-wish”. Then open the files section
and right click on the filename you created and select download in order to download the file to your computer.
It will be a text file with whatever name you saved to with an extension of .rsc. Open that file in your favorite
text editor and redact any sensitive information if desired / needed. Then in your message here, click the code
display icon in the toolbar above the text entry (the code display icon is the 7th one from the left and looks
like a square with a blob in the middle). Then paste the text from the file in between the two code words in brackets.

The VLAN should be as follows:
VLAN 1 - 10.1.0.0/8 (Router and Switch / Cameras)
DHCP 1 - 10.1.0.1-10.1.0.254
VLAN 2 - 10.2.0.0/8 (All connections from Switch)
DHCP 2 - 10.2.0.1-10.2.0.254
VLAN 3 - 10.3.0.0/8 (Wi-Fi Devices / Mobiles)
DHCP 3 - 10.3.0.1-10.3.0.254
VLAN 4 - 10.4.0.0/8 (Wi-Fi devices / IoT )
DHCP 4 - 10.4.0.1-10.4.0.254
VLAN 5 - 10.5.0.0/8 (Router / Servers Eth3, Eth4)
DHCP 5 - 10.5.0.1-10.1.255.254
VLAN 6 - 10.6.0.0/8 (Wi-Fi devices / laptops)
DHCP 6 - 10.6.0.1-10.6.0.254

Problem right there. You are defining each of your IP ranges as /8. That means all of your ranges as defined are all 10.0.0.0 - 10.255.255.255. Based on what you are showing for the IP ranges, it would appear that you really are aiming for /16 address ranges. Do you REALLY need 64K addresses in each VLAN?

Hello archmatts,

Sorry for the long answer.

Let’s start with VLANs.

VLAN 0 and 4095 are reserved for other purposes according to the RFC.

You got a good suggestion in that VLAN 1 should be avoided. The explanation for this is a bit more involved. Cisco in their very popular and excellent Catalyst switches treated this as special, and many - bit not all - manufacturers of switch chips copied this design decision. If you introduce at any point a switch that uses such a chip into your network, you’re looking at hours of fun trying to understand why your network does not behave as it should. What adds to the fun is that it is usually not apparent from either the datasheet or manual of the product what their behavior is with relation to VLAN 1. (Cisco at least documented it thoroughly.)

As to IP allocations, let’s start with the RFC1918 ranges. There are three of them:
192.168.0.0/16
172.16.0.0/12
10.0.0.0/8

There is a convention as to their uses. This is not specified in any standard, but they are usually observed by network engineers all over the world.
192.168 region is used for home / small office networks
172.16-31 is used for VPN connections
10 is used by large - I mean several hundred employees / devices spread over tens of locations, which they all want to interconnect.

If I understand your use case correctly, you should use the 192.168 region.

Your IP numbering is simply wrong - and as stated will not work at all. This is my suggestion:

VLAN 20
subnet: 192.168.152.0/24
DHCP region: 192.168.152.11-192.168.152.253

VLAN 30
subnet: 192.168.153.0/24
DHCP region: 192.168.153.11-192.168.153.253

VLAN 40
subnet: 192.168.154.0/24
DHCP region: 192.168.154.11-192.168.154.253

(and so on)

The reason I suggest using the 11-253 region for DHCP in each of them:

  1. Usually either .1 or .254 is the gateway (the address of the router on the subnet.) In fact you didn’t leave a single address for gateway.
  2. I usually like for routers switches and other network devices static addresses. This configuration leaves you with at least 10 addresses for this purpose. (I like static configurations, because if something doesn’t work and you need to troubleshoot, then it is quite lot easier to do it if your network devices have static configurations and a re reachable by IP. Otherwise quite often you have to take them out of the rack/cabinet/top of the shelf and that is simply a pain.)

Best of luck.

No, I don’t need to, but it’s also part of my personal training, I just want to re-select every type of device on the network :slight_smile: so I need to learn and find out the many options :slight_smile: , yes it’s not necessary but I just want it :smiley:

And for the answer i tried it on first time with /16 or /24 mask but i had same results then, so i give to a try to /8 if something happend and just post it as example of my last try :smiley:
Thank you for your time and support :slight_smile:

I didn’t know that, I learn something new every day, thank you. Next time I’ll be much more careful about safety, it was midnight and I was ready for bed so I didn’t have time to blur what I should have :confused:

Hell yeah ! :smiley: No need to apologize for the long post. For me it’s better to get an explanation of what’s going on and what’s not. I’m familiar with the ip range and its uses as you wrote, I just like the last option for large companies because you have the options of splitting it into multiple and thus for me to remember, for my use it would really be enough to use the range for home networks but I just don’t like the numbers :smiley: :smiley: Just a personal thing but I’ll give it a try :slight_smile:

Yes there will be endless torment and stress for my girlfriend as to why the internet is not working but ! somewhere you have to learn and I have tried on virtual machines before only it’s not the same, the reality is different then.

I didn’t know that, I learn something new every day, thank you. Next time I’ll be much more careful about safety,

Safety is not so much the issue - although there are a few things not to make public. The far bigger issue is that trying to read a bunch of screen captures is very often hard to read and secondly often omits important data. Please export and post your config as instructed above.

You are absolutely free to choose which range to use. :slight_smile: I was just referring to what’s usual. There is no standard to adhere to here.

The bigger problem, and what I was trying to illustrate is this: The subnets must have IP ranges that do not overlap.

Now, 10.0.0.0/8 means: all addresses, whose first 8 bits match this pattern. Only the first 8 bits are relevant, therefore it is customary to give 0 for the other bits. (Although many routers will happily accept any form, nevertheless only the first 8 bits are relevant.)

It follows then that 10.1.0.0/8 is canonically written as 10.0.0.0/8. As is 10.2.0.0/8 written as 10.0.0.0/8. -Both subnets have the exact same IP range. This is not correct and will not work.

If you wish to distinguish between the two ranges, you can write - for example - 10.1.0.0/16 and 10.2.0.0/16. Here the /16 means that the first 16 bits are meaningful (in that they are matched), and therefore you have two distinct IP ranges which do not overlap. Now this will work.

This notation btw is called CIDR notation and if you are still unsure, you will find countless resources on the web explaining the concept. For this the standards document is RFC 1519 - though these are not so useful for learning, rather as a reference.

Yes, I know, and thank you for your help.
I had time to play with it again today and got the result finally :smiley:.

I changed the IP range completely → 192.168.0.0/16
Hold I copied the original network design I had laid out and redid only the addressing.

According to the previous communication, I also changed the VLAN numbering
Now I have the VLANs as follows:

VLAN10
192.168.10.0/24
Gateway: 192.168.10.1
DHCP: 192.168.10.10-192.168.10.254

VLAN20
192.168.20.0/24
Gateway: 192.168.20.1
DHCP: 192.168.20.10-192.168.10.254

and so on, up to 70 for a total of 7 VLANs, but currently I’m going to figure out how to make some VLANs see others/can communicate together and some not at all.
Currently I can see the device / can communicate with it if we are in the same VLAN.
But I would need for example VLAN10 to communicate with VLAN30 bilaterally but for example VLAN10 with VLAN20 only unidirectionally.

I greatly appreciate your reply and thank you very much for your help.

Congrats! You’re done with the first step.

The next step - as you have correctly realized - is setting up the firewall correctly.

By default (if there are no filter rules) the router will route whatever it can. It’s eager in that way.

There are many ways to set up a correct firewall; and unfortunately many more to do so incorrectly.

Some try to write rules that block unwanted traffic, and some block all traffic by default and only allow what is explicitly specified.

For home and corporate networks (of any size) I strongly believe that only the second one is acceptable.

This means that the last rule in both the input and forward chains should be to drop all:
/ip/firewall/filter
add chain=input action=drop
add chain=forward action=drop

Of course if we only have these, then everything gets dropped. To get started, I would suggest that for the while that you are configuring things, you set up a port (I usually use the last port) as an “admin” port, from which everything is allowed. Let’s say it’s ether7.

Make sure that that port is not part of a bridge.

Then out rules will look line this:
add chain=input in-interface=ether7 action=accept
add chain=input action=drop
add chain=forward in-interface=ether7 action=accept
add chain=forward action=drop

Actually, if you really want to understand things, then this is where I would start out from.

The next natural rule that we add is to allow established connections to continue. For example you wrote “VLAN10 to VLAN20 only unidirectionally” - surely here you meant that if someone from VLAN10 makes a request to someone in VLAN20, than it may answer: that is what we mean by allowing established connections.

Now we are here:
add chain=input in-interface=ether7 action=accept
add chain=input action=accept connection-state=established,related
add chain=input action=drop
add chain=forward in-interface=ether7 action=accept
add chain=forward action=accept connection-state=established,related
add chain=forward action=drop

If we want to allow for example VLAN10 to make DNS queries we do it in the following way. (DNS uses port 53 both UDO and TCP.) This is a traffic destined for the router, therefore we use the input chain.

add chain=input in-interface=ether7 action=accept
add chain=input action=accept connection-state=established,related
add chain=input protocol=udp dst-port=53 src-address=192.168.10.0/24 action=accept
add chain=input protocol=tcp dst-port=53 src-address=192.168.10.0/24 action=accept
add chain=input action=drop
add chain=forward in-interface=ether7 action=accept
add chain=forward action=accept connection-state=established,related
add chain=forward action=drop

This should be repeated for all traffic.

However let’s assume that you also want VLAN20, or probably all of your VLANs to have access to DNS. We can of course repeat these two rules 7 times, but well that’s just daunting.

A more appropriate solution is to create an address list of who is allowed to access DNS, let’s call it dns-allowed. Populate it appropriately, and then use that in our rules:

add chain=input in-interface=ether7 action=accept
add chain=input action=accept connection-state=established,related
add chain=input protocol=udp dst-port=53 src-address-list=dns-allowed action=accept
add chain=input protocol=tcp dst-port=53 src-address-list=dns-allowed action=accept
add chain=input action=drop
add chain=forward in-interface=ether7 action=accept
add chain=forward action=accept connection-state=established,related
add chain=forward action=drop

Now for this to be a correct example, we have to add a two rules that do not follow this pattern. One for the DHCP server, and one for loopback. I will not explain these in detail. It’s also considered well-mannered to reply to ICMP messages.

add chain=input in-interface=ether7 action=accept
add chain=input action=accept connection-state=established,related
add chain=input in-interface=lo action=accept
add chain=input protocol-icmp action=accept
add chain=input protocol=67 in-interface-list=LAN action=accept
add chain=input protocol=udp dst-port=53 src-address-list=dns-allowed action=accept
add chain=input protocol=tcp dst-port=53 src-address-list=dns-allowed action=accept
add chain=input action=drop
add chain=forward in-interface=ether7 action=accept
add chain=forward action=accept connection-state=established,related
add chain=forward action=drop

This is a working configuration. Play with these.

After you are familiar with these concepts, the next step is to configure VLAN-toVLAN communication. For this first you have to actually know what you want. Draw a table for yourself labelling the rows with your networks (WAN, VLAN10, VLAN20, …) and the columns as well. For any communication that you wish to permit from interface in a given row to interface in a given column, put an X.

If you have this plan, then you can create (for example) an address list for each of your VLANs (WAN-allowed, VLAN10-allowed, VLAN20-allowed, …) and replicating the example for DNS, specify a rule for them. Just as a reminder, this is traffic that router forwards, so the forward chain will be used; and of course we don’t only wish to allow TCP and UDP but any protocol, so the protocol field will be omitted.

Have fun!

Hello friend in arms :slight_smile: , I’ve been up all night fretting and testing but unfortunately unsuccessfully.

I have no idea where I’m currently going wrong even though I’ve moved forward :smiley:, I’m posting the settings as I have them.

I currently need to somehow achieve / learn where the devil is buried :smiley:.

So simply in points:

  1. VLAN10 should access VLAN20 (a basic one that is missing somewhere..)
  2. VLAN20 should not access VLAN10 without initial contact from VLAN10
  3. All VLANs 10-70 have access to DNS say 9.9.9.11 or 1.1.1.1

I have tried the options to disable even all the preset values in the firewall which reject, I have also tried deleting everything and making only positive accesses between VLANs but also no response, I have tried different places in the priority ladder and also did not help although sometimes I intercepted a request but the machine/server did not respond back while having no VLANs communicating with each other without any problem.

Maybe you or someone else knows the answer to my dilemma :smiley:
But a really huge thank you for everything you’ve done for me :slight_smile:
Yggdrasil.rsc (14.1 KB)

So I woke up and tried one more thing to do it differently and that was the main router range which was 192.168.0.0/16 change the mask to /24 then the connection and VLAN works as it should / firewall rules, I think the problem was in the mask because when I searched 192.168.20.10 (ping) then I still tried the /16 mask range … not /24 for the VLAN range.
We’ll see :smiley:

It’s really a new adventure for me and it makes me happy when after many struggles everything works and I know why :smiley:
Yggdrasil_VLAN.rsc (13.9 KB)