Koozali.org: home of the SME Server

SOLVED: Hostname resolves to external IP rather than internal IP

Offline tinusje

  • *
  • 8
  • +0/-0
Hi there,

I want to access my SME mail on my mobile device. This device tries to establish a WIFI connection when I'm at home, otherwise it will have a 3G connection.
My problem is this: when I'm on 3G, www.mydomainname.nl resolves to my global IP address, which is good.
However, when I'm on WIFI, I want www.mydomainname.nl to resolve to my local IP address, in my case 172.19.x.y.
I tried to modify etc/hosts ,this doesn't work. On top of that, any changes to this file will be overwritten at restart, as is clearly stated in this file.

Can someone point me in the right direction?

Thanks in advance,
Martijn.
« Last Edit: March 27, 2012, 10:17:41 PM by tinusje »

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #1 on: March 26, 2012, 11:15:25 PM »
My problem is this: when I'm on 3G, www.mydomainname.nl resolves to my global IP address, which is good.
However, when I'm on WIFI, I want www.mydomainname.nl to resolve to my local IP address, in my case 172.19.x.y.

This should "just happen", if you are using your SME server as the DHCP server on your LAN. Alternatively, if the DHCP server on your wireless router is enabled, make sure that your SME server is listed as the only DNS server in your router's configuration.

Offline tinusje

  • *
  • 8
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #2 on: March 27, 2012, 09:00:09 AM »
Thanks for your response Charlie,

My SME server isn't the DHCP server, my router takes care of that.
On a windows machine a ipconfig /all shows that my SME is actually the only DNS server, so I guess my router has been configured correctly.
I'll look into the router settings once more to make sure that there's no error.

The strange thing is: when I open a terminal on SME and type PING www.mydomainname.nl my internal IP shows up.
When I do the same thing on any device on my network, my external IP shows up.

Martijn.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #3 on: March 27, 2012, 09:54:20 AM »
configure your SME to be the dhcp server

Offline tinusje

  • *
  • 8
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #4 on: March 27, 2012, 10:41:16 AM »
I'm sorry, can't do that.
There are about 8 devices connected to my network, I want them to remain connected to the internet whenever my server is down.
It shouldn't make a difference anyway. SME is the only DNS.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #5 on: March 27, 2012, 10:54:15 AM »
It shouldn't make a difference anyway. SME is the only DNS.

well, it doesn't seem so..
configure your router to use SME as dns server

Offline tinusje

  • *
  • 8
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #6 on: March 27, 2012, 10:57:36 AM »
I'll give it a try, and let you know what the results are.

Offline p-jones

  • *
  • 594
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #7 on: March 27, 2012, 11:41:43 AM »
Quote
There are about 8 devices connected to my network, I want them to remain connected to the internet whenever my server is down.

How do these devices resolve DNS queries when your SME is down ?

(I suspect when you find the answer to this you will also find the answer to your primary problem)
...

Offline tinusje

  • *
  • 8
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #8 on: March 27, 2012, 11:59:02 AM »
Thanks p-jones,

I'll investigate this later today.

Regards,
Martijn

Offline elmarconi

  • ****
  • 139
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #9 on: March 27, 2012, 07:35:56 PM »
If you have a DD-WRT router you could use DNSMasq options.
http://www.dd-wrt.com/wiki/index.php/DNSMasq_-_DNS_for_your_local_network_-_HOWTO#2.29_Additional_DNS_Options

address=/www.mydomainname.nl/172.19.x.y.

I've added an dyndns adress for those smartphones to resolve to my mailserver, internally to 192.168.x.y, externally to the public IP.

...

Offline tinusje

  • *
  • 8
  • +0/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #10 on: March 27, 2012, 10:16:46 PM »
Solved!

I edited some settings in my router, now my SME is the first entry in DNS settings.
After refreshing my network connection and flushing local DNS cache my domain name now points to my internal IP when I'm on WIFI.
Thanks all of you for any suggestions!

Regards,
Martijn

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Hostname resolves to external IP rather than internal IP
« Reply #11 on: March 28, 2012, 03:46:53 PM »
I edited some settings in my router, now my SME is the first entry in DNS settings.

You will get unreliable results unless you set it as the only entry.

Offline tinusje

  • *
  • 8
  • +0/-0
Re: SOLVED: Hostname resolves to external IP rather than internal IP
« Reply #12 on: March 28, 2012, 04:18:22 PM »
Thanks Charlie,

The only reason for me to have multiple DNS entries is that whenever SME is down, the other DNS will take over.
Isn't this how primary and secundary DNS's are supposed to work?
Why will setting a secundary non-SME DNS give me unreliable result?

Regards,
Martijn.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: SOLVED: Hostname resolves to external IP rather than internal IP
« Reply #13 on: March 28, 2012, 04:43:31 PM »
Isn't this how primary and secundary DNS's are supposed to work?

In general, no. "primary" and "secondary" doesn't usually apply - resolvers usually just choose one at random from the list available. But it depends on the operating system and the resolver code used by particular programs.

Offline tinusje

  • *
  • 8
  • +0/-0
Re: SOLVED: Hostname resolves to external IP rather than internal IP
« Reply #14 on: March 28, 2012, 09:51:14 PM »
Ok, thanks.
I'll remove the second DNS entry whenever I run into problems resolving my domain name.