# samba share can not appear in macbook pro



## topclimber (Jun 6, 2010)

Hi Guys

I got this samba server problem and I have been struggling for a month not being able to resolve.

The samba server is setup in home network with ip: 192.168.1.123 which is a Freebsd8, and all my windows clients can connect to the shares, I can also mount them when windows startup. Main problem here is that: From a macbook pro, no matter what I try, I can not connect to any share, nor I can even connect to the server and browse those shares.

I have checked the allowed ip addresses, permission, none of them should be problem. I am having some problems wih samba,but just not sure what the cause is or there is any connection to the mac problem. They are:

1. When I connect to samba SWAT admin from Lan, the web page opening is extreamly slow,it'll take 10~20 seconds to load a page. I can use both ip or a hostname(eg, dev:901, I setup the dev.abc as hostname in freebsd) to visit the SWAT. However if I visit the same SWAT from KDE in freebsd box itself, eg: localhost:901, the page loading is quick and immediately.

I suspect some settings related to hostname, or name binding in Freebsd is not properly,so that it'll always check hostname matching ip etc. But I am just not familar with all these naming issue. Any idea?

2. Similarly, with the name issue. I can visit share in windows by hostname but not ipaddress, eg: I can use: \\dev\share to mount in windows, but it will not work if I use ip, eg: \\192.168.1.123\share, this seems worked before I upgrade from freebsd7 to freebsd8 and also upgrade the samba server. In macbook pro, none of either way(ip or hostname) works.

3. I have done some tests in office and tested that the macbook pro can smoothly connect to other windows share drive with specifying: smb:\\ip, then choose what share to mount. So any idea what the really issue with my case?

Any help is much appreciated. 

Cheers,

Stephen


----------



## JimW (Jun 6, 2010)

Can you at least successfully ping your FreeBSD box from the Macbook?

Post a copy of your Samba config file... /usr/local/etc/smb.conf

Regarding your name resolution problem.... for a home network, it is probably best to add a line for your server in the hosts file on all your client machines.


----------



## topclimber (Jun 7, 2010)

JimW said:
			
		

> Can you at least successfully ping your FreeBSD box from the Macbook?



Yes, I can ping from mac, but not with the hostname: eg ping dev. However I can ping by ip or hostname from windows.




			
				JimW said:
			
		

> Post a copy of your Samba config file... /usr/local/etc/smb.conf


 I will after I go home



			
				JimW said:
			
		

> Regarding your name resolution problem.... for a home network, it is probably best to add a line for your server in the hosts file on all your client machines.


Oh, I now remember that I probably have added this in windows machine, that's why it worked. But why I can not use ip address to visit the samba server from windows, eg:smb://192.168.1.123/share?


----------



## JimW (Jun 7, 2010)

topclimber said:
			
		

> But why I can not use ip address to visit the samba server from windows, eg:smb://192.168.1.123/share?



Your Windows machines can see the Samba server because of Netbios.

The whole situation will become clearer after you post your /usr/local/etc/smb.conf file and it can be seen how you have Samba setup.

It would also be useful if you post your /etc/rc.conf file too.

You can change the names of your servers while posting your configs... to protect the innocent.


----------



## JimW (Jun 7, 2010)

topclimber said:
			
		

> I have done some tests in office and tested that the macbook pro can smoothly connect to other windows share drive with specifying: smb:\\ip, then choose what share to mount. So any idea what the really issue with my case?



I forgot to ask you before about this....

Does your home server have a different WORKGROUP name than your office?

It probably does, and that could be a problem too. I'm not really up on Mac too much, but I think it needs the correct workgroup name set in your SMB services configuration.


----------



## topclimber (Jun 7, 2010)

Hi JimW

This is my smb.conf as below.

I have setup the hosts in mac and now I am able to ping the freebsd via hostname, however I still can not visit the smb service, eg: when I go server - smb://dev/share or smb://dev, my mac always says: invalid username and password, but I am using same username/pw used for windows machine

So any idea?



```
# Samba config file created using SWAT
# from UNKNOWN (#!ë¿¿#!`##!o#@(ë¿¿)
# Date: 2010/03/28 19:27:43

[global]
        dos charset = cp936
        unix charset = cp936
        workgroup = MYGROUP
        server string = Samba Server
        security = SHARE
        log file = /var/log/samba/log.%m
        max log size = 50
        dns proxy = No
        valid users = stephen
        read list = stephen
        write list = stephen
        hosts allow = 192.168.1.100, 192.168.1.101, 192.168.1.102, 192.168.1.103, 192.168.1.104, 192.168.1.105, 192.168.1.106, 192.168.1.107, 192.168.1.166

