Reaching Host with Public IP in/from inside a segmented network

Since I feel like a beginner, I hope this counts as a beginners question. Our setup had been created by my son but he also has no idea why the following setup does not do what I’d like it to do.

We have several households that are served by a common internet connection using a Mikrotik Router to control everything. So each subnet is connecting to two WANs (LTE) and this works well. What also works well is that we have separated the subnets since we have no need to send data that way. This is all fine and working.

Now I have a nextcloud instance running in my subnet which is reachable via a public fixed IP (provided by one of the LTE connections). This works fine - inside my subnet and also when the user is “elsewhere”. A user from one of the isolated subnets can’t reach that server however. Sounds as if this has something to do with the isolation. So I tried to add rules to the firewall to allow packets directed to the IP of the nextcloud-host also from the other subnets. Seems not to work and I fear I have some basic misunderstanding here.

I have attached a dump of my config.

The rule added is
add action=accept chain=forward dst-address=192.168.80.100 dst-port=443 log=yes log-prefix=NEXTCLOUD protocol=tcp

Any ideas? Help is appreciated
Peter
mikrotik.config.txt (13.1 KB)

Any connection from in-interface-list=LAN (except those to 192.168.1-4.0/24) will get connection mark WANx-connection and then routing mark to-WANx. Problem is, routing table to-WANx has only single default route to internet and no route to local subnets. So packet to 192.168.80.100 will end up going to internet and won’t reach your server.

This is completely useless:

/ip firewall nat
add action=dst-nat chain=dstnat dst-address=192.168.80.100 dst-port=443 in-interface-list=LAN log=yes log-prefix=NAT8 protocol=tcp to-addresses=192.168.80.100 to-ports=443

If you’d want to allow direct connections to 192.168.80.100, you could add similar rule like you already have for 192.168.1-4.0/24 at the beginning of “/ip firewall mangle”. If you want it to work with public address, you need dstnat rule like this:

/ip firewall nat
add action=dst-nat chain=dstnat dst-address=<public address> dst-port=443 in-interface-list=LAN protocol=tcp to-addresses=192.168.80.100 to-ports=443

Then you need either another exception in “/ip firewall mangle” for , or you can use:

/ip route rule
add action=lookup-only-in-table dst-address=192.168.80.100 table=main

You could probably do that for all local subnets, because none of them are reachable in internet anyway:

/ip route rule
add action=lookup-only-in-table dst-address=192.168.0.0/16 table=main

But I’m too lazy to study if some of your isolation does not depend on this “bug” you want to fix for 192.168.80.100.

If you want to be able to connect to also from 192.168.80.0/24, you’ll need to read about hairpin NAT.

Thanks, will now try to understand, digest and try to apply what you wrote… will come back with questions if any.

Peter