Community discussions

MikroTik App
 
yaylitzis
just joined
Topic Author
Posts: 15
Joined: Fri Jan 11, 2019 8:58 am

Resolve domain name with local DNS

Sun Jun 27, 2021 9:28 pm

In my local network, I have an Ubuntu server which host a web application. In my local network, this web application is accessible from 192.168.0.100 . What I am trying to do is to connect this web application with a domain name. What I have done till now:

  • I added an `A` record to the domain name pointing my public IP (I have static public IP)
  • In Mikrotik, I opened the ports 80, 443 (in IP/Firewall/Nat)
  • In Ubuntu server, I added a virtual host for my domain and installed Let's Encrypt certificate

And all works fine! The https : //mydomain.com shows my web application. The only problem is that this configuration I have done, is working only outside local network. When I am connected in the local network, mydomain.com can't be resolved successfully. I tried and I added a static DNS entry in IP/DNS/ :
  • Name: mydomain.com
  • Address: 192.168.0.100

But the problem wasn't resolved. The only solution I found is to add a record in hosts file in my Windows PC, but I would like to avoid this solution.

Can I configure somehow the Mikrotik, to add a rule (??) for this specific domain? Thanks!
 
Zacharias
Forum Guru
Forum Guru
Posts: 3459
Joined: Tue Dec 12, 2017 12:58 am
Location: Greece

Re: Resolve domain name with local DNS

Sun Jun 27, 2021 9:41 pm

 
aesmith
Member Candidate
Member Candidate
Posts: 264
Joined: Wed Mar 27, 2019 6:43 pm

Re: Resolve domain name with local DNS

Mon Jun 28, 2021 7:01 pm

I'm sure this is possible with DNS and without hairpin NAT. At work we have some hosts that are resolved from our internal DNS server to their internal IP addresses, whereas on the Internet they resolve to their external (NAT) address.

Is your Mikrotik configured as a DNS server, and used as primary resolver by your internal devices?
 
User avatar
xvo
Forum Guru
Forum Guru
Posts: 1237
Joined: Sat Mar 03, 2018 1:12 am
Location: Moscow, Russia

Re: Resolve domain name with local DNS

Mon Jun 28, 2021 7:06 pm

I tried and I added a static DNS entry in IP/DNS/ :
  • Name: mydomain.com
  • Address: 192.168.0.100

But the problem wasn't resolved.
That means your PC doesn't use your mikrotik as DNS server.
 
Zacharias
Forum Guru
Forum Guru
Posts: 3459
Joined: Tue Dec 12, 2017 12:58 am
Location: Greece

Re: Resolve domain name with local DNS

Mon Jun 28, 2021 9:03 pm

Using a static DNS entry with Mikrotik as DNS server would work as well...
However reading about Hairping NAT will help you understand why it doesn't work right now...
 
yaylitzis
just joined
Topic Author
Posts: 15
Joined: Fri Jan 11, 2019 8:58 am

Re: Resolve domain name with local DNS

Tue Jun 29, 2021 11:38 am

Thanks for your replies! In IP/DNS, I have :

DNS Mikrotik.jpg

How can I set Mikrotik as DNS resolver? Also, should I set mikrotik as DNS resolver ? :)

Also, I tried to implement Haripin Nat (very nice article, I knew something more today :) :) ) In the article says that I should execute

/ip firewall nat
add action=masquerade chain=srcnat dst-address=192.168.0.100 out-interface=LAN protocol=tcp src-address=192.168.0.0/24

however, the parameter out-interface=LAN what does it mean, because in my case I don't have such interface. I that option I have:

Mikrotik-outinterfaces.jpg
You do not have the required permissions to view the files attached to this post.
 
aesmith
Member Candidate
Member Candidate
Posts: 264
Joined: Wed Mar 27, 2019 6:43 pm

Re: Resolve domain name with local DNS

Wed Jun 30, 2021 6:37 pm

How can I set Mikrotik as DNS resolver? Also, should I set mikrotik as DNS resolver ? :)
Whether or not your devices use the Mikrotik as their DNS server depends on how they're configured. Easiest way to configured this is normally to configure your DHCP server to give out your preferred DNS server. If you're using your Mikrotik as DHCP server as well, then this is configured in Winbox under IP / DHCP Server / Network. Set DNS Server to be the IP address of the Mikrotik

And your second question, yes it's a good idea at least in my opinion. Apart from being able to configure local names like we're discussing here there is also the benefit that the Mikrotik caches the names it resolves, so regularly used names don't need to be looked up from the Internet.
 
Zacharias
Forum Guru
Forum Guru
Posts: 3459
Joined: Tue Dec 12, 2017 12:58 am
Location: Greece

Re: Resolve domain name with local DNS

Wed Jun 30, 2021 7:44 pm

however, the parameter out-interface=LAN what does it mean, because in my case I don't have such interface. I that option I have:
It means that the out interface is your Lan Network...
Masquerade is a unique subversion of action=srcnat, https://wiki.mikrotik.com/wiki/Manual:I ... Masquerade
src-nat happens at the postrouting Chain, so it applies to packets as they leave the network interface, thats why we use out-interface=LAN, so that we masquerade the packets leaving the Lan interface, meaning they will leave with the LANs interface IP address...

So when you try to reach your Server, the Server will actually see the LANs Interface IP address and not the Clients IP...
 
gianmikro
just joined
Posts: 3
Joined: Mon Jan 18, 2021 6:14 pm

Re: Resolve domain name with local DNS

Sat Dec 10, 2022 1:15 am

I'm resurrecting this discussion because I have a similar problem... I have to access my domain with public ip from inside my lan, ngenix redirects https calls to my server: 10.0.0.100

From the outside everything works fine, from inside my network it doesn't :(

Any suggestions?
You do not have the required permissions to view the files attached to this post.
 
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19107
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Resolve domain name with local DNS

Sat Dec 10, 2022 2:19 am

Who is online

Users browsing this forum: Ahrefs [Bot], CGGXANNX, Google [Bot] and 56 guests