# Weird (wins?) name resolution issue



## outofideas (Dec 30, 2010)

I've recently set up a FreeBSD 8.1 machine to take advantage of ZFS.  Most everything is working great.  But...

I cannot access services on other machines on my network by hostname, which nominally need to be resolved via wins.  The really weird part is that I can ping them by hostname.

Pinging:

```
# ping control
PING control (192.168.1.55): 56 data bytes
64 bytes from 192.168.1.55: icmp_seq=0 ttl=64 time=1.780 ms
64 bytes from 192.168.1.55: icmp_seq=1 ttl=64 time=0.771 ms
```

But if I try to use the hostname in another way, I get errors.

Remote X:

```
# DISPLAY="control:0" gkrellm
(gkrellm:37205): Gtk-WARNING **: cannot open display: control:0
```

rsync:

```
# rsync -l rsync://ironfe56@control/home6
rsync: getaddrinfo: control 873: hostname nor servname provided, or not known
rsync error: error in socket IO (code 10) at clientserver.c(122) [Receiver=3.0.7]
```

Both of the above commands work if I provide the IP instead of the hostname.

I setup winbindd along with samba, and added wins to the hosts: line in /etc/nsswitch.conf.  Doing so made the ability to ping hosts by name start working.

I've tried disabling IPv6 (*ipv6_enable="NO"* in /etc/rc.conf), and I've tried switching from DHCP to a static address, with no change in symptoms.

I'm sure I'm missing something simple, but being new to FreeBSD I have been unable to find it.  Thanks.


----------



## SirDice (Dec 30, 2010)

outofideas said:
			
		

> I cannot access services on other machines on my network by hostname, which nominally need to be resolved via wins.  The really weird part is that I can ping them by hostname.


No, this is not weird. WINS and DNS are completely different. Ping uses DNS, not WINS. WINS is only used on Windows networks.

Note the differences:
http://en.wikipedia.org/wiki/Windows_Internet_Name_Service
http://en.wikipedia.org/wiki/Domain_Name_System


----------



## outofideas (Dec 30, 2010)

SirDice said:
			
		

> No, this is not weird. WINS and DNS are completely different. Ping uses DNS, not WINS. WINS is only used on Windows networks.



Hostnames on my network are only resolvable via wins.

A concrete demonstration that ping is successfully using wins:

If I change the hosts line, in/etc/nsswitch.conf to read:

```
hosts: files dns
```
I see:

```
# ping zebec
ping: cannot resolve zebec: Unknown host
```
And, when I change it back to:

```
hosts: files dns wins
```
I see:

```
# ping zebec
PING zebec (192.168.1.10): 56 data bytes
64 bytes from 192.168.1.10: icmp_seq=0 ttl=64 time=0.250 ms
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.118 ms
```

I tested a few more commands:
Unable to resolve via wins through nsswitch.conf:
ssh
ftp
iperf

Able:
traceroute

I also found entries in debug.log, that occur whenever resolution fails, they look like:

```
Dec 30 04:43:15 xebec ssh: NSSWITCH(_nsdispatch): wins, hosts, getaddrinfo, not found, and no fallback provided
```

If I add a nonexistent resolver to nsswitch.conf, say "flkdjgh", then I see 2 errors in debug.log:

```
Dec 30 04:52:47 xebec ssh: NSSWITCH(_nsdispatch): wins, hosts, getaddrinfo, not found, and no fallback provided
Dec 30 04:52:47 xebec ssh: NSSWITCH(_nsdispatch): flkdjgh, hosts, getaddrinfo, not found, and no fallback provided
```

So for some reason, the programs ping and traceroute, can make use of wins resolution through nsswitch.conf, but most/all others can not.

Is there a way to fix this?  Is there another mechanism besides nsswitch.conf for adding "wins" name resolution to FreeBSD?


----------



## SirDice (Dec 30, 2010)

You shouldn't rely on WINS. It's a horrible protocol that uses a flat namespace. Set up DNS correctly, that'll even benefit your Windows clients/servers.


----------

