I am using this as a learning experience for a home lab and wondered if I could get some feedback on my setup script. I am using VLANS for management, services, DMZ for public services, clients and guests. Guests should only have access to WAN clients should have access to services DMZ services, and management should be the only VLAN capable of managing the router and DMZ would be open to WAN. I am running a local DNS on PiHole on 172.23.20.2 and want the router to default to using this DNS server but if it goes down it should switch to 1.1.1.1. To do this i have used netwatch and a script. Is there a better way to do this? Another question i have is i want to limit the communication from DMZ to services but i want some servers on DMZ to access a NAS drive hosed on the service VLAN. What would be the best way of doing this? Should i allow access to the NASs IP on the needed port or is there a more recommended solution?
Thanks
My setup script:
# Device Config
/system/identity/
set name=Base_Router
print
#### Interface Config ####
# Rename interfaces
/interface/
set ether1 name=ether1_WAN
set ether3 name=ether3_ProxmoxMgmt
set ether9 name=ether9_GuestWAP
set ether10 name=ether10_ClientWAP
set ether15 name=ether15_Mgmt
set sfp-sfpplus1 name=sfp+1_Proxmox
set sfp-sfpplus2 name=sfp+2_MainPC
print
# Create LAN bridge
/interface/bridge/
add name=bridge_LAN
print
/interface/bridge/port/
add bridge=bridge_LAN interface=ether2
add bridge=bridge_LAN interface=ether3_ProxmoxMgmt pvid=10
add bridge=bridge_LAN interface=ether4
add bridge=bridge_LAN interface=ether5
add bridge=bridge_LAN interface=ether6
add bridge=bridge_LAN interface=ether7
add bridge=bridge_LAN interface=ether8
add bridge=bridge_LAN interface=ether9_GuestWAP pvid=35
add bridge=bridge_LAN interface=ether10_ClientWAP pvid=30
add bridge=bridge_LAN interface=ether11
add bridge=bridge_LAN interface=ether12
add bridge=bridge_LAN interface=ether13
add bridge=bridge_LAN interface=ether14
add bridge=bridge_LAN interface=ether15_Mgmt pvid=10
add bridge=bridge_LAN interface=ether16
add bridge=bridge_LAN interface=sfp+1_Proxmox
add bridge=bridge_LAN interface=sfp+2_MainPC pvid=20
print
# Create bridge VLANs
/interface/bridge/vlan/
add bridge=bridge_LAN vlan-ids=10 tagged=bridge_LAN untagged=ether3_ProxmoxMgmt,ether15_Mgmt
add bridge=bridge_LAN vlan-ids=20 tagged=bridge_LAN,sfp+1_Proxmox untagged=sfp+2_MainPC
add bridge=bridge_LAN vlan-ids=25 tagged=bridge_LAN,sfp+1_Proxmox
add bridge=bridge_LAN vlan-ids=30 tagged=bridge_LAN untagged=ether10_ClientWAP
add bridge=bridge_LAN vlan-ids=35 tagged=bridge_LAN untagged=ether9_GuestWAP
print
# Create VLAN interfaces
/interface/vlan/
add name=Mgmt vlan-id=10 interface=bridge_LAN
add name=Service vlan-id=20 interface=bridge_LAN
add name=DMZ vlan-id=25 interface=bridge_LAN
add name=Client vlan-id=30 interface=bridge_LAN
add name=Guest vlan-id=35 interface=bridge_LAN
print
#### IP Config ####
# WAN IP Config
/ip/dhcp-client/
add interface=ether1_WAN use-peer-dns=no
print
# LAN IP Config
/ip/address/
add address=172.23.10.1/24 interface=Mgmt
add address=172.23.20.1/24 interface=Service
add address=172.23.25.1/24 interface=DMZ
add address=172.23.30.1/24 interface=Client
add address=172.23.35.1/24 interface=Guest
print
# LAN DHCP Config
/ip/pool/
add name=dhcp_pool_10 ranges=172.23.10.200-172.23.10.254
add name=dhcp_pool_20 ranges=172.23.20.200-172.23.20.254
add name=dhcp_pool_30 ranges=172.23.30.20-172.23.30.254
add name=dhcp_pool_35 ranges=172.23.35.20-172.23.35.254
print
/ip/dhcp-server/
add interface=Mgmt address-pool=dhcp_pool_10 name=dhcp_10
add interface=Service address-pool=dhcp_pool_20 name=dhcp_20
add interface=Client address-pool=dhcp_pool_30 name=dhcp_30
add interface=Guest address-pool=dhcp_pool_35 name=dhcp_35
print
/ip/dhcp-server/network/
add address=172.23.10.0/24 gateway=172.23.10.1 dns-server=172.23.10.1
add address=172.23.20.0/24 gateway=172.23.20.1 dns-server=172.23.20.1
add address=172.23.30.0/24 gateway=172.23.30.1 dns-server=172.23.30.1
add address=172.23.35.0/24 gateway=172.23.35.1 dns-server=172.23.35.1
print
# DNS Config
/ip dns set servers=1.1.1.1 allow-remote-requests=yes
/tool netwatch add host=172.23.20.2 name=PiHoleCheck up-script=upDNS down-script=downDNS
#### Firewall ####
# Firewall NAT Config
/ip/firewall/nat/
add action=masquerade chain=srcnat out-interface=ether1_WAN
print
# Firewall Config
/ip/firewall/filter/
add chain=input action=accept connection-state=established,related comment="input accept: established,related"
add chain=input action=accept src-address=!172.23.25.0/24 in-interface=!ether1_WAN protocol=udp dst-port=67 comment="input accept: from !(WAN,DMZ) UDP DHCP"
add chain=input action=accept src-address=172.23.10.0/24 protocol=udp dst-port=5678,20561 comment="input accept: from Mgmt UDP (Discovery,MAC winbox)"
add chain=input action=accept src-address=172.23.10.0/24 protocol=tcp dst-port=8291 comment="input accept: from Mgmt TCP (Winbox)"
add chain=input action=accept in-interface=!ether1_WAN protocol=udp dst-port=53 comment="input accept: from !WAN UDP DNS"
add chain=input action=accept in-interface=!ether1_WAN protocol=tcp dst-port=53 comment="input accept: from !WAN TCP DNS"
add chain=input action=accept protocol=icmp icmp-options=8 comment="input accept: ICMP Ping"
add chain=input action=drop
add chain=forward action=accept connection-state=established,related comment="forward accept: established,related"
add chain=forward action=accept src-address=172.23.30.0/24 dst-address=172.23.20.0/24 comment="forward accept: Client -> Service"
add chain=forward action=accept out-interface=ether1_WAN comment="forward accept: to WAN"
add chain=forward action=drop
print
# Enable VLAN filtering
/interface/bridge set bridge_LAN vlan-filtering=yes
My upDNS/downDNS template (IP switched accordingly):
:local primaryDNS "172.23.20.2"
:local backupDNS "1.1.1.1"
:local currentDNS /ip dns get servers
:if ($currentDNS = $primaryDNS) do={
/ip dns set servers=$backupDNS
}