How to block inter VLAN communication

Hi,

Seems like it is impossible to block interVLAN communication between vlans (on the same bridge). I did it on earlier version of routerOS, but no way on 7.2 or 7.25,
I even tried klocking it in Bridge-Filter.
Also, in Firewall, chain: roward, action:; drop, source address VLAN1, dest address VLAN2...
Tried placing this roule at every position in firewall..nothing.
I tried it using address list and interfaces, also, nothing..

What is the secret?

You should use this way: /ip firewall filter
add chain=forward src-address=192.168.1.0/24 dst-address=192.168.2.0/24 action=drop

But the best is that: /ip firewall filter
add chain=forward in-interface=VLAN2 in-interface=VLAN1 action=drop

It works on 7.23.8 on an RB760iGS. 7.2 is really old, 7.25 is latest stable (and quite new), but I doubt that the firewall or vlans are broken. The most likely cause is an incorrect configuration.

Post your sanitized (remove SN: public static addresses, any plaintext passwords). See How to export, sanitize and post config on forum Please leave header with timestamp and ROS version and at least line with the model number. (fixed link which was incorrectly pointing to this thread).

I see magicc12 has posted since I stated. As he said, for routed traffic, which inter-vlan ip traffic is, the /ip firewall filter is the correct place.

You don't say if you want neither vlan to be able to establish new connections to the other vlan, or if one will be allowed, and the other blocked. That will affect how the firewall needs to be setup.

When I create firewalls, I have a general rule near top of the forward chain that allows return traffic to flow, and block new connections on the vlans I want to limit.

I also like to use interface lists. If you then add another vlan that should be treated the same from a security standpoint, all you then need to do is add the vlan interface as a member of the appropriate interface list.

exactly what I did, but they keep on pinging.
I ll post the config

model = RB4011iGS+5HacQ2HnD

serial number = 1

