Masquerade not functioning

Hello,
I’ve made thread some time earlier (http://forum.mikrotik.com/t/problem-with-vlan-routing/137753/1), but i seems i was out of my depth.
So i have simplified configuration, stripped those unused “public” vlans and setup somewhat testing enviroment.
Switch1, ether1 [S1E1] is uplink to Zyxel DHCP, which gives 10.10.30.x/24 adresses
Switch1, ether3 [S1E3] is only port in bridgePublic and is conected to [S3E1]
Switch3, ether2 [S3E2] is connected to synology, from where i test conectivity

On Switch1 all ports except ether3 are in bridge LAN
On Switch3 ports ether1-8 are bridged to bridgePublic
There is DHCP Server on Switch1, which gives out 10.10.32.x/24 adresses through bridgePublic with adress 10.10.32.1/24 (only port is S1E3)

So far I am getting 10.10.32.249/24 on S3E3, as expected, and a can ping 10.10.32.1
But whe i set up masquerade rule on S1

chain=srcnat action=masquerade src-address=10.10.32.0/24 log=no log-prefix=""

i cannot ping upstream from S1, for example cloudflare [1.1.1.1]

When i set up analogically different MT in another part of topology it worked.

Can anybody help?

No need to begin a new post… we could continue there…
Well since no one know how your VLANs are configured, it is difficult to predict the problem…

Obviously it is not the Masquerade rule that does not work but something inside your VLANs…
You could export your configs with hide-sensitive and post it inside code tags…

Hello, I’ve stripped those VLANs to narrow the problem.
Only ones, that are there are those in bridgeLAN, and they function normally - getting adresses, comunicating with outide world, the whole shebang.

Sorry for the delay
Switch1

# apr/07/2020 11:36:53 by RouterOS 6.44.5
# software id = JWFR-BF3V
#
# model = CRS326-24G-2S+
# serial number = 94550BE4E7A0
/caps-man channel
add band=2ghz-b/g/n name=chan_2,4
add band=5ghz-a/n name=chan5GHz
/caps-man datapath
add client-to-client-forwarding=yes local-forwarding=yes name=pathLAN
/interface bridge
add name=bridgeLAN protocol-mode=none
add name=bridgePUBLIC
add name=bridgeSERV
/interface ethernet
set [ find default-name=ether1 ] comment="Uplink Zyxel"
set [ find default-name=ether2 ] comment="MT switch 2"
set [ find default-name=ether3 ] comment="MT switch 3"
/interface pptp-client
add connect-to=yyy name=yyy user=tmp
/interface vlan
add disabled=yes interface=ether1 name=e1_LAN_10 vlan-id=10
add disabled=yes interface=ether1 name=e1_PUB_20 vlan-id=20
add interface=ether2 name=e2_LAN_10 vlan-id=10
add interface=ether2 name=e2_PUB_20 vlan-id=20
add disabled=yes interface=ether3 name=e3_LAN_10 vlan-id=10
add disabled=yes interface=ether3 name=e3_PUB_20 vlan-id=20
add interface=ether4 name=e4_LAN_10 vlan-id=10
add interface=ether4 name=e4_PUB_20 vlan-id=20
add interface=ether5 name=e5_LAN_10 vlan-id=10
add interface=ether5 name=e5_PUB_20 vlan-id=20
add interface=ether6 name=e6_LAN_10 vlan-id=10
add interface=ether6 name=e6_PUB_20 vlan-id=20
add interface=ether7 name=e7_LAN_10 vlan-id=10
add interface=ether7 name=e7_PUB_20 vlan-id=20
/caps-man datapath
add bridge=bridgePUBLIC client-to-client-forwarding=no local-forwarding=no name=pathPUBLIC
/caps-man security
add authentication-types=wpa-psk,wpa2-psk encryption=aes-ccm,tkip group-encryption=tkip name=secLAN
add authentication-types=wpa-psk,wpa2-psk encryption=aes-ccm,tkip group-encryption=tkip name=secPUBLIC
/caps-man configuration
add channel=chan_2,4 country="czech republic" datapath=pathLAN mode=ap name=cfgLAN_2,4GHz security=secLAN ssid="xxx"
add channel=chan_2,4 country="czech republic" datapath=pathPUBLIC mode=ap name=cfgPUBLIC_2,4GHz security=secPUBLIC ssid="xxx Guest"
add channel=chan5GHz country="czech republic" datapath=pathLAN mode=ap name=cfgLAN_5GHz security=secLAN ssid="xxx"
add channel=chan5GHz country="czech republic" datapath=pathPUBLIC mode=ap name=cfgPUBLIC_5GHz security=secPUBLIC ssid="xxx Guest"
/caps-man interface
add configuration=cfgLAN_2,4GHz disabled=no mac-address=C4:AD:34:9E:AD:4E master-interface=none name=2,4GHz-RAPSUT001-1 radio-mac=C4:AD:34:9E:AD:4E radio-name=\
    C4AD349EAD4E
add configuration=cfgPUBLIC_2,4GHz disabled=no mac-address=C6:AD:34:9E:AD:4E master-interface=2,4GHz-RAPSUT001-1 name=2,4GHz-RAPSUT001-1-1 radio-mac=\
    00:00:00:00:00:00 radio-name=C6AD349EAD4E
add configuration=cfgLAN_2,4GHz disabled=no mac-address=C4:AD:34:9E:AD:A6 master-interface=none name=2,4GHz-RAPSUT002-1 radio-mac=C4:AD:34:9E:AD:A6 radio-name=\
    C4AD349EADA6
add configuration=cfgPUBLIC_2,4GHz disabled=no mac-address=C6:AD:34:9E:AD:A6 master-interface=2,4GHz-RAPSUT002-1 name=2,4GHz-RAPSUT002-1-1 radio-mac=\
    00:00:00:00:00:00 radio-name=C6AD349EADA6
add configuration=cfgLAN_5GHz disabled=no mac-address=C4:AD:34:9E:AD:4F master-interface=none name=5GHz-RAPSUT001-1 radio-mac=C4:AD:34:9E:AD:4F radio-name=\
    C4AD349EAD4F
add configuration=cfgPUBLIC_5GHz disabled=no mac-address=C6:AD:34:9E:AD:4F master-interface=5GHz-RAPSUT001-1 name=5GHz-RAPSUT001-1-1 radio-mac=00:00:00:00:00:00 \
    radio-name=C6AD349EAD4F
add configuration=cfgLAN_5GHz disabled=no mac-address=C4:AD:34:9E:AD:A7 master-interface=none name=5GHz-RAPSUT002-1 radio-mac=C4:AD:34:9E:AD:A7 radio-name=\
    C4AD349EADA7
add configuration=cfgPUBLIC_5GHz disabled=no mac-address=C6:AD:34:9E:AD:A7 master-interface=5GHz-RAPSUT002-1 name=5GHz-RAPSUT002-1-1 radio-mac=00:00:00:00:00:00 \
    radio-name=C6AD349EADA7
/interface list
add name=WAN
add exclude=WAN include=all name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=poolPUBLIC ranges=10.10.32.32-10.10.32.250
/ip dhcp-server
add add-arp=yes address-pool=poolPUBLIC disabled=no interface=bridgePUBLIC lease-time=8h name=dhcpPUBLIC
/caps-man manager
set enabled=yes
/caps-man provisioning
add action=create-enabled hw-supported-modes=b master-configuration=cfgLAN_2,4GHz name-format=prefix-identity name-prefix=2,4GHz slave-configurations=\
    cfgPUBLIC_2,4GHz
add action=create-enabled hw-supported-modes=an master-configuration=cfgLAN_5GHz name-format=prefix-identity name-prefix=5GHz slave-configurations=cfgPUBLIC_5GHz
/interface bridge nat
add action=accept chain=srcnat
add action=accept chain=dstnat
/interface bridge port
add bridge=bridgeLAN interface=ether1
add bridge=bridgePUBLIC interface=ether3
add bridge=bridgeSERV interface=ether5
add bridge=bridgeSERV interface=ether6
add bridge=bridgeLAN interface=ether7
add bridge=bridgeLAN interface=ether8
add bridge=bridgeLAN interface=ether9
add bridge=bridgeLAN interface=ether10
add bridge=bridgeLAN interface=ether11
add bridge=bridgeLAN interface=ether12
add bridge=bridgeLAN interface=ether13
add bridge=bridgeLAN interface=ether14
add bridge=bridgeLAN interface=ether15
add bridge=bridgeLAN interface=ether16
add bridge=bridgeLAN interface=ether17
add bridge=bridgeLAN interface=ether18
add bridge=bridgeLAN interface=ether19
add bridge=bridgeLAN interface=ether20
add bridge=bridgeLAN interface=ether21
add bridge=bridgeLAN interface=ether22
add bridge=bridgeLAN interface=ether23
add bridge=bridgeLAN interface=ether24
add bridge=bridgeLAN interface=e2_LAN_10
add bridge=bridgeSERV interface=ether2
add bridge=bridgeLAN disabled=yes interface=e3_LAN_10
add bridge=bridgeLAN interface=e4_LAN_10
add bridge=bridgeLAN interface=e5_LAN_10
add bridge=bridgeLAN interface=e6_LAN_10
add bridge=bridgePUBLIC disabled=yes interface=e2_PUB_20 pvid=20
add bridge=bridgePUBLIC disabled=yes interface=e3_PUB_20 pvid=20
add bridge=bridgePUBLIC disabled=yes interface=e4_PUB_20
add bridge=bridgePUBLIC disabled=yes interface=e5_PUB_20
add bridge=bridgePUBLIC disabled=yes interface=e6_PUB_20
add bridge=bridgeLAN interface=ether4
add bridge=bridgePUBLIC disabled=yes interface=e1_PUB_20
add bridge=bridgeLAN interface=e1_LAN_10
/interface detect-internet
set wan-interface-list=WAN
/interface list member
add interface=ether1 list=WAN
add disabled=yes interface=bridgeLAN list=LAN
/ip address
add address=10.10.31.1/24 interface=bridgeSERV network=10.10.31.0
add address=10.10.32.1/24 interface=bridgePUBLIC network=10.10.32.0
add address=10.10.30.198/24 interface=bridgeLAN network=10.10.30.0
add address=10.10.32.15/24 disabled=yes interface=e3_PUB_20 network=10.10.32.0
/ip dhcp-relay
add dhcp-server=10.10.30.1 disabled=no interface=bridgeLAN name=relayLAN
/ip dhcp-server network
add address=10.10.32.0/24 dns-server=10.10.30.1 gateway=10.10.32.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=10.10.30.1
/ip firewall filter
add action=accept chain=forward connection-state=established,related
add action=accept chain=input connection-state=established,related
add action=accept chain=output connection-state=established,related
add action=accept chain=forward in-interface=bridgePUBLIC
add action=accept chain=input in-interface=bridgePUBLIC log=yes log-prefix="pulic accept"
/ip firewall nat
add action=masquerade chain=srcnat src-address=10.10.32.0/24
/ip route
add distance=1 gateway=10.10.30.1
add disabled=yes distance=1 dst-address=10.10.30.1/32 gateway=ether1
/system clock
set time-zone-name=Europe/Prague
/system identity
set name=RTBSUT001
/system routerboard settings
set boot-os=router-os

Switch3

# apr/07/2020 11:40:54 by RouterOS 6.46.4
# software id = I423-DQD8
#
# model = CRS326-24G-2S+
# serial number = 94550BB5D052
/interface bridge
add name=bridgeLAN
add name=bridgePUBLIC
add name=bridgeSERV
add name=bridgeTest
/interface vlan
add disabled=yes interface=ether1 name=e1_LAN_10 vlan-id=10
add disabled=yes interface=ether1 name=e1_PUBLIC_20 vlan-id=20
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/interface bridge port
add bridge=bridgeTest interface=ether2 pvid=20
add bridge=bridgeTest interface=ether3
add bridge=bridgeTest interface=ether4
add bridge=bridgeTest interface=ether5
add bridge=bridgeTest interface=ether6
add bridge=bridgeTest interface=ether7
add bridge=bridgeTest interface=ether8
add bridge=bridgeLAN interface=ether9
add bridge=bridgeLAN interface=ether10
add bridge=bridgeLAN interface=ether11
add bridge=bridgeLAN interface=ether12
add bridge=bridgeLAN interface=ether13
add bridge=bridgeLAN interface=ether14
add bridge=bridgeLAN interface=ether15
add bridge=bridgeLAN interface=ether16
add bridge=bridgeLAN interface=ether17
add bridge=bridgeLAN interface=ether18
add bridge=bridgeLAN interface=ether19
add bridge=bridgeLAN interface=ether20
add bridge=bridgeLAN interface=ether21
add bridge=bridgeLAN interface=ether22
add bridge=bridgeLAN comment="uplink cisco" interface=ether23
add bridge=bridgeLAN interface=ether24
add bridge=bridgeLAN disabled=yes interface=e1_LAN_10 pvid=10
add bridge=bridgePUBLIC disabled=yes interface=e1_PUBLIC_20 pvid=20 trusted=yes
add bridge=bridgeTest interface=ether1
/ip address
add address=10.10.31.3/24 interface=bridgeSERV network=10.10.31.0
add address=10.10.32.3/24 interface=bridgePUBLIC network=10.10.32.0
add address=10.10.30.199/24 interface=bridgeLAN network=10.10.30.0
add address=10.10.32.16/24 interface=e1_PUBLIC_20 network=10.10.32.0
/ip dns
set allow-remote-requests=yes servers=10.10.30.1
/ip firewall filter
add action=accept chain=forward connection-state=established,related
add action=accept chain=input connection-state=established,related
add action=accept chain=output connection-state=established,related
add action=drop chain=forward disabled=yes in-interface=bridgePUBLIC out-interface=bridgeSERV
add action=drop chain=forward disabled=yes
add action=accept chain=input disabled=yes in-interface=bridgePUBLIC log=yes log-prefix=qqqqq
/ip route
add distance=1 gateway=10.10.30.1
/system clock
set time-zone-name=Europe/Prague
/system identity
set name=RTBSUT003
/system routerboard settings
set boot-os=router-os

Before i take a look at your Config, can you please tell me a little more about what does “Masquerade not functioning” means?

Can you draw a diagram of your network. It seems very confusing at the moment as its not clear to me what devices you have, and if they are acting as switches or routers.

“Masquerade not functioning” meaning : I can’t get from 10.10.32.x/24 subnet anywhere past Switch1, adresses aren’t NATed, the rule itself, if i log it, doesn’t get triggered
mikrotik scheme.png
I can ping from NAS eth3 as far as 10.10.30.198 but not 10.10.30.1

Switch 1 does not need any Masquerade Rule to Ping 1.1.1.1 or any Public Address !!!
When switch 1 tries to reach 1.1.1.1 it will send the traffic to its default gateway 10.10.30.1 through ether 1 with IP 10.10.30.198. So 10.10.30.198 → 10.10.30.1.. Then the ISPs Router will nat the connection, reach 1.1.1.1 and when the reply comes back it will unNAT the connection and send it back to 10.10.30.198 with src address 1.1.1.1… So switch 1 will get a reply from the address it expected, so everything is fine…
This does not ofcorse happen when we try to reach 1.1.1.1 or 10.10.30.1 from switch 2. There we need the masquerade rule, because our ISP’s router does not know how to reach switch 2… (You could instead add a route on your ISP for the subnet 10.10.32.0./24 with Gateway 10.10.30.198)

Check the above cases and check your whole configuration again…

I think you’re not getting what i’m saying:
Of course switch1 can ping everything, no problem there.
Switch3 on the other hand…
“There we need the masquerade rule, because our ISP’s router does not know how to reach switch 2”, it’s switch 3, but thats just semantics
The rule is there

add action=masquerade chain=srcnat src-address=10.10.32.0/24

Agree with Zach. There is only one device you should be calling a switch. The first device is the primary router, the second device is acting a a router and the third device is acting purely a switch.
Personally I would ditch the zyxel unit, as I do not see what it adds to the mix, other than making your life difficult.
Also you seem to be concerned with traffic coming from the ISP getting back to the third device, that is destination NAT.

@Zach There we need the masquerade rule, because our ISP’s router does not know how to reach switch 2… (You could instead add a route on your ISP for the subnet 10.10.32.0./24 with Gateway 10.10.30.198) Do you mean the options are.

(1) On Secondary Router, create a routing from 10.10.32.1 to 10.30.1.198? or
(2) On Secondary Router create a masquerade rule
add chain=srcnat action=src-nat src-address=10.10.32.0/24 to-address=10.10.30.198 out-interface=bridgeLAN

@anav,
(1) That is not needed anyways, so no…
(2) Also even if you don’t specify the “to-address=10.10.30.198” the masquerade will see that the out interface is 10.10.30.198 so that will be the address that we will be masqueraded to anyways…

What i said is a little different… That even if we do not use masquerade at all we can still reach the internet but we must first let the ISPs router know where we are, or better where we are…
Case 1, Secondary Router with No masquerade or Src-NAT:
ping 1.1.1.1 Rersults to:
1.The secondary Router will send the Traffic to the ISPs Router through 10.10.30.198, ISP will perform NAT on its Side and reach 1.1.1.1, when the reply comes back from 1.1.1.1, ISP’s Router will perform reverse NAT (unNAT the connection), and the Secondary Router will receive it’s answer from 1.1.1.1 as it should. So success !!!

Case 2, Switch 10.10.32.3 with No masquerade or Src-NAT && Secondary Router with No masquerade or Src-NAT :
ping 1.1.1.1 from the switch Results to:
The switch must have a default route to 10.10.32.1, our secondary Router, so it will send all the unknown traffic there… So after the switch sends the traffic to the Secondary Router, the Secondary router will send this unknown traffic to our ISP’s Router through it’s default route… So our ISP’s Router will receive a packet from 10.10.32.3,our Switch, and destination address 1.1.1.1. The ISP’s Router will NAT the connection reach the destination 1.1.1.1, perform reverse NAT again as soon as it gets the reply from 1.1.1.1, and it will try to reach 10.10.32.3 so that it sends the answer back from 1.1.1.1… But where is 10.10.32.3 ? ISP’s Router has no clue…! So our Switch will never get a responce! But if we add a route on the ISP’s Router for the subnet 10.10.32.0/24 with gateway 10.10.30.198, now the ISP’s Router knows how to reach 10.10.32.3 and it will successfully send the answer from 1.1.1.1. So success again !!!

So on both cases we could reach the Internet without any Masquerade Rule… I tried to explain it in simple words…

Ofcorse the easiest is to just add a masquerade rule on the Secondary Router and everything should/must work.. If it doesn’t something is wrong on the Secondary Router, or the Switch or anywhere else…

@Zacharis

  1. Nope, doesn’t work
  2. I’ll try adding route
ip route add distance=1 dst-address=10.10.32.0/24 gateway=10.10.30.198

on Switch1 (Secondary router)
Tomorrow and see what i see, although we’re planning to isolate 10.10.30.x and 10.10.32.x sites in the future

Removing Zyxel is planned, but for now it’s a no-go, there is standing outsourcing contract.

What boggles me most is that i have, as i posted, pair of mikrotiks in another part of network set up fairy same, and they work!
Will post configs tommorow for you to exemine

@crucker what i ve suggested are working methods !!!
(1) Obviously there are more things going wrong with your configuration then!!!
(2) You dont read carefully my suggestions… That route must be added to your ISP not at the Mikrotik !!!

What boggles me most is that i have, as i posted, pair of mikrotiks in another part of network set up fairy same, and they work!

The fact that one Works and a different one doesn’t does not mean anything…

Reset totally the secondary router to no configuration… set an address to ether 1, 10.10.30.198/24, create a default route to 10.10.30.1. Open a terminal and see that you can ping 1.1.1.1

so, for 2)Sorry i misread, but as i said, i can’t touch the isp router (Zyxel)
As for total reset, i was saving that for last.
I’ll try, but there MUST be a bridge with other ports, not naked ether1. I’m just saying this up front, so i don’t get scolded when there isn’t one.
First attempt i can do is friday morning (holiday), so there won’t be updates since then.

