Installation on Debian 13
Samba 4 AD Domain Controller on Debian 13
This expects a freshly installed Debian 13 (trixie) VM. Not
aan LXCContainercontainer. Debian 13 ships Samba 4.22, which supports AD functional level 2016.
Preparation
What you need
Decide
aonHostname,hostname,Domaindomain and IP
you start. Changing any of them after provisioning means starting over.
ItThiswillguidebeuses:
Item Value Hostname srv-dc01asHostname,DNS domain (realm) samba-test.lanasDomainandNetBIOS domain SAMBA-TESTIP / prefix 10.0.0.55/20asIPGateway 10.0.0.254Upstream DNS 10.0.0.254NetBIOS domain names are limited to 15 characters. Hyphens are allowed.
1. Preparation
Updates
& Upgradesapt update-y apt upgrade -yapt full-upgrade -ydependencies
Core
Dependenciesapt install -y chrony vim ethtool
ConfigureHostname
hostnamectl set-hostname srv-dc01Configure
/etc/hosts. Remove the Debian default127.0.1.1line — the FQDN must resolve to the real IP:127.0.0.1 localhost 10.0.0.5 srv-dc01.samba-test.lan srv-dc01
ConfigureVerify:
hostname -fMust return
srv-dc01.samba-test.lan. If it does not, provisioning will fail.Network
Modify
/etc/network/interfaces.Interface
ens18might be named differently foryouyou.auto ens18 iface ens18 inet static address 10.0.0.5/20 gateway 10.0.0.254synchronisation
ConfigureTime
Timesyncsystemctl enable --now chrony chronyc tracking
ValidateKerberosthattoleratesTime-Synca clock skew of ±5 minutes. Aim for an offsetiswellwithin max.under 5Secondsseconds — anything larger means chrony has not converged yet.Signed NTP for Windows clients is configured later (section 7), because the socket directory does not exist until after provisioning.
Disable
systemd-resolvedSamba's internal DNS server needs port 53.
systemctl disable --now systemd-resolved rm -f /etc/resolv.confCreate
/etc/resolv.conf:For
Provisioning,provisioning,setpointnamservernameservertoat yourRouterrouter orFirewallfirewall soaptworks.keepsAfterworking.that,Itchangeis switched tothe DC itself in section 5.127.0.0.1nameserver 10.0.0.254 search samba-test.lanEnsure
no DNS Servernothing isrunninglisteninganymoreon port 53:ss -tlnp | grep :53This
should notmust returnanything.nothing.
2. Install
Samba4Samba
Install Packagesapt install -y acl attr samba winbind libpam-winbind libnss-winbind \ krb5-config krb5-user dnsutils python3-setproctitle samba-ad-dc
krb5-configprompts during installation:
- Default Kerberos
Serversversionis5 realm:SAMBA-TEST.LAN(uppercase)- Kerberos servers for your
DC Hostname (Example:realm:srv-dc01.samba-test.lan)- Administrative server for your realm:
srv-dc01.samba-test.lanThese values are transient —
/etc/krb5.confis replaced in section 5.Verify the AD DC modules are present:
dpkg -l samba-dsdb-modules samba-vfs-modules samba -VWithout
samba-dsdb-modulesthe DC will not start.Mask
Serviesconflicting servicesDebian starts
smbd,nmbdandwinbindas standalone services immediately after installation. On an AD DC these must not run — thesambaprocess provides its own internal file server and winbind. Leaving them active causessamba-dcerpcdto crash-loop and NSS lookups to hang.systemctl disable --now smbd nmbd winbind systemctl mask smbd nmbd winbind
3. Domain
ProvisioningprovisioningRemove
existingtheConfigurationpackagedFileconfiguration file:rm -f /etc/samba/smb.conf
ProvisiongChoose one of the two variants below.Variant A — default functional level (2008 R2)
Conservative, fully supported, matches most existing Samba
Domaindeployments.samba-tool domain provision --use-rfc2307 --realm=SAMBA-TEST.LAN \ --domain=SAMBA-TEST --server-role=dc --dns-backend=SAMBA_INTERNAL \ --adminpass='ChangeMe123!'Variant B — functional level 2016
Required if the domain this DC will eventually replace runs at FL 2012 R2 or 2016, and needed for Kerberos claims, authentication policies and authentication silos.
samba-tool domain provision --use-rfc2307 --realm=SAMBA-TEST.LAN \ --domain=SAMBA-TEST --server-role=dc --dns-backend=SAMBA_INTERNAL \ --adminpass='ChangeMe123!' \ --function-level=2016 \ --option="ad dc functional level = 2016"The
--optiononly applies during provisioning. It must also be written permanently intosmb.conf(section 5) — on every DC in the domain.Caveats for FL 2016. Samba's implementation is partial and not enabled by default. Samba reads and writes claims and populates them into the PAC, but does not yet use them for access control decisions. Microsoft's PowerShell based AD tools are not expected to work. Functional levels cannot be lowered again.
If you omit
--adminpass, a random password is generated and printed to the console in cleartext, where it lands in your scrollback and terminal logs.
4. Deploy Kerberos
Configconfigurationcp /var/lib/samba/private/krb5.conf /etc/krb5.conf
FixCopyNameserverstheinfile — do not symlink it.
5. Configure DNS and
smb.confPoint the resolver at the DC itself. Rewrite
/etc/resolv.conf:nameserver 10.0.0.5 search samba-test.lan
SetupAddDNStheForwardingfollowingfortoSamba-DNStheinexisting[global]section of/etc/samba/smb.conf— do not create a second[global]block:[global]dns forwarder =1.1.1.110.0.0.254 # Variant B only — must be present on every DC ad dc functional level = 2016On first startup,
ad dc functional levelupdates the server's own AD entry with the configured level.Check the file parses:
testparm -s
6. Start
samba4Samba
Start Servicessystemctl unmask samba-ad-dc systemctl enable --now samba-ad-dc systemctl status samba-ad-dcIf the service fails to start, the two usual causes are a port 53 conflict (check
ss -tlnp | grep :53) andserver rolenot being set toactive directory domain controllerinsmb.conf.
7. Post-provisioning tasks
Set
DomaintheAdmindomainPasswordadministrator passwordsamba-tool user setpassword Administrator
Review the password policy
samba-tool domain passwordsettings showSamba defaults to a maximum password age of 43 days. In a lab this will expire on you at the worst possible moment:
samba-tool domain passwordsettings set --max-pwd-age=0Do not do this in production — use the policy your organisation requires.
Verify sysvol ACLs
samba-tool ntacl sysvolcheckIf it reports errors:
samba-tool ntacl sysvolresetCreate
Reversethe reverse DNSZonezoneProvisioning does not create one.
samba-tool dns zonecreate srv-dc01 0.0.10.in-addr.arpa -U AdministratorA
/20network spans10.0.0.xthrough10.0.15.x. Either create all 16 zones or use10.in-addr.arpainstead.Signed NTP for Windows clients
The socket directory exists only after provisioning:
chgrp _chrony /var/lib/samba/ntp_signd chmod 750 /var/lib/samba/ntp_signdAdd to
/etc/chrony/chrony.conf:ntpsigndsocket /var/lib/samba/ntp_signd allow 10.0.0.0/20systemctl restart chronyTake a snapshot
Snapshot the VM here — freshly provisioned, no clients joined. Domain join tests can then be repeated from a known state.
Verifications8. Verificationand listeners
GeneralServices
Verificationsss -tlnp | grep -E ':(53|88|389|445|464|636)\b' smbclient -L localhost -NExpected listeners: 53 (DNS), 88 (Kerberos), 389 (LDAP), 445 (SMB), 464 (kpasswd), 636 (LDAPS).
smbclientmust show thenetlogonandsysvolshares.DNS records
host -t SRV _ldap._tcp.samba-test.lan localhost host -t SRV _kerberos._udp.samba-test.lan localhost host -t A srv-dc01.samba-test.lan localhostRepeat from another host on the network — this is what clients actually do:
host -t SRV _ldap._tcp.samba-test.lan 10.0.0.5Kerberos
kinit administrator@SAMBA-TEST.LAN&&klistThe ticket must show realm
SAMBA-TEST.LAN.Directory consistency
samba-tool dbcheck --cross-ncs getent passwd administrator
Verify
getentPasswordprovesPolicyNSSwinbindsamba-toolresolutiondomainthroughpasswordsettingstheshowinternallevel
Verifyworks.DomainFunctional
Levelsamba-tool domain level show
DefaultVariantDomainAlevel isreports(Windows) 2008 R2, Variant B reports(Windows) 2016.If
you9.
haveRaising an existingZonedomain from 2008 R2 to 2016Only needed if you provisioned with Variant A and now need a higher level.
Functional levels cannot be lowered. Take a backup and verify it before starting.
Back up first
samba-tool domain backup offline --targetdir=/srv/backup samba-tool dbcheck --cross-ncsEnable the feature
Add to the
[global]section of/etc/samba/smb.confon every DC:ad dc functional level = 2016Restart Samba on every DC:
systemctl restart samba-ad-dcUpgrade schema and raise the level
samba-tool domain schemaupgrade --schema=2019 samba-tool domain functionalprep --function-level=2016 samba-tool domain level raise --domain-level=2016 --forest-level=2016Verify
samba-tool domain level show samba-tool dbcheck --cross-ncs
10. Domain join test
On the Windows client, set the DC as the only DNS server — not the router, not a public resolver. This is the cause of most "domain could not be contacted" errors.
After joining, confirm from the DC:
samba-tool computer list samba-tool user list
11. Before going to production
- Backups.
samba-tool domain backup offlineon a schedule, plus a tested restore. A DC without a verified restore path is not a DC you canalreadyrelyprovisiongon.- Second DC. Join a second controller and verify replication with
asamba-tool.newerdrsLevelshowrepl- sysvol replication. Samba does not replicate sysvol between DCs. This has to be built separately with rsync or osync. This surprises people migrating from Windows AD with DFS-R.
- Monitoring. Add LDAP, Kerberos and DNS service checks plus
samba-tool drs showreplto your monitoring.- FSMO roles. When replacing an existing DC, transfer the roles with
samba-tool fsmo transferbefore demoting the old one.