# Ping windows machines by name

## d4mo

So I've tried to look online and can't find a staightforward answer.  Is it NetBIOS that does it?  If I understand correctly NetBIOS is a part of CIFS?  Or is that incorrect?

Also if it is NetBIOS that does it, is there anyything I can install to get just the Naming support.  I don't want to install samba just for that.

----------

## Hu

As far as I know, WINS is the reason Windows machines can find hosts that have not been given proper DNS entries.  Once WINS finds the name, the ping is done in the same way as if you entered the IP address explicitly, got the name from DNS, or had it in your /etc/hosts file.  If you are dealing with a small number of statically addressed Windows machines, I would just put their names in /etc/hosts and call it done.  If you have a large site, or if the machines change addresses, you will need to get a WINS resolver.  I think net-fs/samba has such a resolver, but I do not use it.  See man winbindd (yes, two Ds) for details.  I think that you could run just winbindd without also providing full CIFS server, but I have never tried that, either.

----------

## John R. Graham

I have yet to see a crappy little (i.e., home) router DHCP / DNS service that correctly provides name service for local machines but dnsmasq and bind both do.  My advice would be to install dnsmasq on an appropriate machine and set it up to provide DNS and DHCP for your network.  Of course, you'll have to disable those services in your home router.

- John

----------

## szczerb

 *john_r_graham wrote:*   

> I have yet to see a crappy little (i.e., home) router DHCP / DNS service that correctly provides name service for local machines but dnsmasq and bind both do.

 Any router capable of running openWRT, tomato, DD-WRT can do that. That's almost every linksys WRT, some Asus, some Buffalo, some  of some other companies ;] They are small, home and almost cheap (my Asus WL500gP v1 (with the wifi card on miniPCI and 2 USB 2.0 ports) costs about 70 Euros and those linksys WRTs are usually significantly cheaper).

----------

## John R. Graham

Right you are.  Here's a clarification:  I have yet to see a crappy little (i.e., home) router DHCP / DNS service that out of the box correctly provides name service for local machines.  I still recommend dnsmasq.   :Razz: 

- John

----------

## szczerb

DD-WRT uses dnsmasq and the others also if I remember correctly  :Smile:  So basically it's the way to go ;] Although once I had an ambition to set up local bind and caching and with reading dhcpd leases...

----------

## d4mo

ok that may work(I've been using ddwrt for years).  But it won't work for the Windows PC's to be able to ping the linux box by hostname....right?

----------

## John R. Graham

Yes, it will.  I've good cross-platform naming service in both directions supported by dnsmasq.

- John

----------

## d4mo

So what service is sending the hostname out on the nix boxes to the dnsmasq then?

----------

## John R. Graham

DHCP client.  

- John

----------

## szczerb

And it's not a service ;]

----------

## krinn

echo "windowsIPname1 windowscompname1" >> /etc/hosts

as simple as that, no programs needed. If your windows comp have statics ip of course.

so ping, ssh... windowscompname1 will be resolved to windowsIPname1

and there's also a file in windows that does the same thing for your linux computers. but i don't remember where/what is it, but pretty sure a windows user could point it out easy.

----------

## szczerb

 *krinn wrote:*   

> echo "windowsIPname1 windowscompname1" >> /etc/hosts
> 
> as simple as that, no programs needed. If your windows comp have statics ip of course.
> 
> so ping, ssh... windowscompname1 will be resolved to windowsIPname1
> ...

 Sure...why do we need DNS servers at all   :Laughing: 

----------

## Malvineous

 *krinn wrote:*   

> and there's also a file in windows that does the same thing for your linux computers. but i don't remember where/what is it, but pretty sure a windows user could point it out easy.

 

Now I'm ashamed to admit I know this, but it's %windir%\system32\drivers\etc\hosts and it works the same as the *nix hosts file.

Also the service that handles Windows network names is "nmbd" (part of the Samba package.)  It will allow a Windows machine to map your Samba name (which you probably want to set the same as your hostname) into an IP address.  This will allow Windows PCs to ping your Linux box without editing their hosts file.  You don't have to actually run Samba (smbd) but you will need the nameserver (nmbd) running.

I'm not aware of any way of automatically mapping Windows names to IPs on the Linux side, but the "nmblookup" program can do it in a similar way as "nslookup" or "host" do, it's just a bit more manual.  Note that winbind is more aimed at integrating your Linux machine in with Active Directory, it handles the mapping of users, groups and logins rather than hostnames.  (For example using winbind you can let users in Active Directory SSH into your Linux box without creating a specific account for them first.)

----------

## szczerb

But instead of setting up netbios name resolution you should just use a working DNS server ;/

----------

## d4mo

Well here's the deal.  I turned on Local DNS on DDwrt.  I can ping Windows computers from my nix box by name just fine.  But I can't do it the other way around. 

From what you guys are saing DHCP should be sending my hostname to DNSmasq on my router and I should need any part of samba to do it...correct?  Or am I mistaken.

Also I don't use static IPs, so I don't want to do host file entries.  I also just want to get this to work out of principle.

----------

## szczerb

Did you get new leases for windows hosts after turning on local DNS?

----------

## d4mo

I believe so.  The computer was turned off and not listed in DDwrt as having a lease.  But i don't think that is the problem anyways.  Because in DDwrt when you look at who is connected to your router it says what there host name is.  It shows up for all my Windows machines, but my nix box just shows up as a *.  Same as my 360, which I assume has no name.

----------

## szczerb

Then your nix has a misconfigured dhcp client which doesn't send it's host name.

----------

## d4mo

Where would the setting be for that...or what would I be looking for?

----------

## d4mo

Ok, I kind of have it working.  DD-wrt shows it as my host name.  And on windows if I do a ping -a 192.168.xxx.xxx it shows my host name and the IP.  But the weird thing is if I do a ping hostname on windows it says host in unreachable.  Any idea why?

----------

## szczerb

Usually hosts are unreachable when there is no root to them...right? So do you have a fancy setup with multiple networks with different addresses or something?

----------

## d4mo

No, just a standard 192.168.1.x Class C network.

----------

## szczerb

That's weird...like you don't have the route to the local network ;/

----------

## Malvineous

When you say ping "192.168.xxx.xxx" you do realise that's up to 256 different class C networks?  As in, if you're on 192.168.1.xxx and you try to ping 192.168.0.xxx you'll need a machine routing the traffic between the two subnets?

----------

## d4mo

 *Malvineous wrote:*   

> When you say ping "192.168.xxx.xxx" you do realise that's up to 256 different class C networks?  As in, if you're on 192.168.1.xxx and you try to ping 192.168.0.xxx you'll need a machine routing the traffic between the two subnets?

 

Yes I realise that.  It's just one subnet.  192.168.1.x.  

Any ideas on what to try next?

----------

## Malvineous

You could try a traceroute to see how far it gets before it stops.  When it gets to a machine that should respond but doesn't, that's the one whose firewall rules you'll need to fix.

----------

