Hello everyone,
I’m very new to the Mikrotik/RouterOS but looking forward to learning. I’m hoping more advanced users would be able to provide some comments on my configuration.
What I am trying to do:
- Purchased a HEX RB750gr3
- Hex cable/port configuration as follows:
Eth1 - connected to LTE router
Eth2 - connected to a Cisco IOS based switch as a VLAN trunk carrying VLANS (1, 30, 43, 45, 47, 48, 49, 54, 57, 58) (trunk port)
Eth3 - connected to an unmanaged switch with devices intended for VLAN 30 (access port)
Eth4 - connected to a Wireless AP that is for VLAN 54 (access port)
Eth5 - reserved as an admin port to be used as a backup way to connect
I would like the Mikrotic router to be able to basically be a hybrid of a router on a stick, managed switch, NAT/Firewall. This is a temporary setup until our facility gets it’s proper wiring and switch stacks (backordered due to supply chain issues). I could have temporarily put all my devices on a flat style network with the same subnet but then that would mean i would have to change the IP’s of everything in the future.
For now I would like every VLAN to be able to route to each other as well as to be able to access the internet (in the future i’ll set more restrictive rules but for now i’ll start off simple). I would also like the router to have a DHCP server on VLANs 54, 57, 58.
I’ve used the configuration files in this excellent thread as a starting point http://forum.mikrotik.com/t/using-routeros-to-vlan-your-network/126489/1 but my use case is a bit of a hybrid so I am sure i’ve screwed something up.
The configuration appears to work when I plug devices in ports 3,4,5 but I don’t have a switch capable of VLAN trunking/tagging in my house so I can’t test that portion until I go to the factory and this is why I would appreciate any tips or suggestions. Thank you all in advance!
#######################################
# Cable Configuration
#######################################
#ether1 "INTERNET" WAN
#ether2 "2" Trunk connection to switches (VLAN 1, 30, 43, 45, 47, 48, 49, 54, 57, 58)
#ether3 "3" Local Unmanaged Switch (VLAN 30)
#ether4 "4" Local Wifi AP (VLAN 54)
#ether5 "5" Admin (VLAN 1)
#######################################
# Naming
#######################################
# name the device being configured
/system identity set name="CAL-OT Router"
#######################################
# VLAN Overview
#######################################
# 1 = Router/Switch Management BASE_VLAN
# 30 = OT - Core OT_CORE
# 40 = OT - Grow BHA OT_BHA_GROW
# 42 = OT - Ext. BHA OT_BHA_EXT
# 43 = OT - Seeding OT_SEEDING
# 45 = OT - AHU/BAS OT_AHU
# 46 = OT - Irrigation OT_IRRIGATION
# 47 = OT - Packaging OT_PACKAGING
# 48 = OT - Harvest OT_HARVEST
# 49 = OT - Tray Handling OT_TRAY
# 54 = OT - Wireless OT_WIFI
# 57 = OT - IOT #1 OT_IOT1
# 58 = OT - IOT #2 OT_IOT2
#######################################
# Bridge
#######################################
# create one bridge, set VLAN mode off while we configure
/interface bridge add name=BR1 protocol-mode=none vlan-filtering=no
#######################################
#
# -- Trunk Ports --
#
#######################################
# ingress behavior
/interface bridge port
# Purple Trunk. Leave pvid set to default of 1
add bridge=BR1 interface=ether2
# egress behavior
/interface bridge vlan
# Purple Trunk. These need IP Services (L3), so add Bridge as member
add bridge=BR1 tagged=BR1,ether2 vlan-ids=1
add bridge=BR1 tagged=BR1,ether2 vlan-ids=30
add bridge=BR1 tagged=BR1,ether2 vlan-ids=43
add bridge=BR1 tagged=BR1,ether2 vlan-ids=45
add bridge=BR1 tagged=BR1,ether2 vlan-ids=47
add bridge=BR1 tagged=BR1,ether2 vlan-ids=48
add bridge=BR1 tagged=BR1,ether2 vlan-ids=49
add bridge=BR1 tagged=BR1,ether2 vlan-ids=54
add bridge=BR1 tagged=BR1,ether2 vlan-ids=57
add bridge=BR1 tagged=BR1,ether2 vlan-ids=58
#######################################
#
# -- Access Ports --
#
#######################################
# ingress behavior
/interface bridge port
# set port 3 to VLAN ID 30 (OT - Core)
add bridge=BR1 interface=ether3 pvid=30
# set port 4 to VLAN ID 54 (OT - Wireless)
add bridge=BR1 interface=ether4 pvid=54
# set port 5 to VLAN ID 1 (Router/Switch Management)
add bridge=BR1 interface=ether5 pvid=1
#######################################
# IP Addressing & Routing
#######################################
# LAN facing router's IP address on the BASE_VLAN
/interface vlan add interface=BR1 name=BASE_VLAN vlan-id=1
/ip address add address=192.168.1.1/24 interface=BASE_VLAN
# DNS server, set to cache for LAN
/ip dns set allow-remote-requests=yes servers="8.8.8.8"
# Yellow WAN facing port with IP Address provided by ISP
/ip address add interface=ether1 address=192.168.0.79/24 network=192.168.0.0
# router's gateway provided by ISP
/ip route add distance=1 gateway=192.168.0.1
#######################################
# IP Services
#######################################
# OT - Core interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_CORE vlan-id=30
/ip address add interface=OT_CORE address=10.30.30.1/24
# OT - Grow BHA interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_BHA_GROW vlan-id=40
/ip address add interface=OT_BHA_GROW address=10.30.40.1/24
# OT - Ext. BHA interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_BHA_EXT vlan-id=42
/ip address add interface=OT_BHA_EXT address=10.30.42.1/24
# OT - Seeding interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_SEEDING vlan-id=43
/ip address add interface=OT_SEEDING address=10.30.43.1/24
# OT - AHU/BAS interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_AHU vlan-id=45
/ip address add interface=OT_AHU address=10.30.45.1/24
# OT - Irrigation interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_IRRIGATION vlan-id=46
/ip address add interface=OT_IRRIGATION address=10.30.46.1/24
# OT - Packaging interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_PACKAGING vlan-id=47
/ip address add interface=OT_PACKAGING address=10.30.47.1/24
# OT - Harvest interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_HARVEST vlan-id=48
/ip address add interface=OT_HARVEST address=10.30.48.1/24
# OT - Tray Handling interface creation, IP assignment
/interface vlan add interface=BR1 name=OT_TRAY vlan-id=49
/ip address add interface=OT_TRAY address=10.30.49.1/24
# OT - Wireless interface creation, IP assignment, and DHCP service
/interface vlan add interface=BR1 name=OT_WIFI vlan-id=54
/ip address add interface=OT_WIFI address=10.30.54.1/24
/ip pool add name=OT_WIFI_POOL ranges=10.30.54.20-10.30.54.254
/ip dhcp-server add address-pool=OT_WIFI_POOL interface=OT_WIFI name=OT_WIFI_DHCP disabled=no
/ip dhcp-server network add address=10.30.54.0/24 dns-server=8.8.8.8 gateway=10.30.54.1
# OT - IOT #1 interface creation, IP assignment, and DHCP service
/interface vlan add interface=BR1 name=OT_IOT1 vlan-id=57
/ip address add interface=OT_IOT1 address=10.30.57.1/24
/ip pool add name=OT_IOT1_POOL ranges=10.30.57.200-10.30.57.254
/ip dhcp-server add address-pool=OT_IOT1_POOL interface=OT_IOT1 name=OT_IOT1_DHCP disabled=no
/ip dhcp-server network add address=10.30.57.0/24 dns-server=8.8.8.8 gateway=10.30.57.1
# OT - IOT #2 interface creation, IP assignment, and DHCP service
/interface vlan add interface=BR1 name=OT_IOT2 vlan-id=58
/ip address add interface=OT_IOT2 address=10.30.58.1/24
/ip pool add name=OT_IOT2_POOL ranges=10.30.58.200-10.30.58.254
/ip dhcp-server add address-pool=OT_IOT2_POOL interface=OT_IOT2 name=OT_IOT2_DHCP disabled=no
/ip dhcp-server network add address=10.30.58.0/24 dns-server=8.8.8.8 gateway=10.30.58.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 add name=BASE
/interface list member
add interface=ether1 list=WAN
add interface=BASE_VLAN list=BASE
add interface=BASE_VLAN list=VLAN
add interface=OT_CORE list=VLAN
add interface=OT_BHA_GROW list=VLAN
add interface=OT_BHA_EXT list=VLAN
add interface=OT_SEEDING list=VLAN
add interface=OT_AHU list=VLAN
add interface=OT_IRRIGATION list=VLAN
add interface=OT_PACKAGING list=VLAN
add interface=OT_HARVEST list=VLAN
add interface=OT_TRAY list=VLAN
add interface=OT_WIFI list=VLAN
add interface=OT_IOT1 list=VLAN
add interface=OT_IOT2 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"
# Allow BASE_VLAN full access to the device for Winbox, etc.
add chain=input action=accept in-interface=BASE_VLAN comment="Allow Base_Vlan Full Access"
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
add chain=forward action=accept connection-state=new in-interface-list=VLAN out-interface-list=WAN comment="VLAN Internet Access"
# Allow all VLANs to access each other (for now)
add chain=forward action=accept connection-state=new in-interface-list=VLAN out-interface-list=VLAN comment="VLAN to VLAN access"
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 packets with tags over the Trunk Ports
/interface bridge port
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-vlan-tagged [find interface=ether2]
# Only allow ingress packets without tags on Access Ports
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=ether3]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=ether4]
set bridge=BR1 ingress-filtering=yes frame-types=admit-only-untagged-and-priority-tagged [find interface=ether5]
#######################################
# MAC Server settings
#######################################
# Ensure only visibility and availability from BASE_VLAN, the MGMT network
#/ip neighbor discovery-settings set discover-interface-list=BASE
#/tool mac-server mac-winbox set allowed-interface-list=BASE
#/tool mac-server set allowed-interface-list=BASE
#######################################
# Turn on VLAN mode
#######################################
/interface bridge set BR1 vlan-filtering=yes