Moving from a single LAN setup into the Mikrotik (and Ubiquiti Unifi) world, I haven't quite figured out how to correctly setup VLANs. I hope someone here can help.
I have attached a diagram, trying to show the imagined setup: My immediate questions are:
On the RB5009
- ether3-7 (green) are access ports. They should all be VLAN 3. What would be the correct / recommended RouterOS 7.8 way to do this? (considering next questions)
- ether1 (white) and SFP+ should carry both VLAN 1, 3 and 250 and allow downstream devices to handle these, what would be correct for this? (I believe they are trunk ports?)
- ether2 (purple) is my PC to be used for management of the whole LAN, anything to take into account here?
Notes:
- I'm aware that VLAN 1 can be a bad practice. I would use it for management to avoid trouble with the unifi controller. I'm willing to change it, if it's recommended, but right now I'm struggling with just "enforcing" VLAN 3 on all "green ports"
- I'm able to carry VLAN 250 to the Unifi APs and "advertise" them on a separate IoT/Guest SSID. When I check "VLAN filtering" on the bridge containing (in WinBox) all ports except ether 8, which is the WAN, it seems that the unifi APs are not able to deliver an IP on VLAN 250 (maybe it's due to another misconfiguration.
I appreciate any help, including links to previous posts. I'm probably asking the same question as many others, but I haven't found the answer or I found it and didn't understand it
There is how my current setup looks (I think): And here is my configuration with secrets removed. There is a bit of trash lying around as well, including an extra dhcp and a disabled VLAN. I also have a lot of static DHCP-leases, which I removed to make a better overview. One important static lease is my pi-hole being at 192.168.2.100. Others include my NAS and some family PCs.
# apr/07/2023 13:17:54 by RouterOS 7.8
# software id = XXXX
#
# model = RB5009UPr+S+
# serial number = XXXXXXXXXXX
/interface bridge
add admin-mac=48:A9:8A:34:6F:80 auto-mac=no name=WAN_bridge
add admin-mac=48:A9:8A:34:6F:81 auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether8 ] comment=ISP
/interface vlan
add interface=bridge name=GuestIoT vlan-id=250
add interface=bridge name=Home vlan-id=3
add disabled=yes interface=bridge name=MgmtMaybe vlan-id=2
/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=dhcp_pool2 ranges=192.168.2.2-192.168.2.254
add name=dhcp_pool250 ranges=192.168.250.2-192.168.250.254
add name=dhcp_pool3 ranges=192.168.3.2-192.168.3.254
add name=dhcp_pool1 ranges=192.168.1.2-192.168.1.254
/ip dhcp-server
add address-pool=dhcp_pool2 interface=bridge name=dhcp2b
add address-pool=dhcp_pool250 interface=GuestIoT name=dhcp250
add address-pool=dhcp_pool3 interface=Home name=dhcp3
add address-pool=dhcp_pool2 disabled=yes interface=MgmtMaybe name=dhcp2
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=ether6
add bridge=bridge comment=defconf interface=ether7
add bridge=bridge comment="defconf was ether8" interface=ether1
add bridge=bridge comment=defconf interface=sfp-sfpplus1
add bridge=WAN_bridge interface=ether8
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface detect-internet
set detect-interface-list=WAN internet-interface-list=WAN lan-interface-list=\
LAN wan-interface-list=WAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment="defconf was ether1 now it's the WAN bridge (containing ether8 and\
\_using a fake mac address)" interface=WAN_bridge list=WAN
/ip address
add address=192.168.2.1/24 comment=defconf interface=bridge network=\
192.168.2.0
add address=192.168.250.1/24 interface=GuestIoT network=192.168.250.0
add address=192.168.3.1/24 interface=Home network=192.168.3.0
add address=192.168.2.1/24 disabled=yes interface=MgmtMaybe network=\
192.168.2.0
/ip dhcp-client
add comment="defconf was ether1 - now WAN_bridge with fake MAC-address equal t\
o ether1's MAC address, to fool ISP into giving me an IP address" \
interface=WAN_bridge
/ip dhcp-server network
add address=192.168.2.0/24 dns-server=192.168.2.100,192.168.2.1 gateway=\
192.168.2.1 netmask=24
add address=192.168.3.0/24 dns-server=192.168.2.100,192.168.2.1 gateway=\
192.168.3.1
add address=192.168.250.0/24 dns-server=8.8.8.8,194.239.134.83 gateway=\
192.168.250.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.2.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" \
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 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
add action=dst-nat chain=dstnat dst-port=5001 in-interface-list=WAN protocol=\
tcp to-addresses=192.168.2.40 to-ports=5001
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 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 ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
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 packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
/system clock
set time-zone-name=Europe/Copenhagen
/system identity
set name="MikroTik RB5009"
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
- I'm not remotely close to setting up firewalls yet, but I added my thoughts on firewalls to the first diagram as well.
- The WAN interface (ether 8 ) is "replaced" by a VLAN. That way I could fake the mac-address towards the ISP fiber modem. Otherwise it wouldn't give me an IP address (probably mac-locked). It works fine.