/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk comment=defconf
disable-pmkid=yes mode=dynamic-keys supplicant-identity=MikroTik
/ip cloud
set ddns-enabled=yes ddns-update-interval=10m
/ip dhcp-server network
add address=192.168.50.0/24 dns-none=yes gateway=192.168.50.1
add address=192.168.51.0/24 dns-none=yes gateway=192.168.51.1
add address=192.168.52.0/24 dns-none=yes gateway=192.168.52.1
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=
192.168.88.1
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan type=A
/ip firewall address-list
add address=192.168.100.2 list="Wire Guard Lista"
add address=192.168.100.3 list="Wire Guard Lista"
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
add name=dhcp_pool1 ranges=192.168.50.100-192.168.50.150
add name=dhcp_pool2 ranges=192.168.51.150-192.168.51.200
add name=dhcp_pool3 ranges=192.168.52.200-192.168.52.250
/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
/interface bridge
add name=TrunkB-Eth5 vlan-filtering=yes
add admin-mac=78:9A:18:94:97:B1 auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether1 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether2 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether3 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether4 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether5 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether6 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether7 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether8 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether9 ] advertise="10M-baseT-half,10M-baseT-full,100M
-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
set [ find default-name=ether10 ] advertise="10M-baseT-half,10M-baseT-full,100
M-baseT-half,100M-baseT-full,1G-baseT-half,1G-baseT-full"
/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 name=pppoe-Telekom
use-peer-dns=yes user=user
/interface wireless
set [ find default-name=wlan2 ] band=2ghz-b/g/n channel-width=20/40mhz-XX
disabled=no distance=indoors frequency=auto mode=ap-bridge name=wlan1
ssid=MikroTik-80D82F wireless-protocol=802.11
set [ find default-name=wlan1 ] band=5ghz-a/n/ac channel-width=
20/40/80mhz-XXXX disabled=no distance=indoors frequency=auto mode=
ap-bridge name=wlan2 ssid=MikroTik-80D82F wireless-protocol=802.11
/interface wireguard
add comment="HUB 4011 ruter" listen-port=37169 mtu=1420 name=
WireGuard-HUB4011
add listen-port=13231 mtu=1420 name=Wireguard
/interface vlan
add interface=TrunkB-Eth5 name=VLAN-50 vlan-id=50
add interface=TrunkB-Eth5 name=VLAN-51 vlan-id=51
add interface=TrunkB-Eth5 name=VLAN-52 vlan-id=52
/disk settings
set auto-media-interface=bridge auto-media-sharing=yes auto-smb-sharing=yes
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=pppoe-Telekom list=WAN
/interface wireguard peers
add allowed-address=192.168.100.3/32 comment="laptop podaci" interface=
Wireguard name=peer-lenovo2007 public-key=
"0xwj6g1DwMIz0XbRaKB28iXiHkwoyUH79G/q0QV13W8="
add allowed-address=192.168.100.2/32 comment="Telefon podaci" interface=
Wireguard name=peer-telefon public-key=
"fjo3Rl1tFJpoHHbT0dMforyOO7s0IPAamR7OsoJRySg="
add allowed-address=192.168.100.5/32 !client-listen-port endpoint-address=::
interface=Wireguard name="LapTop kuci" public-key=
"JaWvxkKq6LAKNzHPjnDVtpLpbDw0aPeOCEjjF/zdWxQ=\C2\A0"
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=
192.168.88.0
add address=192.168.100.1/24 comment="WireGuard private IP" interface=
Wireguard network=192.168.100.0
add address=192.168.50.1/24 interface=VLAN-50 network=192.168.50.0
add address=192.168.51.1/24 interface=VLAN-51 network=192.168.51.0
add address=192.168.52.1/24 interface=VLAN-52 network=192.168.52.0
add address=10.0.0.1 interface=WireGuard-HUB4011 network=10.0.0.1
/ip dhcp-server
add address-pool=default-dhcp interface=bridge name=defconf
add address-pool=dhcp_pool1 interface=VLAN-50 name=dhcp1
add address-pool=dhcp_pool2 interface=VLAN-51 name=dhcp2
add address-pool=dhcp_pool3 interface=VLAN-52 name=dhcp3
/ip dns
set allow-remote-requests=yes
/ip firewall filter
add action=drop chain=forward connection-state=established,new dst-address=
192.168.50.0/24 src-address=192.168.51.0/24
add action=drop chain=forward connection-state=established,new dst-address=
192.168.51.0/24 src-address=192.168.50.0/24
add action=accept chain=input comment=
"dopust za menad\C5\BEerisanje rutera na int wireguard" in-interface=
Wireguard
add action=accept chain=input comment="dopust VPN vezama" dst-port=13231
protocol=udp
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=drop chain=forward comment="defconf: drop invalid"
connection-state=invalid
add action=fasttrack-connection chain=forward comment="defconf: fasttrack"
connection-state=established,related
add action=accept chain=forward comment=
"defconf: accept established,related, untracked" connection-state=
established,related,untracked
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=masquerade chain=srcnat src-address=192.168.88.0/24
add action=masquerade chain=srcnat src-address=192.168.50.0/24
add action=masquerade chain=srcnat src-address=192.168.51.0/24
add action=masquerade chain=srcnat src-address=192.168.52.0/24
/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"
dst-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=fasttrack-connection chain=forward comment="defconf: fasttrack6"
connection-state=established,related
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/Podgorica
/system leds
add interface=wlan1 leds="wlan1_signal1-led,wlan1_signal2-led,wlan1_signal3-le
d,wlan1_signal4-led,wlan1_signal5-led" type=wireless-signal-strength
add interface=wlan1 leds=wlan1_tx-led type=interface-transmit
add interface=wlan1 leds=wlan1_rx-led type=interface-receive
/system routerboard settings
set enter-setup-on=delete-key
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
/tool romon
set enabled=yes
/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=TrunkB-Eth5 comment=defconf interface=ether5
add bridge=TrunkB-Eth5 comment=defconf interface=ether6 pvid=50
add bridge=TrunkB-Eth5 comment=defconf interface=ether7 pvid=51
add bridge=TrunkB-Eth5 comment=defconf interface=ether8 pvid=52
add bridge=bridge comment=defconf interface=ether9
add bridge=bridge comment=defconf interface=ether10
add bridge=bridge comment=defconf interface=sfp-sfpplus1
add bridge=bridge comment=defconf interface=wlan1
add bridge=bridge comment=defconf interface=wlan2
/interface bridge vlan
add bridge=TrunkB-Eth5 tagged=TrunkB-Eth5,ether5 untagged=ether6 vlan-ids=50
add bridge=TrunkB-Eth5 tagged=TrunkB-Eth5,ether5 untagged=ether7 vlan-ids=51
add bridge=TrunkB-Eth5 tagged=TrunkB-Eth5,ether5 untagged=ether8 vlan-ids=52

Thanks.

Does your client(s) receiving address from the corresponding dhcp pool when you connect it to port 6/7/8?

You may want to sanitize a bit more than you did (key).

