# SOLVED DNS resolving local network nodes as public WAN IP

## GoofballJM1

Weird issue.  I set up DNS/DHCP on my local network on my gentoo machine using dnsmasq.  Both my windows machines pulled IP's and DNS information successfully and can ping each other using their FQDN.  However, the DNS/DHCP server when it resolves the windows machines on the network, it's resolving my network's public IP address acquired from my ISP.  Here's my /etc/hosts file:

```

127.0.0.1       localhost.localdomain localhost

192.168.0.101   mydomain.dyndns.org linux.mydomain.dyndns.org linux.mydomain linux 

```

I'm not entering the other nodes in here because they are pulling dynamic IP addresses (obviously).

Here's my /etc/dnsmasq.conf

```

server=/localnet/192.168.0.1

local=/mydomain.dyndns.org/192.168.0.101

interface=eth0

domain=mydomain.dyndns.org

dhcp-range=192.168.0.10,192.168.0.100,255.255.255.0,72h

dhcp-option=3,192.168.0.1

dhcp-host=desktop,192.168.0.10,infinite

dhcp-host=laptop,192.168.0.11,infinite

```

EDIT

It doesn't matter what the host name is, even if I make it up.  If it can't resolve the hosts, it gives a ping reply from the WAN interface on my router.

----------

## VinzC

Check your /etc/resolv.conf and what those nameserver clauses points to.

----------

## VinzC

Sorry, I didn't catch your message immediately.

Your windows machines are trying to send dynamic DNS updates to some server that thinks they all belong to your ISP. To give an accurate response I need tho know what you get when you type ipconfig /all on your windows boxes. Especially pay attention to the DNS settings that should be sent using the DHCP in dnsmasq.

Windows machines default to dynamically updating the DNS server that they receive through DHCP options with their IP address. I am not sure whether dnsmasq supports dynamic updates from windows machines. Anyway what happens is that there seems to be some kind of dynamic update - since there is an IP address that is associated with the machine names - but all names resolve to your public IP.

I personally use DHCP+BIND instead since both support dynamic DNS updates. But I set them up so that only the DHCP is allowed to update the DNS server. It works like a charm.

Also give an example of a ping with some names from at least one of your windows machines and the Gentoo box holding dnsmasq.

----------

## GoofballJM1

Sorry for the delayed reply, I've been super busy.  Here's the client output on the windows machines:

```
Windows IP Configuration

        Host Name . . . . . . . . . . . . : jorgeburrito

        Primary Dns Suffix  . . . . . . . :

        Node Type . . . . . . . . . . . . : Hybrid

        IP Routing Enabled. . . . . . . . : No

        WINS Proxy Enabled. . . . . . . . : No

        DNS Suffix Search List. . . . . . : mydomain.dyndns.org

Ethernet adapter Local Area Connection:

        Media State . . . . . . . . . . . : Media disconnected

        Description . . . . . . . . . . . : Intel(R) PRO/100 VE Network Connecti

on

        Physical Address. . . . . . . . . : 08-00-46-28-C2-CD

Ethernet adapter Wireless Network Connection:

        Connection-specific DNS Suffix  . : mydomain.dyndns.org

        Description . . . . . . . . . . . : IEEE 802.11g Wireless Cardbus/PCI Ad

apter

        Physical Address. . . . . . . . . : 00-18-E7-0A-2B-38

        Dhcp Enabled. . . . . . . . . . . : Yes

        Autoconfiguration Enabled . . . . : Yes

        IP Address. . . . . . . . . . . . : 192.168.0.11

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.0.1

        DHCP Server . . . . . . . . . . . : 192.168.0.101

        DNS Servers . . . . . . . . . . . : 192.168.0.101

        Lease Obtained. . . . . . . . . . : Sunday, August 19, 2007 8:53:26 PM

        Lease Expires . . . . . . . . . . : Monday, January 18, 2038 9:14:07 PM
```

I think you're right about the resolution issue.  The /etc/resolv.conf has the DNS servers given to me by my ISP.  Here's the ping output of my windows machine:

```
Microsoft Windows XP [Version 5.1.2600]

(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jon-Michael>ping heather

Pinging heather.mydomain.dyndns.org [192.168.0.10] with 32 bytes of data:

Reply from 192.168.0.10: bytes=32 time=5ms TTL=128

Reply from 192.168.0.10: bytes=32 time=4ms TTL=128

Reply from 192.168.0.10: bytes=32 time=2ms TTL=128

Reply from 192.168.0.10: bytes=32 time=2ms TTL=128

Ping statistics for 192.168.0.10:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 2ms, Maximum = 5ms, Average = 3ms
```