If anyone else have any ideas, you are welcome to post.

@Zacharis
“The fact that one Works and a different one doesn’t does not mean anything…”
Bit undeterministic, isn’t it?

No…
Each Mikrotik can have totally different configuration.. So it does not say anything to me..
Also i do not understand why you can’t add a route on your ISP’s Router…

The fact that i said, only ether1, is so that you see it actually works.. So please just keep your config to only the absolutely basics… This will help you and not me…
I know how it works… If you keep adding and adding things that you don’t know what they do, most probably you will not make this simple setup work!

The thing is i need secondary router(Switch1) to switch on nearly all ports - hence the bridgeLAN

The whole setup is screwy.
Now that I think I understand it better here is what I suggest.

Only use the DHCP from the zyxel as the WANIP for the second device and not for any devices on device 2.
Thus S1E1 is a “WAN” input.
The second device will act fully as a router.
Then in the second device only need to create ONE bridge with two (or more vlans)
vlanA, is for the local devices on that switch/router
vlanB is for the third device switch only

Much better because on the second device you can create as many vlans as you wish and pass them down to the third device (purely acting as a switch) not just vlan B, if required.

@anav
Hello, your post has very little usable informations - is it posible for you to at least use the terminology in opening post [Zyxel, Switch1, Switch3]?

