# Ping windows boxes by name

## i92guboj

Hello, I am having some problem with this, I'll admit. 

To simplify. this is the scenario: gentoo box and win7 box. Gentoo box is dhcp and dns server, via dnsmasq.

From win7, I can ping gentoo by both ip and name. No problem there.

From Gentoo, I can ping win7 by ip, but not by name. The dnsmasq log seems to receive the name ok, it's "Tere-PC". I have been looking around for many hours now and I know there must be something simple I am not taking into account.

```
dnsmasq-dhcp: 55480937 available DHCP range: 192.168.0.50 -- 192.168.0.150

dnsmasq-dhcp: 55480937 client provides name: Tere-PC

dnsmasq-dhcp: 55480937 vendor class: MSFT 5.0

dnsmasq-dhcp: 55480937 DHCPREQUEST(eth0) 192.168.0.2 00:14:85:18:59:d2 

dnsmasq-dhcp: 55480937 DHCPACK(eth0) 192.168.0.2 00:14:85:18:59:d2 Tere-PC

dnsmasq-dhcp: 55480937 requested options: 1:netmask, 15:domain-name, 3:router, 6:dns-server, 

dnsmasq-dhcp: 55480937 requested options: 44:netbios-ns, 46:netbios-nodetype, 47:netbios-scope, 

dnsmasq-dhcp: 55480937 requested options: 31:router-discovery, 33:static-route, 121:classless-static-route, 

dnsmasq-dhcp: 55480937 requested options: 249, 43:vendor-encap

dnsmasq-dhcp: 55480937 etiquetas: known, eth0

dnsmasq-dhcp: 55480937 next server: 192.168.0.1

dnsmasq-dhcp: 55480937 sent size:  1 option: 53:message-type  05

dnsmasq-dhcp: 55480937 sent size:  4 option: 54:server-identifier  192.168.0.1

dnsmasq-dhcp: 55480937 sent size:  4 option: 51:lease-time  00:00:a8:c0

dnsmasq-dhcp: 55480937 sent size:  4 option: 58:T1  00:00:4d:26

dnsmasq-dhcp: 55480937 sent size:  4 option: 59:T2  00:00:8c:6e

dnsmasq-dhcp: 55480937 sent size:  4 option:  1:netmask  255.255.255.0

dnsmasq-dhcp: 55480937 sent size:  4 option: 28:broadcast  192.168.0.255

dnsmasq-dhcp: 55480937 sent size:  4 option:  3:router  192.168.0.1

dnsmasq-dhcp: 55480937 sent size:  4 option:  6:dns-server  192.168.0.1

dnsmasq-dhcp: 55480937 sent size: 10 option: 81:FQDN  03:ff:ff:54:65:72:65:2d:50:43
```

```
# ping Tere-PC

ping: unknown host Tere-PC
```

Is there any way that dnsmasq, which is supposedly a dns server, will link this name to the given ip?

Thanks for reading and for any idea  :Smile: 

----------

## cach0rr0

possible the windows host disallows netbios over TCP instead of plain ole netbios, where the linux one does not? 

no issues doing so here, BUT, i have dnsmasq in dd-wrt sending out a domain suffix, and my clients doing the same, so pinging 'brutus' ends up being 'brutus.domain.com', and even though there's no DNS record for it, it just magically works

*shrug*

i think that's true, unfortunately i dont remember if i had to set up samba to do this or not

----------

## cach0rr0

ah right, here we go. man im getting rusty on windows crap, it's been ages:

http://www.linuxquestions.org/questions/linux-networking-3/ping-netbios-names-from-linux-samba-271336/

summary:

/etc/nsswitch.conf

default has:

```

hosts:       files dns

```

supposedly can change to:

```

hosts:       files dns wins

```

caveat: i still don't know if adding wins requires samba or not.

EDIT: I'm betting it does. A guess, but a semi-educated guess. Am reading `man nsswitch.conf` at the moment, and see this:

```

FILES

       A service named SERVICE is implemented by a shared object library named libnss_SERVICE.so.X that resides in /lib.

       /etc/nsswitch.conf       configuration file

       /lib/libnss_compat.so.X  implements `compat' source for glibc2

       /lib/libnss_db.so.X      implements `db' source for glibc2

       /lib/libnss_dns.so.X     implements `dns' source for glibc2

       /lib/libnss_files.so.X   implements `files' source for glibc2

       /lib/libnss_hesiod.so.X  implements `hesiod' source for glibc2

       /lib/libnss_nis.so.X     implements `nis' source for glibc2

       /lib/libnss_nisplus.so.2 implements `nisplus' source for glibc 2.

```

i don't see anything in there talking about wins =/

i suppose i can emerge samba and see

/me emerges samba while editing this. jesus the configure portion takes forever - hurry up and compile shit so i can go to bed!

While I'm doing so, I'm also reading this from a dnsmasq FAQ

 *Quote:*   

> 
> 
> Testing lookups
> 
>    using "nslookup" or "dig" will work, but then attempting to run
> ...

 

I could swear having to emerge samba for this is overkill.

...and you know, as much as my answers are going all over the place, it's starting to look like you and I are both lost

----------

## Suicidal

What happens with:

```
ping tere-pc.yourdomain.tld
```

```
nslookup tere-pc.yourdomain.tld
```

----------

## magic919

This works from my Gentoo server with dnsmasq.  I run a caching DNS server locally and bind that to 127.0.0.1.  I bind the dnsmasq (listen address) to (your equiv) 192.168.0.100 which is the IP of the Gentoo server.  Making sure that /etc/resolv.conf shows 192.168.0.100 it works when I ping windozeboxen.

----------

## i92guboj

Ok, some success (I think). nslookup showed me that it was attempting to resolve the dns query using the external server from my ISP.

```
$ nslookup tere-pc.homenetwork

