[Solved] VLAN with own subnets, not access to internet (modem/router)

Hi, my 1st mikrotik switch and trying to setup simple network with two VLANs with own subnets:

  • vlan10 / 10.0.10.1/24
  • vlan20 / 10.0.20.1/24

Device: CRS310-1G-5S-4S+IN
Connected to ISP modem/router 10.0.99.1 via ether1

Looks like VLANs part works as expected, connecting to different ports assigns expected IPs:
sfp1: 10.0.10.254 gateway 10.0.10.1
sfp2-…sfp4+ 10.0.20.254 gateway 10.0.20.1

Can reach RouteOs webUI via gateway IPs
But 10.0.99.1(modem) is not reachable, so no internet from VLANs

What I’m missing?

/interface bridge
add admin-mac=D4:01:C3:D4:C0:0E auto-mac=no comment=defconf name=BR1 vlan-filtering=yes
/interface vlan
add interface=BR1 name=vlan10 vlan-id=10
add interface=BR1 name=vlan20 vlan-id=20
/interface list
add name=WAN
add name=VLAN
/ip pool
add name=vlan10 ranges=10.0.10.2-10.0.10.254
add name=vlan20 ranges=10.0.20.2-10.0.20.254
/port
set 0 name=serial0
/interface bridge port
add bridge=BR1 comment=defconf interface=ether1
add bridge=BR1 comment=defconf frame-types=admit-only-vlan-tagged interface=sfp-sfpplus1
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus2 pvid=20
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus3 pvid=20
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus4 pvid=20
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp1 pvid=10
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp2 pvid=20
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp3 pvid=20
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp4 pvid=20
add bridge=BR1 comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=sfp5 pvid=20
/ip neighbor discovery-settings
set discover-interface-list=VLAN
/interface bridge vlan
add bridge=BR1 tagged=BR1 vlan-ids=10
add bridge=BR1 tagged=BR1 vlan-ids=20
/interface ethernet switch
set 0 l3-hw-offloading=yes
/interface list member
add interface=ether1 list=WAN
add interface=vlan10 list=VLAN
add interface=vlan20 list=VLAN
/ip address
add address=192.168.88.1/24 comment=defconf interface=BR1 network=192.168.88.0
add address=10.0.99.3/24 interface=ether1 network=10.0.99.0
add address=10.0.10.1/24 interface=vlan10 network=10.0.10.0
add address=10.0.20.1/24 interface=vlan20 network=10.0.20.0
/ip dhcp-server
add address-pool=vlan10 interface=vlan10 name=vlan10_dhcp
add address-pool=vlan20 interface=vlan20 name=vlan20_dhcp
/ip dhcp-server network
add address=10.0.10.0/24 dns-server=1.1.1.1 gateway=10.0.10.1
add address=10.0.20.0/24 dns-server=1.1.1.1 gateway=10.0.20.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1
/ip dns static
add address=192.168.88.1 name=router type=A
/ip firewall filter
add action=accept chain=input comment="Allow Estab & Related" connection-state=established,related
add action=accept chain=input comment="Allow VLAN" in-interface-list=VLAN
add action=drop chain=input comment=Drop
add action=accept chain=forward comment="Allow Estab & Related" connection-state=established,related
add action=accept chain=forward comment="VLAN Internet Access only" connection-state=new in-interface-list=VLAN out-interface-list=WAN
add action=drop chain=forward comment=Drop
/ip firewall nat
add action=masquerade chain=srcnat comment="Default masquerade" out-interface-list=WAN
/ip route
add distance=1 gateway=10.0.99.1
/system clock
set time-zone-name=Asia/Jakarta
/system identity
set name=swtich1
/system note
set show-at-login=no
/system routerboard settings
set enter-setup-on=delete-key
/tool mac-server
set allowed-interface-list=VLAN
/tool mac-server mac-winbox
set allowed-interface-list=VLAN

Well the question is what is the TRUSTED or management subnet?? Did you want to use vlan20 or create another one like vlan99??
All smart devices should get their IP address on this subnet save the MT switch which should get its IP address from the upstream routers private LAN.