[printers]
        comment = All Printers
        path = /var/spool/samba
        printable = Yes
        browseable = No
        browsable = No

[share]
        path = /media/AAAAA
        valid users = stephen
        read list = stephen
        write list = stephen
        hosts allow = 192.168.1.100, 192.168.1.101, 192.168.1.102, 192.168.1.103, 192.168.1.104, 192.168.1.106, 192.168.1.105, 192.168.1.107, 192.168.1.123
```


----------



## topclimber (Jun 7, 2010)

Hi JimW

I noticed the error in the log as below:

Some thoughts, I found that mac automatically turn its hostname to ipaddress.hostcompany.com, this somehow breaks the auth/connection. So does this look like a samba bug?



```
[2010/06/07 20:58:32,  0] lib/util_sock.c:1685(get_peer_name)
  Matchname failed on 192-168-1-104.myhostingcompany.com 192.168.1.104
[2010/06/07 21:02:58,  0] lib/util_sock.c:1685(get_peer_name)
  Matchname failed on 192-168-1-104.myhostingcompany.com 192.168.1.104
[2010/06/07 21:03:06,  0] smbd/password.c:805(authorise_login)
  authorise_login: rejected invalid user nobody
[2010/06/07 21:03:06,  1] smbd/service.c:676(make_connection_snum)
  create_connection_server_info failed: NT_STATUS_WRONG_PASSWORD
[2010/06/07 21:03:27,  0] lib/util_sock.c:1685(get_peer_name)
  Matchname failed on 192-168-1-104.myhostingcompany.com 192.168.1.104
[2010/06/07 21:03:41,  0] lib/util_sock.c:1685(get_peer_name)
  Matchname failed on 192-168-1-104.myhostingcompany.com 192.168.1.104
[2010/06/07 21:03:56,  0] lib/util_sock.c:1685(get_peer_name)
  Matchname failed on 192-168-1-104.myhostingcompany.com 192.168.1.104
```


----------



## topclimber (Jun 7, 2010)

I performed another test just now. What I have done is to:

1. Add a entry in mac hosts to point to freebsd, eg: point ipaddress 192.168.1.123 to dev
2. Add a entry in freebsd hosts to point to mac, eg: point ipaddress 192.168.1.104 to abc [the mac hostname]

Though now the hostname works for both freebsd, mac still complains about:username/pw validation.

I found this error in log:



```
[2010/06/07 22:25:12,  1] smbd/service.c:676(make_connection_snum)
  create_connection_server_info failed: NT_STATUS_WRONG_PASSWORD
```


----------



## JimW (Jun 7, 2010)

topclimber said:
			
		

> I performed another test just now. What I have done is to:
> 
> 1. Add a entry in mac hosts to point to freebsd, eg: point ipaddress 192.168.1.123 to dev



By *"dev"* you mean the Server's hostname.... right?

Edit your smb.conf and remove... or comment out the following lines in the *Global* section....


```
dos charset = cp936
unix charset = cp936
valid users = stephen
read list = stephen
write list = stephen
```

You don't have any DOS clients connecting... do you?

Add the following lines to the *Global* section....


```
netbios name = [i]Servername[/i]
domain master = No
local master = Yes
preferred master = Yes
hosts allow = 192.168.1. 127.
os level = 64
```

You need to set a Netbios name. Usually you make it the same as the machine's hostname (Not the long FQDN.... the short hostname)

On your *share* section, change it to the following....


```
path = /media/AAAAA
comment = [i]Share Name[/i]
writeable = Yes
available = Yes
valid users = stephen
```

Do your editing from a text editor and save backup copies....(e.g.  smb.conf.001...smb.conf.002) Don't use SWAT to make changes.

You don't need the *hosts allow =* statement in the *share* section. The above would restrict use to the local LAN and save you from typing in all those IP addresses. It only needs to be in the *Global* section.

Did you create a Samba user account for the user *stephen*? If not, it might be best to do it again from the command line. Users need Samba accounts. SWAT may have done it, but it might be best to do it again yourself. As root on the FreeBSD box do the following...


```
smbpasswd -a stephen
```

Also, you need to set a hostname on your MAC and set the proper WORKGROUP...(MYGROUP) All clients in the local LAN should be part of the same WORKGROUP.

Start by trying these simple changes and see what happens. Good Luck.


----------

