Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

6 Answers 6

up vote 2 down vote accepted

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.

share|improve this answer
    
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 –  hasenj 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

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.

share|improve this answer

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.

share|improve this answer
    
The IPs in the network are not exactly static, they take a while to change, but eventually they do change –  hasenj 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? –  hasenj 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.

share|improve this answer
    
got the same problem –  hasenj 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 –  hasenj Aug 3 '09 at 16:37

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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