Dont use same name for diff things, like vlan interface name and ip pool name… clarity and dont confuse the router :wink:
remove static dns for 192.168.88.1

/interface bridge
add admin-mac=D4:01:C3:D4:C0:0E auto-mac=no comment=defconf name=BR1 vlan-filtering=yes
/interface vlan
add interface=BR1 name=vlan10 vlan-id=10
add interface=BR1 name=vlan20 vlan-id=20
add interface=BR1 name=vlan16 vlan-id-16 comment=“Management vlan”
/interface list
add name=WAN
add name=VLAN
add name=TRUSTED
/ip pool
add name=vlan10-pool ranges=10.0.10.2-10.0.10.254
add name=vlan20-pool ranges=10.0.20.2-10.0.20.254
add name=vlan16-pool ranges=172.16.0.40-172.16.0-50
/port
set 0 name=serial0
/interface bridge port
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-vlan-tagged interface=sfp-sfpplus1
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus2 pvid=20
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus3 pvid=20
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus4 pvid=20
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp1 pvid=10
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp2 pvid=20
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp3 pvid=20
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp4 pvid=20
add bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged interface=sfp5 pvid=20
/ip neighbor discovery-settings
set discover-interface-list=TRUSTED
/interface bridge vlan
add bridge=BR1 tagged=BR1,sfp-sfpplus1 vlan-id=16
add bridge=BR1 tagged=BR1,sfp-sfpplus1 untagged=sfp1 vlan-ids=10
add bridge=BR1 tagged=BR1,sfp-sfpplus1 untagged=sfp-sfpplus2,sfp-sfpplus3,sfp-sfpplus4,sfp2,sfp3,sfp4,sfp5 vlan-ids=20
/interface ethernet switch
set 0 l3-hw-offloading=yes
/interface list member
add interface=ether1 list=WAN
add interface=vlan10 list=VLAN
add interface=vlan20 list=VLAN
add interface=vlan16 list=VLAN
add interface=vlan16 list=TRUSTED

/ip address
add address=10.0.99.3/24 interface=ether1 network=10.0.99.0
add address=10.0.10.1/24 interface=vlan10 network=10.0.10.0
add address=10.0.20.1/24 interface=vlan20 network=10.0.20.0
add address=172.16.0.1/24 interface=vlan16 network=172.16.0.0
/ip dhcp-server
add address-pool=vlan10-pool interface=vlan10 name=vlan10_dhcp
add address-pool=vlan20-pool interface=vlan20 name=vlan20_dhcp
add address-pool=vlan16-pool interface=vlan16 name=vlan16_dhcp
/ip dhcp-server network
add address=10.0.10.0/24 dns-server=1.1.1.1 gateway=10.0.10.1
add address=10.0.20.0/24 dns-server=1.1.1.1 gateway=10.0.20.1
add address=172.16.0.0/24 dns-server=1.1.1.1 gateway=172.16.0.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1
/ip firewall address-list { using static DHCP leases }
add address=172.16.0.0/24 list=AUTHORIZED comment=“Management vlan to router”
add address=10.0.10.XX list=AUTHORIZED comment=“admin on vlan10 wired”
add address-10.0.10.YY list=AUTHORIZED comment=“admin on vlan10 wifi”

{ ADD admin IPs AS NEEDED }
/ip firewall filter
add action=accept chain=input connection-state=established,related,untracked
add action=drop chain=input connection-state=invalid
add action=accept chain=input protocol=icmp

add action=accept chain=input comment=“admin access” src-address-list=AUTHORIZED
add action=accept chain=input comment=“users to services” in-interface-list=VLAN dst-port=53 protocol=udp
add action=accept chain=input comment=“users to services” in-interface-list=VLAN dst-port=53 protocol=tcp