Also that is not in standard order, I had to use "CTRL-F" to find the bridge. You also didn't paste into a </> block.

There is no need for a second bridge, there are very few cases where multiple bridges are required, and I have never used more than one. But the RB4011 does have 2 switch chips, so I believe it is possible to have 2 HW offloaded bridges on that device, but only if all members of each vlan are on the same switch chip. As you have it configured, with TrunkB-Eth5 on ports 5-8, it is not optimal.

See https://cdn.mikrotik.com/web-assets/product_files/RB4011iGSplusRM_180903.png

But that isn't the cause of the issue you are seeing.

Be aware that when you ping an interface on the router itself, it isn't using the forward chain.

Here's your original trouble report:

That says you were trying to block traffic between vlans.

Before anyone tries to dissect your (hard to read) config, can you show us what does not work?

Have you tried between devices in the different vlans?

a network diagram - even a photo of a hand drawn sketch is much easier to quickly understand than a bunch of words.

How to export, sanitize and post config on forum - gigabyte091

Please follow the standard litany when giving a problem report. From Frequently Given Answers written by JdeBP

How to Report Bugs Effectively from PuTTY author Simon Tatham's Home Page

Yes they do

Try to block another thing from a chosen VLAN, for example drop the entire communication towards wan, or block ping to/from google and check if that works or not.

Hi DanijelPG,

Buckeye already pointed in this direction, and I think your config confirms it. Which address are you pinging?

Your two drop rules for 50 and 51 are at the top of the forward chain and look fine to me. But the forward chain only sees traffic that goes through the router. If a client in VLAN 50 pings 192.168.51.1, it is pinging the router itself. That goes to the input chain, and there you have "defconf: accept ICMP". So this ping will always answer, no matter what you block in forward.

Please test it like this: from a client on ether6 (VLAN 50), ping a client on ether7 (VLAN 51), not the gateway. Make sure that client answers pings at all, because a Windows firewall often blocks them. Then look at the counters:

/ip firewall filter print stats where chain=forward

If the counters of your first two rules go up, the rules are working.

Your rules also have a gap: VLAN 52 is not covered. You can use one rule for all VLANs instead:

/interface list add name=VLANS
/interface list member add list=VLANS interface=VLAN-50
/interface list member add list=VLANS interface=VLAN-51
/interface list member add list=VLANS interface=VLAN-52
/ip firewall filter add chain=forward action=drop in-interface-list=VLANS out-interface-list=VLANS place-before=0 comment="block inter-VLAN"

After that you can remove your two old rules. This rule does not cover 192.168.88.0/24 on your other bridge, so traffic between that network and the VLANs still passes.

I haven't tested this with your config, it's only what I read from it. English is not my first language, so I used a translation help.

Regards

Hi M.Breuer1975.

Thank you very much for your answer. True, I have tried pinging gateways, because I have only one laptop :slight_smile: .
Hope you are right !

Hi again,

I have set up Chain: input, source address:vlan-50 range dest address: vlan-52 range action: Drop and everything works beautifull !!!

Hi DanijelPG,

Glad it looks better, but your new rule only stops the ping. The input chain only sees traffic to the router itself, so your rule blocks VLAN 50 from reaching 192.168.52.1. Devices in VLAN 52 have other addresses. That traffic goes through the forward chain, and in the config you posted there is no rule for VLAN 52 there. I tried your rule with the same VLAN setup on CHR: the gateway stopped answering, but a device in VLAN 52 still answered.

Also, I'm sorry: part of the command in my last post got lost. RouterOS still accepts the broken version and reads it as in-interface-list=VLANS only. That rule blocks everything coming from your VLANs, also the internet. If you added it, please remove it:

/ip firewall filter remove [find comment="block inter-VLAN"]

I have corrected the post. This is the right rule:

/ip firewall filter add chain=forward action=drop in-interface-list=VLANS out-interface-list=VLANS place-before=0 comment="block inter-VLAN"

If you did not add the list VLANS yet, the commands for it are in my corrected post.

You can test this with one laptop. Connect it to ether6 (VLAN 50) and ping an address in VLAN 52 that is not the gateway, for example 192.168.52.77. No device has to be there, the packet still goes through the forward chain. Then run this:

/ip firewall filter print stats where comment="block inter-VLAN"

If the counter goes up with each ping, the rule is catching that traffic.

I tested these commands on CHR with RouterOS 7.24.5 and 7.25.1, not on an RB4011.

Regards