Basic VLAN configuration and DHCP

I think I’ve managed to set up VLAN 10 on trunk port ether8, to which I have connected a wireless access point that tags a specific network with VLAN ID 10. I’m able to connect to it and get an IP in the 10.0.10.x range. If I connect to another wireless network that has VLAN ID 11, I don’t get an IP (which is expected since VLAN 11 is not configured on the router).

The (apparently working) config is:

/interface bridge
add name=switches vlan-filtering=yes
/interface ethernet
set [ find default-name=sfp-sfpplus1 ] auto-negotiation=no speed=1Gbps
/interface vlan
add interface=ether8 name=vlan10 vlan-id=10
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=local ranges=10.0.0.10-10.0.0.254
add name=vlan10 ranges=10.0.10.2-10.0.10.254
/ip dhcp-server
add address-pool=local interface=local name=local
add address-pool=vlan10 interface=vlan10 name=vlan10
/interface bridge port
add bridge=local comment=defconf ingress-filtering=no interface=ether2
add bridge=local comment=defconf ingress-filtering=no interface=ether3
add bridge=local comment=defconf ingress-filtering=no interface=ether4
add bridge=local comment=defconf ingress-filtering=no interface=ether5
add bridge=local comment=defconf ingress-filtering=no interface=ether6
add bridge=switches disabled=yes frame-types=admit-only-untagged-and-priority-tagged interface=ether7 pvid=10
add bridge=switches ingress-filtering=no interface=ether8
/ip neighbor discovery-settings
set discover-interface-list=LAN
/ip settings
set max-neighbor-entries=8192
/ipv6 settings
set disable-ipv6=yes max-neighbor-entries=8192
/interface bridge vlan
add bridge=switches tagged=ether8 untagged=ether7 vlan-ids=10
/interface list member
add comment=defconf interface=local list=LAN
add comment=defconf interface=ether1 list=WAN
/ip address
add address=10.0.0.1/24 interface=local network=10.0.0.0
add address=10.0.10.1/24 interface=vlan10 network=10.0.10.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=10.0.0.0/24 comment=defconf dns-server=10.0.0.1 gateway=10.0.0.1 netmask=24
add address=10.0.10.0/24 comment=vlan10 dns-server=10.0.10.1 gateway=10.0.10.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=10.0.0.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" disabled=yes in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related disabled=yes hw-offload=yes
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN

However, when I change the interface that vlan10 is on from ether8 to “switches” (my bridge is called that), I am no longer able to get an IP after connecting to the network.

/interface vlan
add interface=switches name=vlan10 vlan-id=10

The client’s MAC shows up under Bridge > Hosts with VID 10. It didn’t previously show up here before the vlan interface change, which makes sense since it only lists bridges.

Some things I’m confused about:

  1. I don’t understand why the above change leads to different behavior. “switches” is a bridge with only ether8. Shouldn’t I be able to connect and get an IP like when the vlan interface was set to ether8?
  2. Some VLAN setup guides I’ve looked at don’t add VLANs under “/interface vlan”. https://help.mikrotik.com/docs/display/ROS/Bridge+VLAN+Table only adds the management VLAN there, but none of the others. How come?
  3. If a VLAN is not added under “/interface vlan”, how can I run a DHCP server on it that is specific to that VLAN?

Thank you!

  1. If you have VLAN interface on bridge, that bridge must be listed as tagged interface, i.e. tagged=switches,ether8 instead of your tagged=ether8.
  2. You need VLAN interface only when router itself needs to access that VLAN. If for some VLANs it works only as managed switch and doesn’t otherwise interact with other devices in them, it doesn’t need VLAN interfaces for them.
  3. You can’t. So if you want to, you need VLAN interface for that VLAN.

Please read LINK C. from here - https://forum.mikrotik.com/viewtopic.php?t=182373

It works! :partying_face:

One thing I still wonder is:

/interface bridge port
add bridge=vlans comment="Base/Management Access Port" frame-types=admit-only-untagged-and-priority-tagged interface=ether3 pvid=1000
add bridge=vlans interface=ether8 pvid=1000
/interface bridge vlan
add bridge=vlans tagged=vlans,ether8 vlan-ids=10
add bridge=vlans tagged=vlans vlan-ids=1000 <-- Notice: Nothing under untagged.
add bridge=vlans tagged=vlans,ether8 vlan-ids=11

VLAN 1000 has a pure access port (ether3) and a hybrid port (ether8). The entry in

/interface bridge port

already specifies

pvid=1000

. ether3 and ether8 both show up under “Current Untagged” in Bridge > VLANs, so I’m curious if there is any reason to specify them explicitly as untagged in the

/interface bridge vlan

config?

Technically you don’t have to specify untagged ports under /interface bridge vlan. Only reason to do so is to make configuration export of that section more readable … but it makes changing also more error prone as you have to change things in two places.

HI,

I have a similar problem (but on a Router). Could you please publish your whole working-config so that i can try as well.