add action=drop chain=input comment=Drop
add action=fasttrack-connection chain=forward connection-state=established,related
add action=accept chain=forward connection-state=established,related,untracked
add action=accept chain=forward comment=“VLAN Internet Access only” connection-state=new in-interface-list=VLAN out-interface-list=WAN
add action=drop chain=forward comment=Drop
/ip firewall nat
add action=masquerade chain=srcnat comment=“Default masquerade” out-interface-list=WAN
/ip route
add distance=1 gateway=10.0.99.1
/system clock
set time-zone-name=Asia/Jakarta
/system identity
set name=swtich1
/system note
set show-at-login=no
/system routerboard settings
set enter-setup-on=delete-key
/tool mac-server
set allowed-interface-list=NONE
/tool mac-server mac-winbox
set allowed-interface-list=TRUSTED

Once this is setup one should be able to reach any LANIP on the 10.0.99.0/24 subnet.
Since all traffic leaving the router is given a source IP of 10.0.99.3 ( due to sourcenat masquerade ) return traffic from that LAN should head back to the MT switch.

If your intent, as it should be to minimize access to the upstream router…

Then massage firewall rules…
add action=fasttrack-connection chain=forward connection-state=established,related
add action=accept chain=forward connection-state=established,related,untracked
add action=accept chain=forward comment=“admin access to upstream router” src-address-list=AUTHORIZED dst-address=10.0.99.0/24
add action=drop chain=forward comment=“restrict access to upstream router” in-interface-list=VLAN dst-address=10.0.99.0/24

add action=accept chain=forward comment=“VLAN Internet Access only” connection-state=new in-interface-list=VLAN out-interface-list=WAN
add action=drop chain=forward comment=Drop all else

OR
add action=fasttrack-connection chain=forward connection-state=established,related
add action=accept chain=forward connection-state=established,related,untracked
add action=accept chain=forward comment=“admin access to upstream router” src-address-list=AUTHORIZED dst-address=10.0.99.0/24
add action=accept chain=forward comment=“access to all but upstream router” in-interface-list=VLAN out-interface-list=WAN dst-address=!10.0.99.0/24
add action=drop chain=forward comment=Drop all else

You have left some default config which seems to be messing this up. ether1 is labelled as a WAN and you are firewalling/nat’ing however it is still a member of br1:

add bridge=BR1 comment=defconf interface=ether1

Get rid of this ^^^
Should jump into life.

Thank you @anav and @Steveocee!

Removing defcon rules static route 192.168.88.1 and “add bridge=BR1 comment=defconf interface=ether1” did the trick!
Still learning and I couldn’t find the way to apply new config from WebUI, instead I did modify script from http://forum.mikrotik.com/t/using-routeros-to-vlan-your-network/126489/1 to update existing interfaces.
If I reset config with “no default config” option how do I connect to the switch w/o winbox?

@anav my intet for now is to start simple:

  • sfp1 (vlan10) as AP for all personal devices TRUSTED vlan I guess
  • sfp-plus1 (trunk port?) to connect another switch in the future
  • and use remaning ports (vlan20) for homelab proxmox cluster
  • ether1 WAN port

This what’s I use at the moment, I’ll do more research today how to apply config from scratch

#######################################
# Naming
#######################################

# name the device being configured
/system identity set name="swtich1"


#######################################
# VLAN Overview
#######################################


# 10 = Archer
# 20 = proxmox

#######################################
# Bridge
#######################################

/interface set "bridge" name="BR1"

# create one bridge, set VLAN mode off while we configure
#/interface bridge add name=BR1 protocol-mode=none vlan-filtering=no
/interface bridge set BR1 vlan-filtering=no
/interface/ethernet/switch set 0 l3-hw-offloading=no


#######################################
#
# -- Access Ports --
#
#######################################

# ingress behavior
/interface bridge port

# Archer VLAN 1GB
#add bridge=BR1 interface=sfp1 pvid=10
set [find where interface=sfp1] pvid=10

# proxmox VLAN 1GB ports
#add bridge=BR1 interface=sfp2 pvid=20
#add bridge=BR1 interface=sfp3 pvid=20
#add bridge=BR1 interface=sfp4 pvid=20
#add bridge=BR1 interface=sfp5 pvid=20
set [find where interface=sfp2] pvid=20
set [find where interface=sfp3] pvid=20
set [find where interface=sfp4] pvid=20
set [find where interface=sfp5] pvid=20