And, if it is not obvious:
I cannot mess with Zyxel
I need 10.10.30.x/24 network on Switch1 - there are devices with static adresses
10.10.32.x/24 won’t be necessary only on Switch3 - it should be a VLAN for Guest devices. I’ve stripped the vlans and made it only subnet on physical ports so it can be tuneable without any fuss.

Suspect you need to read up on configuring MT switches and you can do it two ways.
Use SWOS, which is not always intuitive or use ROUTER OS and use hardware offloading.
example is check out last code block in this post…
viewtopic.php?f=2&t=158824&p=780499#p780499

This is your post from last thread. Are you trying to help or just throwing ideas without any connection?

@crucker,
Although i ve given you sollutions i will sum up to the basics…

Secondary Router:

  1. add an address to your eth1 10.10.30.198/24
  2. bridge all the other ports and set your LAN address on the Bridge Interface 10.10.32.1/24
  3. create your masquerade rule, out interface must be eth1
  4. add a default route with gateway the Zyxel’s IP
  5. Add DNS to your Router and enable the remote requests
    Switch:
  6. Bridge all ports
  7. Set an address to the Bridge interface 10.10.32.2/24
  8. add a default route with gateway 10.10.32.1
  9. Bridge any port with any port of the secondary router, not eth1

If this does not work, then you obviosuly making something wrong during your configuration…