Hello,
I have an external router doing nat translation and providing DHCP services to the internal VLANs under the bridge interface. I want to block the packets coming from the VLANs to the router except DHCP. For testing reasons at first I wanted to block the DHCP packets then invert the conditions. I routed the bridged packets through the firewall (use-ip-firewall and use-ip-firewall-for vlan), marked them in the mangle prerouting chain (added packet mark: dhcp and log prefix: dhcp_prerouting:) and then wanted to block in the filter rules input chain (packet mark: dhcp, chain: input action: drop, log prefix: Drop-DHCP:). I log all firewall actions related to the given rules. The packet is marked correctly then identified by the filter rule but it reaches the router and gets answered.
/interface bridge
add name=bridge vlan-filtering=yes
/interface ethernet
set [ find default-name=ether1 ] disable-running-check=no
/interface vlan
add interface=bridge name=Vlan10 vlan-id=10
add interface=bridge name=Vlan20 vlan-id=20
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=VLAN10 ranges=192.168.10.2-192.168.10.254
add name=VLAN20 ranges=192.168.20.2-192.168.20.254
/ip dhcp-server
add address-pool=VLAN10 interface=Vlan10 lease-time=1d name=Vlan10DHCP
add address-pool=VLAN20 interface=Vlan20 lease-time=1d name=Vlan20DHCP
/port
set 0 name=serial0
set 1 name=serial1
/interface bridge port
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=ether2 pvid=10
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=ether3 pvid=20
/interface bridge settings
set use-ip-firewall=yes use-ip-firewall-for-vlan=yes
/ip neighbor discovery-settings
set discover-interface-list=all
/interface bridge vlan
add bridge=bridge tagged=bridge untagged=ether2 vlan-ids=10
add bridge=bridge tagged=bridge untagged=ether3 vlan-ids=20
/ip address
add address=192.168.10.1/24 interface=Vlan10 network=192.168.10.0
add address=192.168.20.1/24 interface=Vlan20 network=192.168.20.0
/ip dhcp-client
add interface=ether1
/ip dhcp-server network
add address=192.168.10.0/24 dns-server=192.168.10.1 gateway=192.168.10.1 netmask=24
add address=192.168.20.0/24 dns-server=192.168.20.1 gateway=192.168.20.1 netmask=24
/ip dns
set allow-remote-requests=yes
/ip firewall filter
add action=drop chain=input log=yes log-prefix=Drop-DHCP: packet-mark=dhcp
add action=accept chain=input connection-state=established
add action=drop chain=input
/ip firewall mangle
add action=mark-packet chain=prerouting dst-port=67 in-interface=bridge log=yes log-prefix=dhcp_prerouting: new-packet-mark=dhcp passthrough=yes protocol=udp
/ip firewall nat
add action=masquerade chain=srcnat log=yes log-prefix=nat: out-interface=ether1
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set api disabled=yes
set api-ssl disabled=yes
and get the following log:
*25E 21:24:25 firewall,info dhcp_prerouting: prerouting: in:bridge(ether3) out:(unknown 0), connection-state:new src-mac 00:0c:29:17:0a:63, proto UDP, 0.0.0.0:68->255.255.255.255:67, len 328
*25F 21:24:25 firewall,info Drop-DHCP: input: in:Vlan20(ether3) out:(unknown 0), packet-mark:dhcp connection-state:new src-mac 00:0c:29:17:0a:63, proto UDP, 0.0.0.0:68->255.255.255.255:67, len 328
*260 21:24:26 dhcp,info Vlan20DHCP assigned 192.168.20.254 for 00:0C:29:17:0A:63 MikroTik
*261 21:24:26 firewall,info dhcp_prerouting: prerouting: in:bridge(ether3) out:(unknown 0), connection-state:new src-mac 00:0c:29:17:0a:63, proto UDP, 0.0.0.0:68->255.255.255.255:67, len 328
*262 21:24:26 firewall,info Drop-DHCP: input: in:Vlan20(ether3) out:(unknown 0), packet-mark:dhcp connection-state:new src-mac 00:0c:29:17:0a:63, proto UDP, 0.0.0.0:68->255.255.255.255:67, len 328
What is wrong in the configuration?