Community discussions

MikroTik App
 
freeman7162
just joined
Topic Author
Posts: 6
Joined: Thu Nov 20, 2014 1:14 am

Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 12:13 pm

Hello!
I have a web server on 192.168.0.2. From internet i can access it by its dns name mysite.com . What should i do to get access in local network by dns name mysite.com instead of typing http://192.168.0.2
 
Experimentator
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Sat Nov 24, 2012 9:12 pm

Re: Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 1:12 pm

You need to add a so-called "hairpin NAT" rule.
Here's a good description: http://wiki.mikrotik.com/wiki/Hairpin_NAT
 
freeman7162
just joined
Topic Author
Posts: 6
Joined: Thu Nov 20, 2014 1:14 am

Re: Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 1:19 pm

what exactly rule for nat i need to add?
 
freeman7162
just joined
Topic Author
Posts: 6
Joined: Thu Nov 20, 2014 1:14 am

Re: Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 1:19 pm

What exactly rule for NAT i need to add?
 
Experimentator
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Sat Nov 24, 2012 9:12 pm

Re: Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 1:58 pm

Should be something like this:
/ip firewall nat
add chain=srcnat src-address=192.168.0.0/24 dst-address=192.168.0.2 protocol=tcp dst-port=80 action=masquerade
 
freeman7162
just joined
Topic Author
Posts: 6
Joined: Thu Nov 20, 2014 1:14 am

Re: Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 2:09 pm

Should be something like this:
/ip firewall nat
add chain=srcnat src-address=192.168.0.0/24 dst-address=192.168.0.2 protocol=tcp dst-port=80 action=masquerade
it doesnot working!
 
Experimentator
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Sat Nov 24, 2012 9:12 pm

Re: Access to local web server by its dns name instead of ip

Thu Nov 20, 2014 4:43 pm

Well, I'm not an expert, but similar settings work for me just fine.

You have your server running on 192.168.0.2, right? What port your web server is running on? How do you connect to it from outside - is it just the domain.name or domain.name:port ?

Can I see your current NAT configuration?
 
freeman7162
just joined
Topic Author
Posts: 6
Joined: Thu Nov 20, 2014 1:14 am

Re: Access to local web server by its dns name instead of ip

Fri Nov 21, 2014 8:58 pm

thanks to all, problem solved by myself with this NAT rules
http://project.eraps.ru/knowledgebase/articles/13