I'm reading this as a guide for accessing a Windows network from linux using samba.

The machine I want to access on my network is called HP, the following commands work fine:

smbclient -L HP
smbclient //HP/D

But, when I want to mount it, I get:

$ smbmount //HP/D /media/hp/d/
mount error: could not resolve address for HP: No address associated with hostname
No ip address specified and hostname not found

The error seems strange, if it can't resolve HP, how did smbclient read it?!


I don't want to specify the IP addresses manually because they tend to change every once in a while.


That's weird... normally smbmount can figure out names on its own. However, since it doesn't, you could use nmblookup to figure out which resolution methods work, and then use it as part of your mount command. For example, if you use a WINS server:

$ nmblookup -R -U Haruhi
querying Haruhi on Haruhi<00>

then you can extract it with a little shell work:

$ nmblookup -R -U Haruhi | grep 'Haruhi<00>' | cut -d' ' -f1

so you can put it all together:

smbmount //HP/D /media/hp/d/ -o ip=`nmblookup -R -U HP | grep 'HP<00>' | cut -d' ' -f1`

and thus you don't have an IP listed.

  • awesome! for some reason though nmblookup returned two lines with the ip and ending with <00> so I had to add -m 1 to grep – hasen Aug 3 '09 at 9:48
  • 1
    That is odd, maybe it got two answers? Wonder if its related to why smbmount isn't working like it should. – derobert Aug 5 '09 at 15:33
  • i get two lines from my samba server that has an aliased interface (eth0:0) on the same subnet as the real interface (eth0). if i leave off the -U option only the real interface is returned, but with it both interfaces are listed. – quack quixote Oct 19 '09 at 8:14

On Debian and probably others, install winbind:

apt-get install winbind

And check that "/etc/nsswitch.conf" has "wins" in the "hosts" line, as in:

hosts: files dns wins

This second one may already have been done for you.

The package creates the file /lib/libnss_wins.so


You can then just add the entries to the /etc/fstab file.


I've been trying to mount my media streamers samba share similiar to this. The share is named playonhd and using the smbclient -L //playonhd works but

sudo mount -t cifs -o guest //playonhd/HDD1 /mnt/box

does not.

My way around this without specifying an ip on the mount command is to use the alias I set up in /etc/hosts: box

Which allows

sudo mount -t cifs -o guest //box/HDD1 /mnt/box

to be used. I know the ip still has to be specified but in my case this was ok as it was already in the hosts file and I didn't want to specify it on the cl.

  • 1
    Greetings form the Future: I have had the same exact problem with a new install of Ubuntu 18.04.1 on VirtualBox with bridged connection, where with a new install on VMWare with the same 18.04.1 it works fine every time. Nothing I have tried gets it to work. – Celess Sep 24 '18 at 18:25
  • @Celess appreciation from the past (almost 10 years). – jmoz Dec 2 '18 at 13:48

You can specify an IP address with the options switch, add this to the end:

-o ip=

obviously replacing the IP with the appropriate server IP.

  • The IPs in the network are not exactly static, they take a while to change, but eventually they do change – hasen Aug 3 '09 at 5:43
  • well then that is another issue entirely, this will fix your connecting issue though. – John T Aug 3 '09 at 5:46
  • Yes, it did work, thanks :) but I consider this a temporary/sub-optimal solution. Is there a way (using smbclinet for example) to automatically get the IP address of the machine and then pass it to the smbmount command through a pipe or something like that? – hasen Aug 3 '09 at 5:52
  • well you can assign it a static IP from your router. You can then edit the lmhosts file, this is basically the hosts file for samba. Alternatively if the windows box can access your PC, have it write its new IP to a file on your machine each boot perhaps? Then simply do something like this: smbmount //HP/D /media/hp/d/ -o ip=$(cat ~/somefile.txt | tr -d " ") – John T Aug 3 '09 at 5:57
  • Also check out this article it seems to be a similar problem: linuxquestions.org/questions/linux-software-2/… – John T Aug 3 '09 at 5:58

I've always had problems with hostname based smbmount mounting. Try mount.cifs, it works for me where smbmount doesn't.

  • got the same problem – hasen Aug 3 '09 at 9:51
  • So mount.cifs works? Problem solved? :) – user4126 Aug 3 '09 at 12:12
  • lol, no dude it doesn't work – hasen Aug 3 '09 at 16:37

Assuming you have winbind set up, attaching .local after the host name worked for me. For example: sudo smbmount //mycomputername.local/storage /media/storage/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.