Hi
I've recently came across setting Samba as file sharing service on my FreeBSD.
I found some FreeBSD related doc's confusing too. However the Samba official documentation, Linux tutorials with some books help should be ok
In my case I've found that my problems with Samba were connected with active directory or domain or network or authentication issues which are often host or site specific.
I had no Active Directory, ldap, nor DNS configured. I've used Samba 4.6 from package on RaspBSD 12 (which goes with 11 branch). My input is not ready solution, but I hope it may help somebody.
First - check yours hostname and set the name hostname="hostname.domain.tld" (rather don't use .localhost or example.com)
I've set it in the
/etc/rc.conf
Confusion -
domainname(1) - it is not Samba domain related - it's NIS/YellowPages UNIX service.
Second - set up
/etc/hosts
Code:
::1 rpi.aigo.go localhost rpi
127.0.0.1 rpi.aigo.go localhost rpi
192.168.1.5 rpi.aigo.go rpi
A name next to the address is full name (FQDN), followed by aliases
Third - you need
/usr/local/etc/smb4.conf. There is no
share/example.
Let's take a look at
less /usr/local/share/doc/samba46/README.FreeBSD
. There is
samba-tool domain provision --interactive --use-xattrs=no --use-ntvfs
.
For me only --interactive worked, however we may learn that FreeBSD's Samba works on UFS2 ACL. So check
tunefs -p /dev/da0p1
whether you are using it. For me NFSv4 ACLs worked, it doesn't have to be POSIX.1e ACLs. Turn it on by
tunefs
(in single user mode as / must be detached if needed).
After
samba-tool domain provision --interactive
there will be generated a simple
/usr/local/etc/smb4.conf. The tool will use your hostname to determine REALM, netbios name and workgroup (all must be uppercase). I've set dns to samba internal, without dns forwarding and copied
cp /var/db/samba4/private/krb5.conf /etc/krb5.conf
. But wait a sec - I've already set up a Active Directory backend
Code:
passdb backend = samba_dsdb
It is something I didn't want to, and I have little idea about it.
Confusion: Samba have BIND dns, FreeBSD comes with unbound.
You may also update
/etc/resolv.conf if this apply to your configuration - add nameserver 127.0.0.1 or search.
So we may take a look at
https://www.freebsd.org/doc/handbook/network-samba.html
The backend used there is
passdb backend = tdbsam
I've read somewhere that it is depreciated and skiped it in first approach - no it works, smbpasswd backend is Samba 3 stuff and discouraged in Samba 4 as far as I know.
So we need to add an user
pdbedit -a username
Confusion. My wife need a password... yeah:
pdbedit -a nobody
I've read some examples on forum and web.
I found also useful
smb.conf(5) and
testparm -v
Finally my
smb4.conf:
Code:
[global]
netbios name = RPI
realm = AIGO.GO
workgroup = AIGO
server string = Some text
passdb backend = tdbsam
#security = user # its default - to allow guest
#have no printers disable spoolss = yes
disable spoolss = yes
#want to use mount_smbfs with ntlm_v1 on
ntlm auth = yes
map to guest = Bad User
guest account = nobody
#these two are netbios stuff
#local master = yes #default yes
#domain master = auto #default auto
domain master = yes
#os level = 255 if your wins must win over windows machines
# win81 = 62 win10 = 100?
os level = 255
wins support = yes
#log 1 ,2 3, 5 10
log level = 3
max log size = 1000
# smb ports = 139 445 # its default
#with password
[raspberry]
comment = "home::"
path = /usr/home/raspberry
#not valid users just users
users = raspberry
read only = no
create mask = 755
directory mask = 755
#with password
[cores]
comment = "Public"
path = /mnt/cores
read only = no
public = yes
create mask = 755
directory mask = 755
Of course user nobody have file rights. Ports 139 and 445 are opened.
Then - how to start Samba?
1 -
/usr/local/sbin/smbd if you like - for more check help option.
2 - through
/etc/inetd.conf - my choice for filesharing uncomment 2 lines referring samba
Code:
netbios-ssn stream tcp nowait root /usr/local/sbin/smbd smbd
netbios-ns dgram udp wait root /usr/local/sbin/nmbd nmbd
3 - you have an AD or ldap, you will use winbindd
service samba_server onestart
or by
/etc/rc.conf
Code:
samba_server_enable="YES"
Confusion - if you choose more than one way I'm not sure if this will act correctly (or unless you have correctly set up domain). I had some problems with it.
Other useful command:
smbcontrol all reload-config
smbstatus
smbtree
nmblookup -B client '*'
smbclient //192.168.1
Then I could
mount_smbfs -I 192.168.1.5 -U raspberry //a@a/raspberry /mnt/sth/
I'm not able to credit all sources. However you may find useful
https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server
http://www.oreilly.com/openbook/samba/book/
https://www.samba.org/samba/docs/using_samba/toc.html
https://wiki.archlinux.org/index.php/samba
As this is my first post I want to say thank you to the Forum Team, Timur (the port maintainer) and FreeBSD crew.
Cheers
grzes