Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: tinusje on March 26, 2012, 10:50:49 PM

Title: SOLVED: Hostname resolves to external IP rather than internal IP
Post by: tinusje on March 26, 2012, 10:50:49 PM
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.
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: CharlieBrady 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.
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: tinusje 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.
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: Stefano on March 27, 2012, 09:54:20 AM
configure your SME to be the dhcp server
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: tinusje 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.
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: Stefano 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
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: tinusje on March 27, 2012, 10:57:36 AM
I'll give it a try, and let you know what the results are.
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: p-jones 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)
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: tinusje on March 27, 2012, 11:59:02 AM
Thanks p-jones,

I'll investigate this later today.

Regards,
Martijn
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: elmarconi 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.

Title: Re: Hostname resolves to external IP rather than internal IP
Post by: tinusje 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
Title: Re: Hostname resolves to external IP rather than internal IP
Post by: CharlieBrady 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.
Title: Re: SOLVED: Hostname resolves to external IP rather than internal IP
Post by: tinusje 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.
Title: Re: SOLVED: Hostname resolves to external IP rather than internal IP
Post by: CharlieBrady 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.
Title: Re: SOLVED: Hostname resolves to external IP rather than internal IP
Post by: tinusje 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.