Ping / SSH computer via SMB name

0

0

At work, I can ping and SSH computers by either their IP or their SMB name.

If I try that at home (no, I am not trying to access the office internal network from home), then ping / SSH by IP address works fine, but SMB name fails.

(Just to clarify, hosts do show up in the smbtree and respond to pings by IP, just not by SMB name!).

At work there's a PFSense server managing the network. At home it's just a wireles router on a DSL line. All my devices on the home network are 192.168.1.x / 255.255.255.0 issued by DHCP.

The following is a sample from my home network.

user@computer:~$ smbtree -N
WORKGROUP
    \\UBUNTU-PC             computer server (Samba, Ubuntu)
        \\UBUNTU-PC\print$          Printer Drivers
        \\UBUNTU-PC\IPC$            IPC Service (computer server (Samba, Ubuntu))
    \\FILESERVER            fileserver server (Samba, Ubuntu)
        \\FILESERVER\Storage            
        \\FILESERVER\Videos     
        \\FILESERVER\Photos         
        \\FILESERVER\IPC$               IPC Service (fileserver server (Samba, Ubuntu))
user@computer:~$ nmblookup fileserver
querying fileserver on 192.168.1.255
192.168.1.9 fileserver<00>
user@computer:~$ ping fileserver
ping: unknown host fileserver
user@computer:~$ ssh fileserver
ssh: Could not resolve hostname fileserver: Name or service not known

$ ifconfig from my home PC

eth0      Link encap:Ethernet  Endereço de HW xx:xx:xx:xx:xx:xx  
          inet end.: 192.168.1.10  Bcast:192.168.1.255  Masc:255.255.255.0
          endereço inet6: xxxxxxxxxxxxxxx/64 Escopo:Global
          endereço inet6: xxxxxxxxxxxxxxx/64 Escopo:Global
          endereço inet6: xxxxxxxxxxxxxxx/64 Escopo:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Métrica:1

That Brazilian Guy

Posted 2015-05-22T13:05:38.427

Reputation: 5 880

@FranciscoTapia of which hosts(s)? I have two laptops, a file server, a raspberry PI, two smartphones, and a tablet. – That Brazilian Guy – 2015-05-22T13:19:04.000

What os do you have at work? Windows ping (and other winsock tools) can resolve names using smb multicast, WSD multicast, lmhosts or wins (Depends on Node Type). But **nix ping uses resolve.conf(for DNS) or yp.conf (for NIS) or hosts file. It can't use SMB name – user996142 – 2015-05-22T13:35:31.643

@user996142 Ubuntu at both home and work. No config files modified. – That Brazilian Guy – 2015-05-22T13:39:41.837

Try to run nslookup <<COMPUTER_NAME>> at work. I am sure you will get anwer from DNS server. That means you can access this server from work, but not from home. – user996142 – 2015-05-22T13:41:27.377

@user996142 I do not want to acess a remote machine from home! – That Brazilian Guy – 2015-05-22T16:33:24.703

Answers

2

The corrrect way to use SMB name resolution on a Linux machine is to edit (as su) the file /etc/nsswitch.conf and to make sure that the line beginning with hosts contains wins, like this, for instance:

 hosts:          files wins mdns4_minimal [NOTFOUND=return] dns

Of course you will be unable to contact any pc not running a SMB server, like for instance a Linux machine on which samba has not been downloaded, installed, and the NetBIOS name has not been provided in the /etc/samba/smb.conf file as follows:

 workgroup = WORKGROUP
 NetBIOS name = MyPCName

You should also remember that firewall settings may block these requests.

MariusMatutiae

Posted 2015-05-22T13:05:38.427

Reputation: 41 321

Why is it that 10 pings to the IP address takes 9s but 10 pings to the NetBIOS name takes 50+ seconds? – That Brazilian Guy – 2015-05-24T23:58:56.700