I disagree, the ability to physically map (see and check off on a paper copy of the config or on the screen, between Bridge Ports and Bridge vlans, especially for troubleshooting issues, is better accomplished with manually entering the untagged entries IMHO.
Its up to you though, and I am one of the rare folks that espouses this as I am not professionally trained and thus can relate better to the new user. :wink:
If you are comfortable and understand how they work, as you clearly do, not required.

Posting the working config in case it helps someone. I’ve removed the irrelevant parts (e.g. IPv6) to keep it more focused.

Thank you all for the help! :slightly_smiling_face:

# RouterOS 7.1.1
#
# model = RB5009UG+S+
/interface bridge
add admin-mac=REDACTED auto-mac=no name=local
add frame-types=admit-only-vlan-tagged name=vlans vlan-filtering=yes
/interface vlan
add comment="Upstairs Main" interface=vlans name=vlan10 vlan-id=10
add comment="Upstairs Guest" interface=vlans name=vlan11 vlan-id=11
add comment="Base VLAN" interface=vlans name=vlan1000 vlan-id=1000
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
add name=VLAN
add name=BASE
add comment="All interfaces that should be able to access the router's admin tools." include=BASE,LAN,VLAN name=Admin-Access
add comment="All interfaces that should be able to access WAN." include=VLAN name=WAN-Access
/ip pool
add name=local ranges=10.0.0.10-10.0.0.254
add name=vlan10 ranges=10.0.10.2-10.0.10.254
add name=vlan11 ranges=10.0.11.2-10.0.11.254
add name=vlan1000 ranges=10.0.1.2-10.0.1.254
/ip dhcp-server
add address-pool=local interface=local name=local
add address-pool=vlan10 interface=vlan10 name=vlan10
add address-pool=vlan11 interface=vlan11 name=vlan11
add address-pool=vlan1000 interface=vlan1000 name=vlan1000
/interface bridge port
add bridge=local comment=defconf ingress-filtering=no interface=ether2
add bridge=vlans comment="Base/Management Access Port" frame-types=admit-only-untagged-and-priority-tagged interface=ether3 pvid=1000
add bridge=local comment=defconf ingress-filtering=no interface=ether4
add bridge=local comment=defconf ingress-filtering=no interface=ether5
add bridge=vlans frame-types=admit-only-untagged-and-priority-tagged interface=ether6 pvid=10
add bridge=vlans frame-types=admit-only-untagged-and-priority-tagged interface=ether7 pvid=1000
add bridge=vlans interface=ether8 pvid=1000
/ip neighbor discovery-settings
set discover-interface-list=Admin-Access
/ipv6 settings
set disable-ipv6=yes max-neighbor-entries=8192
/interface bridge vlan
# ether8 has a UniFi access point that is configured to tag specific wireless networks and leave its management traffic untagged.
# ether8 has pvid=1000 and becomes implicitly "untagged" on the following entry.
add bridge=vlans tagged=vlans vlan-ids=1000
# VLANs 10 and 11 are tagged on the AP and represent the two wireless networks
add bridge=vlans tagged=vlans,ether8 vlan-ids=10
add bridge=vlans tagged=vlans,ether8 vlan-ids=11
/interface list member
add interface=local list=LAN
add interface=ether1 list=WAN
add interface=vlan1000 list=BASE
add interface=vlan10 list=VLAN
add interface=vlan11 list=VLAN
add interface=vlan1000 list=VLAN
/ip address
add address=10.0.0.1/24 interface=local network=10.0.0.0
add address=10.0.10.1/24 interface=vlan10 network=10.0.10.0
add address=10.0.11.1/24 interface=vlan11 network=10.0.11.0
add address=10.0.1.1/24 interface=vlan1000 network=10.0.1.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=10.0.0.0/24 dns-server=10.0.0.1 gateway=10.0.0.1 netmask=24
add address=10.0.1.0/24 comment=vlan1000 dns-server=10.0.1.1 gateway=10.0.1.1 netmask=24
add address=10.0.10.0/24 comment=vlan10 dns-server=10.0.10.1 gateway=10.0.10.1
add address=10.0.11.0/24 comment=vlan11 dns-server=10.0.11.1 gateway=10.0.11.1 netmask=24
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=10.0.0.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment="accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" disabled=yes dst-address=127.0.0.1
add action=accept chain=input in-interface-list=VLAN
add action=accept chain=input in-interface-list=BASE
add action=accept chain=input in-interface-list=LAN
add action=drop chain=input
add action=accept chain=forward comment="defconf: accept in ipsec policy" disabled=yes ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" disabled=yes ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related disabled=yes hw-offload=yes
add action=accept chain=forward comment="accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=forward in-interface-list=WAN-Access out-interface-list=WAN
add action=accept chain=forward disabled=yes in-interface-list=WAN out-interface-list=WAN-Access
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN
add action=reject chain=forward comment="Reject cross-VLAN traffic" in-interface-list=VLAN out-interface-list=VLAN reject-with=icmp-admin-prohibited
add action=drop chain=forward comment="Drop everything else"
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
/tool mac-server
set allowed-interface-list=Admin-Access
/tool mac-server mac-winbox
set allowed-interface-list=Admin-Access

thank you