This guide details how to install and configure SAMBA 4.8 as an AD member server of an existing domain on FreeBSD 11.x. This is only a basic configuration with a single share that allows Domain Users read/write access. Further configuration can be performed to restrict access as well as enabling ACLs to provide granular access management to directories within shares.

NB: I’ve started right from the beginning of installing FreeBSD and YMMV if you are not installing from scratch but it’s only the samba48 package and its dependencies that are installed as part of this guide. You should also make sure your AD PDC FSMO is sourcing external time synchronisation because Kerberos authentication has a 5min tolerance. Clients exceeding that tolerance will experience authentication failures with their Kerberos tickets.

  1. Accepted default charset.
  2. Entered hostname.
  3. Unchecked docs, games and ports trees.
  4. Accepted default auto partitioning.
  5. Set root password.
  6. Configured network interface with IPv4 static IP.
  7. Did not configure IPv6.
  8. Entered AD DC domain and IP DNS settings.
  9. Set timezone.
  10. Added NTPD to the SSHD and dumpdev services to load at startup.
  11. Did not add any additional users.
  12. Exited the installer and rebooted.
  13. Modified /etc/ssh/sshd_config to permit root login
    #PermitRootLogin no
    PermitRootLogin yes
  14. Restart SSHD
    service sshd restart
  15. Update system:
    freebsd-update fetch
    freebsd-update install
  16. Modified /etc/sysctl.conf
  17. Install the “pkg” package manager and update the repository
    pkg update
  18. Install Samba 4.8
    pkg install samba48
  19. Create /etc/krb5.conf
    	default_realm = TEST.LOCAL
    	dns_lookup_realm = true
    	dns_lookup_kdc = true
    	ticket_lifetime = 24h
    	renew_lifetime = 7d
    	forwardable = yes
  20. Update /etc/nsswitch.conf
    group: files winbind
    passwd: files winbind
  21. Create /usr/local/etc/smb4.conf
    	workgroup = TEST
    	server string = Samba Server Version %v
    	security = ads
    	realm = TEST.LOCAL
    	domain master = no
    	local master = no
    	preferred master = no
    	socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
    	use sendfile = true
    	idmap config * : backend = tdb
    	idmap config * : range = 100000-299999
    	idmap config TEST : backend = rid
    	idmap config TEST : range = 10000-99999
    	winbind separator = +
    	winbind enum users = yes
    	winbind enum groups = yes
    	winbind use default domain = yes
    	winbind nested groups = yes
    	winbind refresh tickets = yes
    	template homedir = /home/%D/%U
    	template shell = /bin/false
    	client use spnego = yes
    	client ntlmv2 auth = yes
    	encrypt passwords = yes
    	restrict anonymous = 2
    	log file = /var/log/samba4/log.%m
    	max log size = 50
    #============================ Share Definitions ==============================
    	comment = Test share
    	path = /samba/testshare
    	read only = no
    	force group = "Domain Users"
    	directory mode = 0770
    	force directory mode = 0770
    	create mode = 0660
    	force create mode = 0660
  22. Join SAMBA to the domain
    net ads join -U administrator
    net ads testjoin
    # Should report "Join is OK"
  23. Enable and start SAMBA
    echo "samba_server_enable=YES" >> /etc/rc.conf
    echo "winbindd_enable=YES" >> /etc/rc.conf
    service samba_server start
  24. Test Kerberos
    kinit administrator
    # Enter domain admin password, should return to the prompt
    # Credentials cache: FILE:/tmp/krb5cc_0
    #    Principal: administrator@TEST.LOCAL
    # Issued                Expires               Principal
    # Dec  6 10:15:39 2014  Dec  6 20:15:39 2014  krbtgt/[email protected]
  25. Test Winbind
    wbinfo -u
    # Should return domain users
    wbinfo -g
    # Should return domain groups
    getent passwd
    # Should return domain users at the end of the list with 10000+ UIDs
    getent group
    # Should return domain groups at the end of the list with 10000+ GIDs

    If the wbinfo commands don’t work it means either there’s an error in /usr/local/etc/smb4.conf or the winbind service isn’t running. It will usually be an error in smb4.conf so make sure you’ve replaced TEST and TEST.LOCAL to suit your own environment. Then restart the services

    service samba_server restart

    If the getent commands don’t work but wbinfo DOES return the expected results, check your /etc/nsswitch.conf passwd: and group: lines are set correctly as above, “compat” should be removed from both lines so they just specify “files winbind“.

  26. Create the share location on the server
    mkdir -p /samba/testshare
    chown "administrator":"domain users" /samba/testshare
    chmod 0770 /samba/testshare

You should then be able to browse the share from a Windows client and create files and directories etc.

NB: If you get an error that the server cannot be found by the Windows client check your AD DNS and add a hostname for your SAMBA server if it does not exist. It may not have been automatically created during the domain join process but you should have received an error at that point stating as much.

Categories: FreeBSD

1 Comment

stoe · August 18, 2018 at 6:26 am

Thank you for sharing; your guides are highly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *