Community discussions

MikroTik App
 
trebew
just joined
Topic Author
Posts: 4
Joined: Thu May 31, 2018 6:13 am

How to get a request like "sometime.myddns.com:port" to work from local network instead of using 192.168.x.x

Thu Aug 23, 2018 4:53 pm

This can be a newbie question but I really have no idea how to do… I have an address name linked to my public address (DDNS) and I want to use it locally, I mean, Instead of using 192.168.x.x, I need to use somename.myddns.com:port locally and it redirects to my local network instead of searching the internet DNS. With the ISP modem/router it works fine, not needing any configuration, but when I installed Mikrotik router it stopped working and I don’t know how to set it up.

The request somename.myddns.com:port is working fine externally, but when try to use it locally it doesn't work.
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 915
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: How to get a request like "sometime.myddns.com:port" to work from local network instead of using 192.168.x.x  [SOLVED]

Thu Aug 23, 2018 5:02 pm

Look into Hairpin NAT: https://wiki.mikrotik.com/wiki/Hairpin_NAT

Generic example (check and correct subnets for your own network):
/ip firewall nat
add chain=srcnat src-address=192.168.88.0/24 \
  dst-address=192.168.88.0/24 \
  out-interface-list=LAN action=masquerade
It will translate the connections from local addresses to local addresses as if the connections were coming from the router itself.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10551
Joined: Mon Jun 08, 2015 12:09 pm

Re: How to get a request like "sometime.myddns.com:port" to work from local network instead of using 192.168.x.x

Thu Aug 23, 2018 5:16 pm

When you are not sending different port numbers to different servers it could be better to put a static
entry for somename.myddns.com in the DNS service with the address of the internal server (192.168.x.x)
so that internal clients asking for somename.myddns.com get directly connected to the server without NAT.

Of course this only works when everyone on the local network uses the MikroTik's DNS.
In a slightly larger network (e.g. business) you would handle this on your local DNS server (split DNS).
 
trebew
just joined
Topic Author
Posts: 4
Joined: Thu May 31, 2018 6:13 am

Re: How to get a request like "sometime.myddns.com:port" to work from local network instead of using 192.168.x.x

Thu Aug 23, 2018 5:38 pm

Look into Hairpin NAT: https://wiki.mikrotik.com/wiki/Hairpin_NAT

Generic example (check and correct subnets for your own network):
/ip firewall nat
add chain=srcnat src-address=192.168.88.0/24 \
  dst-address=192.168.88.0/24 \
  out-interface-list=LAN action=masquerade
It will translate the connections from local addresses to local addresses as if the connections were coming from the router itself.
Thanks, I think that is what I need. I'll test and reply back here.

When you are not sending different port numbers to different servers it could be better to put a static
entry for somename.myddns.com in the DNS service with the address of the internal server (192.168.x.x)
so that internal clients asking for somename.myddns.com get directly connected to the server without NAT.

Of course this only works when everyone on the local network uses the MikroTik's DNS.
In a slightly larger network (e.g. business) you would handle this on your local DNS server (split DNS).
As I understand this works if I need to redirect to a specific IP address right... but I need it to pass through the other NAT rules (using port numbers to reach different local IPs), so I think the solution nescafe2002 presented fits better for me.
 
User avatar
Steveocee
Forum Guru
Forum Guru
Posts: 1199
Joined: Tue Jul 21, 2015 10:09 pm
Location: UK
Contact:

Re: How to get a request like "sometime.myddns.com:port" to work from local network instead of using 192.168.x.x

Thu Aug 23, 2018 6:52 pm

Hairpin NAT is what you need. Have a look at my video which shows you how to do this;
https://www.youtube.com/watch?v=_kw_bQyX-3U
 
trebew
just joined
Topic Author
Posts: 4
Joined: Thu May 31, 2018 6:13 am

Re: How to get a request like "sometime.myddns.com:port" to work from local network instead of using 192.168.x.x

Thu Aug 23, 2018 8:42 pm

Thanks all for helping me, it worked just fine with Hairpin Nat indeed!