Hi guys!
One of my customers has a /29 public subnet routed by the ISP through a link public IP (static assigned) for quite a few years.
All customer services (like MTA, DVR, monitoring etc). running on various machines on the LAN, are bound to different public IP from the /29 subnet (with VIPs configured on a Fortigate 40C).
As the Forti is pretty obsolete, I’m trying to find the best option to replicate the configuration with a RouterOS (most probable will be a entry level CCR).
The main scenario is following (I will put it with below test rig information, in order to be easier to follow, please don’t mind the non-public link IP):
- ISP link IP: 192.168.0.253/24
- gateway for link IP: 192.168.0.254
- /29 subnet: 2.2.2.0/29 routed through 1.1.1.1 above (link IP).
- /24 local subnet for clients: 10.0.0.0/24
From the /29 above I need to assign some public IPs for specific access to / from LAN side: ex: one for MTA, one for httpd, one for NAT access for rest of the clients.
I managed to configure the above setup (or similar) on different routers (Juniper, AT, Fortigate), using different approaches (eNat, VIPs, etc) Mikrotik is giving me some issues. There is also an older topic on the subject, which is now closed, and now I found some spare time (due to overall global status) and I am back on the issue.
Starting from http://forum.mikrotik.com/t/nat-plus-1-1-nat/50487/1 i managed to get some results.
This is what I managed to do (full script below, test rig is a hAP AC2, clients and test - different real and virtual machines in my office, with proper routes added):
- 1:1 NAT for 2.2.2.2 to 10.0.0.199 - the “httpd machine” - which is fine, and works as intended
- 1:1 NAT for 2.2.2.3 to 10.0.0.198 - the “MTA machine” - which is fine, and works as intended
- masquerade for rest of the clients: 2.2.2.4 to 10.0.0.0/24
- hairpin NAT from 10.0.0.0/24 to above services (httpd - TCP 80 to 10.0.0.199, SMTP - TCP 25 to 10.0.0.198, from rest of the LAN clients) (now seem to work after removing interface binding)
What I am missing:
- confirmation that this is the right approach for the job. Should I do it otherwise? Is there any risk doing it like this?
- firewall access rules for 1:1 NAT public IPs (will do, they are not important at this time, as the test rig is behind a local subnet) - if you have any advice on this one, would be welcome!
I filtered the config below (like setting interfaces names, wifi setup, etc):
/interface bridge
add name=bridge-local
/interface bridge port
add bridge=bridge-local interface=ether2-master-local
add bridge=bridge-local interface=ether3-slave-local
add bridge=bridge-local interface=ether4-slave-local
add bridge=bridge-local interface=ether5-slave-local
add bridge=bridge-local interface=wlan1
add bridge=bridge-local interface=wlan2
/ip address
add address=10.0.0.254/24 comment="LAN interface" interface=bridge-local network=10.0.0.0
add address=192.168.0.253/24 comment="WAN interface" interface=ether1-gateway network=192.168.0.0
add address=2.2.2.1/29 comment="public /29" interface=ether1-gateway network=2.2.2.0
add address=2.2.2.2/29 interface=ether1-gateway network=2.2.2.0
add address=2.2.2.3/29 interface=ether1-gateway network=2.2.2.0
add address=2.2.2.4/29 interface=ether1-gateway network=2.2.2.0
/ip route
add distance=1 gateway=192.168.0.254
/ip dhcp-server network
add address=10.0.0.0/24 comment="default configuration" dns-server=192.168.0.246 gateway=10.0.0.254 netmask=24
/ip dns
set allow-remote-requests=yes servers=192.168.0.246
/ip firewall filter
add chain=input comment="default configuration" protocol=icmp
add chain=input comment="default configuration" connection-state=established
add chain=input comment="default configuration" connection-state=related
add chain=input comment="Winbox accept from 192.168.0.0/24" dst-port=8291 protocol=tcp src-address=192.168.0.0/24
add chain=forward comment="default configuration" connection-state=established
add chain=forward comment="default configuration" connection-state=related
/ip firewall nat
add action=masquerade chain=srcnat comment="2.2.2.2 traffic - HTTP server" dst-address=10.0.0.199 src-address=10.0.0.0/24
add action=dst-nat chain=dstnat dst-address=2.2.2.2 to-addresses=10.0.0.199
add action=src-nat chain=srcnat src-address=10.0.0.199 to-addresses=2.2.2.2
add action=masquerade chain=srcnat comment="2.2.2.3 traffic - MTA" dst-address=10.0.0.198 src-address=10.0.0.0/24
add action=dst-nat chain=dstnat dst-address=2.2.2.3 to-addresses=10.0.0.198
add action=src-nat chain=srcnat src-address=10.0.0.198 to-addresses=2.2.2.3
add action=src-nat chain=srcnat comment="2.2.2.4 - rest of the clients" out-interface=ether1-gateway src-address=10.0.0.0/24 to-addresses=2.2.2.4
add action=masquerade chain=srcnat comment="general public maquerade" out-interface=ether1-gateway
Thank you!
T
PS: added MTA rules, corrected 1:1 masquerade, correct topic title (initially left by mistake as “RouterOS”). ![]()