# proxmox VLAN 10GB ports
#add bridge=BR1 interface=sfp-sfpplus2 pvid=20
#add bridge=BR1 interface=sfp-sfpplus3 pvid=20
#add bridge=BR1 interface=sfp-sfpplus4 pvid=20
set [find where interface=sfp-sfpplus2] pvid=20
set [find where interface=sfp-sfpplus3] pvid=20
set [find where interface=sfp-sfpplus4] pvid=20


# egress behavior, handled automatically

# L3 switching so Bridge must be a tagged member
/interface bridge vlan
add bridge=BR1 tagged=BR1 vlan-ids=10
add bridge=BR1 tagged=BR1 vlan-ids=20


#######################################
# IP Addressing & Routing
#######################################

# DNS server, set to cache for LAN
/ip dns set allow-remote-requests=yes servers="1.1.1.1"

# Yellow WAN facing port with IP Address and route provided by ISP
/ip address add interface=ether1 address=10.0.99.3/24 network=10.0.99.0
/ip route add distance=1 gateway=10.0.99.1

/ip dns static add address=192.168.88.1 name=router

#######################################
# IP Services
#######################################

# Blue VLAN interface creation, IP assignment, and DHCP service
/interface vlan add interface=BR1 name=vlan10 vlan-id=10
/ip address add interface=vlan10 address=10.0.10.1/24
/ip pool add name=vlan10 ranges=10.0.10.2-10.0.10.254
/ip dhcp-server add address-pool=vlan10 interface=vlan10 name=vlan10_dhcp disabled=no
/ip dhcp-server network add address=10.0.10.0/24 dns-server=1.1.1.1 gateway=10.0.10.1

# Green VLAN interface creation, IP assignment, and DHCP service
/interface vlan add interface=BR1 name=vlan20 vlan-id=20
/ip address add interface=vlan20 address=10.0.20.1/24
/ip pool add name=vlan20 ranges=10.0.20.2-10.0.20.254
/ip dhcp-server add address-pool=vlan20 interface=vlan20 name=vlan20_dhcp disabled=no
/ip dhcp-server network add address=10.0.20.0/24 dns-server=1.1.1.1 gateway=10.0.20.1



#######################################
# Firewalling & NAT
# A good firewall for WAN. Up to you
# about how you want LAN to behave.
#######################################

# Use MikroTik's "list" feature for easy rule matchmaking.

/interface list add name=WAN
/interface list add name=VLAN

/interface list member
add interface=ether1     list=WAN
add interface=vlan10     list=VLAN
add interface=vlan20     list=VLAN

# VLAN aware firewall. Order is important.
/ip firewall filter


##################
# INPUT CHAIN
##################
add chain=input action=accept connection-state=established,related comment="Allow Estab & Related"

# Allow VLANs to access router services like DNS, Winbox. Naturally, you SHOULD make it more granular.
add chain=input action=accept in-interface-list=VLAN comment="Allow VLAN"

add chain=input action=drop comment="Drop"

##################
# FORWARD CHAIN
##################
add chain=forward action=accept connection-state=established,related comment="Allow Estab & Related"

# Allow all VLANs to access the Internet only, NOT each other
add chain=forward action=accept connection-state=new in-interface-list=VLAN out-interface-list=WAN comment="VLAN Internet Access only"

add chain=forward action=drop comment="Drop"

##################
# NAT
##################
/ip firewall nat add chain=srcnat action=masquerade out-interface-list=WAN comment="Default masquerade"


#######################################
# VLAN Security
#######################################

# Only allow ingress packets without tags on Access Ports
/interface bridge port

set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp1]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp2]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp3]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp4]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp5]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp-sfpplus2]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp-sfpplus3]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=sfp-sfpplus4]

# Only allow ingress packets WITH tags on Trunk Ports
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-vlan-tagged [find interface=sfp-sfpplus1]


#######################################
# MAC Server settings
#######################################

# Ensure only visibility and availability from VLAN
/ip neighbor discovery-settings set discover-interface-list=VLAN
/tool mac-server mac-winbox set allowed-interface-list=VLAN
/tool mac-server set allowed-interface-list=VLAN


#######################################
# Turn on VLAN mode
#######################################
/interface bridge set BR1 vlan-filtering=yes

/interface/ethernet/switch set 0 l3-hw-offloading=yes

Manage to install winbox on macbook, can apply config from scratch.
My current config- almost there. When I reboot router, no internet access, I found that if I change WAN IP address manually it start working again

Screenshot 2024-10-19 at 12.04.23.png
e.g. if I change it to 10.0.99.5 start working again

Also I don’t have access to 10.0.99.1 (modem webUI) from VLANs, I can ping it from RoOs terminal though


/interface bridge
add name=BR1 protocol-mode=none vlan-filtering=yes
/interface vlan
add interface=BR1 name=vlan10 vlan-id=10
add interface=BR1 name=vlan20 vlan-id=20
/interface list
add name=WAN
add name=VLAN
/ip pool
add name=vlan10 ranges=10.0.10.2-10.0.10.254
add name=vlan20 ranges=10.0.20.2-10.0.20.254
/ip dhcp-server
add address-pool=vlan10 interface=vlan10 name=vlan10_dhcp
add address-pool=vlan20 interface=vlan20 name=vlan20_dhcp
/port
set 0 name=serial0
/interface bridge port
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp1 pvid=10
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp2 pvid=20
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp3 pvid=20
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp4 pvid=20
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp5 pvid=20
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus2 pvid=20
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus3 pvid=20
add bridge=BR1 frame-types=admit-only-untagged-and-priority-tagged interface=sfp-sfpplus4 pvid=20
/ip neighbor discovery-settings
set discover-interface-list=VLAN
/interface bridge vlan
add bridge=BR1 tagged=BR1 vlan-ids=10
add bridge=BR1 tagged=BR1 vlan-ids=20
/interface ethernet switch
set 0 l3-hw-offloading=yes
/interface list member
add interface=ether1 list=WAN
add interface=vlan10 list=VLAN
add interface=vlan20 list=VLAN
/ip address
add address=10.0.10.1/24 interface=vlan10 network=10.0.10.0
add address=10.0.20.1/24 interface=vlan20 network=10.0.20.0
add address=10.0.99.3/24 interface=ether1 network=10.0.99.0
/ip dhcp-server network
add address=10.0.10.0/24 dns-server=1.1.1.1 gateway=10.0.10.1
add address=10.0.20.0/24 dns-server=1.1.1.1 gateway=10.0.20.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1
/ip firewall filter
add action=accept chain=input comment="Allow Estab & Related" connection-state=established,related
add action=accept chain=input comment="Allow VLAN" in-interface-list=VLAN
add action=drop chain=input comment=Drop
add action=accept chain=forward comment="Allow Estab & Related" connection-state=established,related
add action=accept chain=forward comment="VLAN Internet Access only" connection-state=new in-interface-list=VLAN out-interface-list=WAN
add action=drop chain=forward comment=Drop
/ip firewall nat
add action=masquerade chain=srcnat comment="Default masquerade" out-interface-list=WAN
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=10.0.99.1 routing-table=main scope=30 target-scope=10
/system clock
set time-zone-name=Asia/Makassar
/system identity
set name=swtich1
/system note
set show-at-login=no
/system routerboard settings
set enter-setup-on=delete-key
/tool mac-server
set allowed-interface-list=VLAN
/tool mac-server mac-winbox
set allowed-interface-list=VLAN

Current settings
Screenshot 2024-10-19 at 12.23.26.png

Found the reason:

/interface/ethernet/switch set 0 l3-hw-offloading=yes

Apparently I have a switch CRS310-1G-5S-4S+IN and it supports only some hardware offloaded Layer-3 routing.

I’ll get proper router for hw routing.


Cheers.