Server:         78.136.66.5

Address:        78.136.66.5#53

** server can't find tere-pc.homenetwork: NXDOMAIN

```

So, I looked into resolv.conf. The local server was not listed in /etc/resolv.conf, so, if I edit it this way and add it:

```
# Generated by dhclient for interface eth1

nameserver 192.168.0.1

nameserver 78.136.66.5

nameserver 78.136.66.6
```

Then ping works. However, that file is created via my dhcp client (also dnsmasq) every time I reboot, and editing it by hand is not an option. Now, at least, I know where to look. Suggestions are welcome, of course. You already helped me a lot. Thanks to everyone in the thread  :Smile: 

----------

## magic919

Your DHCP client is dhclient.  Dnsmasq is your DHCP server.

Use the 'nodns' option as part of your network set-up to avoid dhclient overwriting.

----------

## i92guboj

 *magic919 wrote:*   

> Your DHCP client is dhclient.  Dnsmasq is your DHCP server.
> 
> Use the 'nodns' option as part of your network set-up to avoid dhclient overwriting.

 

You are right, however there should be a way to tell dnsmasq that local dns queries should first go to 127.0.0.1. I am trying to do so using the local and server keywords in /etc/dnsmasq.conf, but dnsmasq seems to be ignoring that completely. When I run dnsmasq in debug mode it spits out this:

```
# LC_ALL=C dnsmasq -d

dnsmasq: started, version 2.57 cachesize 150

dnsmasq: compile time options: IPv6 GNU-getopt DBus I18N DHCP no-TFTP IDN

dnsmasq-dhcp: DHCP, IP range 192.168.0.50 -- 192.168.0.150, lease time 12h

dnsmasq: ignoring nameserver 127.0.0.1 - local interface

dnsmasq: reading /etc/resolv.conf

dnsmasq: using nameserver 78.136.66.6#53

dnsmasq: using nameserver 78.136.66.5#53

dnsmasq: read /etc/hosts - 2 addresses
```

Using server or local makes no difference.

----------

## magic919

I see what you are saying.

Here's mine -

```

dnsmasq: started, version 2.52 cachesize 150

dnsmasq: compile time options: no-IPv6 GNU-getopt no-DBus I18N DHCP no-TFTP

dnsmasq-dhcp: DHCP, IP range 172.16.32.100 -- 172.16.32.110, lease time 12h

dnsmasq-dhcp: DHCP, IP range 172.16.32.10 -- 172.16.32.99, lease time 12h

dnsmasq: using local addresses only for domain internal

dnsmasq: reading /etc/nameservers

dnsmasq: using nameserver 127.0.0.1#53

dnsmasq: using local addresses only for domain internal

dnsmasq: read /etc/hosts - 9 addresses

```

Try my method of using /etc/nameservers

----------

## i92guboj

 *magic919 wrote:*   

> Try my method of using /etc/nameservers

 

I'll admit that networking in linux has always been one of the things I didn't like. They always manage to get me on  my nerves. I have no idea why it has to be so complicated.

I've tried many things and it doesn't seem to work so well. The closest I've gone is as follows:

/etc/dnsmasq.conf

```
listen-address=127.0.0.1
```

/etc/conf.d/net

```
dhcp_eth1="nodns"

dns_servers="127.0.0.1 78.136.66.5 78.136.66.6"
```

In this case, local lookups succeed after restarting net.eth1 and dnsmasq, and resolv.conf shows the three nameservers. The problem is that then non-local lookups take forever and then fail, that of my network is just making a fool out of me.

I'll keep trying, there's no other choice.

----------

## magic919

Sounds like progress.

I don't bind dnsmasq to localhost, as it stops the rest of my LAN getting to it.  I bind to the machine's IP.

Second, I run djbdns on the Gentoo server to provide DNS to dnsmasq.  I bind djbdns to localhost.

----------

## i92guboj

I don't want to put one more layer into this. It's a simple setup with two machines, it should just work with little effort, otherwise I wouldn't be using dnsmasq which is an all-rounder good-at-nothing (I'd just use bind + some random dhcp daemon, which is a typical setup).

This is what I finally did:

```
# cat /etc/dnsmasq.conf 

interface=eth0

dhcp-range=192.168.0.100,192.168.0.105,255.255.255.0,12h

dhcp-host=xx:xx:xx:xx:xx:xx,192.168.0.100

# cat /etc/conf.d/net

config_eth0="192.168.0.1/24"

config_eth1="dhcp"

dhcp_eth1="nodns"

[jesgue] root@jesgue:/etc

[jesgue] 15:10:38 # cat /etc/resolv.conf 

# Generated by dhclient for interface eth1

nameserver 192.168.0.1

nameserver xx.xxx.xx.xxx

nameserver xx.xxx.xx.xxx

```

This seems to work. Now, I am ready to go into the next step, which is configuring the remote printer.

Thanks everyone in the thread for helping me.  :Wink: 

----------

