NAT question

My current network setup:

My Wan IP: 85.0.0.2/30 (Net-Id 85.0.0.0 ISP-GW: 85.0.0.1 Broadcast: 85.0.0.3)
Ekstra 30 Public IP-Net: Net-Id 85.0.0.64/27 Broadcast: 85.0.0.95
Host-Range: 85.0.0.65 - 85.0.0.94

Mikrotik setup:
Interface:
ether1 Wan
ether2 PubIPs

Address
add address=85.0.0.2/30 network=85.0.0.0 broadcast=85.0.0.95 interface=“ether1 Wan” \ comment=“” disabled=no
add address=85.0.0.94/27 network=85.0.0.64 broadcast=85.0.0.95 interface=“ether2 PubIPs” \ comment=“” disabled=no

Route
add dst-address=0.0.0.0/0 gateway=85.0.0.1 distance=1 scope=255 target-scope=10 \ comment=“” disabled=no

Filter rules: apllied to the HostRange using the foreward chain and the router itself on the input chain.

Pub. IPs used for web servers and other services demanding static IPs.

I would like to use one of the static IP to hide a local network behind a NAT - I have used a separate Mikrotik router for this - which work fine.

Now I would like to drop the second Router and include the NAT function in my MainRouter.

  1. Is that possible ?
    So far I have added interface “ether3 local”
    add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255
    interface=“ether3 local” comment=“” disabled=no
    NAT:
    add chain=srcnat action=src-nat to-addresses=85.0.0.70 to-ports=0-65535
    out-interface=“ether2 PubIPs” src-address=192.168.1.0/24 comment=“”
    disabled=no

Local network gets behind the NAT with the public IP 85.0.0.70
Local network has 192.168.1.1 as GateWay

  1. From the local network I can ping other servers in my HostRange - but nothing outside - how do I route packet to the internet ?

  2. How do I apply Filter rules for the In and outgoing traffic for the Natted local network.

/Lars
Learning is a never ending story

I’m not sure what you are trying to do is possible with just one router. When you are doing the NAT for the 192.168.1.0/24 subnet you are sending the traffic out of ether2, that traffic has no way of getting back to the router for further routing, it just leaves the interface.

You can try something like that is described in this thread, but I don’t know if it will do what you want.
http://forum.mikrotik.com/t/loopback-interface/20725/1
I.E. place your /27 on a bridge with no interfaces assigned to it and NAT out of that interface and see what happens.

Unless I’m thinking about this wrong you should be ble to just adjust the source NAT rule and set the out-interface to ether1. The NAT algorithm shouldn’t care that you’re translating to an address found behind ether2. Also remove the to-ports option as it is unnecessary.

If it does not work like that the loopback trick should work just fine. Assign the /32 to NAT to as the address of a bridge without any ports, source NAT the LAN to that IP for an out-interface of ether1.

Filtering works as usual - just refer to the packet flow diagram. For outbound traffic the forward chain comes before source NAT so you refer to real (private) IP addresses. For return traffic in established connections source NAT is undone in destination NAT before the forward chain, so again you refer to real IPs. For inbound traffic initiated from the WAN (requires port forwarding due to NAT) prerouting is before destination NAT and you use the public IP, everything afterwards is after destination NAT and you refer to the real IP.

Hi fewi

Adjusting the SourceNAT to Out-interface ether1 worked. Thx :smiley:
(The to-ports option - remove ?)

feklar: did not try the loopback trick.

Outbound traffic can be filtered in the Forward chain by using the In. Interface: “ether3 local” + Dst. Port
Inbound traffic initiated from the WAN on the public IP 85.0.0.70 needs forwarding - only if needed. However traffic like portscans ect. is handle in the Input chain together with the Router itself :slight_smile:
I now have a poster of the packet flow diagram :slight_smile: very good for a beginner like my self.

What else should i look into for securing my NAT network ?

/Lars
Learning is a never ending story