3

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?!

UPDATE

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

7 Answers 7

4

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 172.16.1.3 Haruhi
querying Haruhi on 172.16.1.3
172.16.1.3 Haruhi<00>

then you can extract it with a little shell work:

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

so you can put it all together:

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

and thus you don't have an IP listed.

3
  • 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, 2009 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, 2009 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. Oct 19, 2009 at 8:14
3

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

http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/integrate-ms-networks.html#id2668413

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

2

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

1
  • Works on Raspian/Debian Buster in September 2019
    – zuiqo
    Sep 30, 2019 at 22:44
1

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:

192.168.1.27 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.

2
  • 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.
    – Beeeaaar
    Sep 24, 2018 at 18:25
  • @Celess appreciation from the past (almost 10 years).
    – jmoz
    Dec 2, 2018 at 13:48
0

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

-o ip=111.111.111.111

obviously replacing the IP with the appropriate server IP.

5
  • The IPs in the network are not exactly static, they take a while to change, but eventually they do change
    – hasen
    Aug 3, 2009 at 5:43
  • well then that is another issue entirely, this will fix your connecting issue though.
    – user1931
    Aug 3, 2009 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, 2009 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 " ")
    – user1931
    Aug 3, 2009 at 5:57
  • Also check out this article it seems to be a similar problem: linuxquestions.org/questions/linux-software-2/…
    – user1931
    Aug 3, 2009 at 5:58
0

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

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

To expand on the accepted answer, you can simply look up the IP address for WINS name NAME with nmblookup NAME | grep 'NAME<00>' | cut -d' ' -f1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .