# how can I ping my machines in LAN with host name?

## davidshen84

Hi,

I am using Gentoo 2008 x64. I have installed samba, and added 'wins support=yes' in /etc/samba/smb.conf file. Also, I have added 'wins' keyword in /etc/nsswitch.conf. But I still cannot ping my other machines in my LAN, however, my windows machines can ping all the machines including the linux machines.

What's wrong with my linux?

----------

## albright

are the machine names in your /etc/hosts file?

----------

## davidshen84

 *albright wrote:*   

> are the machine names in your /etc/hosts file?

 

with 'WINS', you can ping any of your machines in your LAN with the NetBios name. This is what windows does. And linux is now supporting this also.

I read on the net that I need to set my workgroup name the same as other windows machines. In my smb.conf file, I set 'workgroup = WORKGROUP'. But in the output of testparam, I did not see this information. Does 'WORKGROUP' an invalid value for workgroup? or it is not displayed because it is the same as default?

----------

## devilheart

WORKGROUP is the default workgroup name used when a workgroup name has not been setted and should not be used. i'm not sure but if i remember correctly, windows machines will not use wins unless netbios over tcp is enabled. you should try avahi

----------

## davidshen84

 *devilheart wrote:*   

> WORKGROUP is the default workgroup name used when a workgroup name has not been setted and should not be used. i'm not sure but if i remember correctly, windows machines will not use wins unless netbios over tcp is enabled. you should try avahi

 

my problem now is that my windows machines can see my linux machines, either by ping by host name, or see it in the 'Network' node in explorer. my none of my linux machines can ping any of my machines in my LAN with hostname...

I will try to rename the workgroup name to something not default.

----------

## devilheart

i still think you should try avahi

----------

## davidshen84

 *devilheart wrote:*   

> i still think you should try avahi

 

looks like avahi is my last chance to ping my machines by hostname. Thanks, I will try  :Very Happy: 

----------

## Nerevar

I wrote this a long time ago to get the ip address of unix/windows machines. I guess it still works, but I no longer have any windows boxes to test it. Try the nmblookup command first (part of samba) and see what it outputs as shown below.

```
# cat iplookup

#!/bin/sh

HOST=$1

#IP address of your WINS server

WINS_SERVER="XXX.XXX.XXX.XXX"

if [ -z "$1" ]; then

    echo "Usage: iplookup <hostname>"

    exit 1

fi

IP=`nslookup $HOST 2>/dev/null | awk '{ if (FNR == 5) print $2 }'`

if [ -n "$IP" ]; then

    echo "$IP";

else

    IP=`nmblookup -U $WINS_SERVER -R $HOST | awk '{if ($1 ~ /^[0-9]/) print $1}'`

    if [ -n "$IP" ]; then

        echo "$IP";

    else

        echo "$1: Unknown host";

    fi

fi
```

----------

## tutaepaki

I'd suggest you look into the nsswitch.conf config file. That's where you configure how your systems resolves names. I believe there is a WINS option you can add in there. (you need the build samba with the winbind use flag enabled to get this option I think)

----------

## poly_poly-man

hey, uhh... what's wrong with dns?

You can even get dhcpd to give bind the updates (windows clients push their hostname to the dhcp server, as well as many linux clients)

----------

## davidshen84

 *tutaepaki wrote:*   

> I'd suggest you look into the nsswitch.conf config file. That's where you configure how your systems resolves names. I believe there is a WINS option you can add in there. (you need the build samba with the winbind use flag enabled to get this option I think)

 

oops, I do not have winbind enabled on my machine. I will try later. Thanks  :Very Happy: 

----------