And from the Gentoo machine running dnsmasq

```
ping heather

PING mydomain.dyndns.org (71.218.214.29) 56(84) bytes of data.

64 bytes from heather.mydomain.dyndns.org (x.x.x.x): icmp_seq=1 ttl=255 time=1.21 ms

64 bytes from heather.mydomain.dyndns.org (x.x.x.x): icmp_seq=2 ttl=255 time=0.713 ms

64 bytes from heather.mydomain.dyndns.org (x.x.x.x): icmp_seq=3 ttl=255 time=0.729 ms

64 bytes from heather.mydomain.dyndns.org (x.x.x.x): icmp_seq=4 ttl=255 time=0.718 ms

64 bytes from heather.mydomain.dyndns.org (x.x.x.x): icmp_seq=5 ttl=255 time=0.721 ms

--- mydomain.dyndns.org ping statistics ---

5 packets transmitted, 5 received, 0% packet loss, time 4000ms

rtt min/avg/max/mdev = 0.713/0.819/1.217/0.201 ms
```

x.x.x.x is my public ip.

----------

## VinzC

 *GoofballJM1 wrote:*   

> Sorry for the delayed reply, I've been super busy.

 

No problem, man. Take as much time as needed. What counts most is to fix your issue  :Smile:  .

 *GoofballJM1 wrote:*   

> I think you're right about the resolution issue.  The /etc/resolv.conf has the DNS servers given to me by my ISP. 
> 
> [...]

 

Then the fix is simple: don't allow dhcp to update your resolv.conf and add the IP address of your local dnsmasq on the first line. Better, keep only the IP of the interface on which dnsmasq listens to and configure dnsmasq to forward DNS requests to your ISP's name servers. (I suppose your machine which runs dnsmasq has two network interfaces and/or one fix IP address, do I?)

If you have more than one network adapter, use your fix IP if you have one. If your machine with the dnsmasq only has dynamic IP addresses, this becomes a little more complex.

----------

## GoofballJM1

 *Quote:*   

> (I suppose your machine which runs dnsmasq has two network interfaces and/or one fix IP address, do I?)

 

The DNS server is behind a router with the rest of the nodes on the network.  There is only one interface on the machine.

I also changed my resolv.conf to point only to the local dnsmasq per your suggestion and added the ISP dns to dnsmasq.conf.  The windows machines work correctly except when they can't resolve the IP.  If they can't resolve an ip, the ip for the dns server is given instead.

----------

## VinzC

 *Quote:*   

> (I suppose your machine which runs dnsmasq has two network interfaces and/or one fix IP address, do I?)

 

 *GoofballJM1 wrote:*   

> The DNS server is behind a router with the rest of the nodes on the network.  There is only one interface on the machine.

 

Ok, so I suppose your server has a fix IP. The trick I gave you about inserting its own IP address in resolv.conf should be enough.

As a side note: you shouldn't use your public domain name with the local area network. Instead you should use a local domain name, e.g. mydomain.local. It has the adverse effect of masking everything in mydomain.dyndns.org unless you create a zone with the same name as the public name (i.e. mydomain.dyndns.org) but with internal IP addresses.

----------

## GoofballJM1

Okay, followed your great advice, here's what I did.

I changed the domain to an internal name (mydomain.local)

Put the ISP DNS servers in the /etc/dnsmasq.conf file like so:

```
server=/localnet/205.171.3.65

server=/localnet/205.171.2.65
```

And I then added the local DNS server to /etc/resolv.conf

Now, the automatic resolution of IP's to the WAN has disappeared, but it doesn't ping the other hosts on the network unless I manually add them to my /etc/hosts file.

Also, my DNS/DHCP server is running a static IP.

----------

## VinzC

You can have dnsmasq use the DHCP leases to resolve address names. Add "-l" to dnsmasq start options as explained in Gentoo Wiki for dnsmasq.

----------

## GoofballJM1

Thanks for your help and patience.  It's working great!  That did the trick.  I overlooked that option.

----------

## VinzC

Glad to help  :Smile:  .

----------

