This episode enters the Active Directory world: provisioning a full AD DC with samba-tool domain provision, the integrated internal DNS, replication between Domain Controllers, and a case analysis of replacing a Windows Server DC at small-to-medium scale. You also understand the daemon architecture differences in DC and member modes.

Up to episode 8, Samba worked as a standalone file server — users managed locally. In episode 9 we climb to Samba's highest level: making it a full Active Directory Domain Controller. This feature, carried by Samba 4 since 2012, means you can replace a Windows Server DC — with DNS, Kerberos, and AD replication — all on Linux. This is the use case that keeps Samba from being dismissed as "just a file server".
A Domain Controller is a server that stores the Active Directory database (users, computers, groups, policies) and provides domain authentication (Kerberos + LDAP) as well as AD DNS. A Windows computer "joining the domain" means trusting the DC for login and policy application.
Remember episode 2: in standalone mode we use smbd + nmbd. In AD DC mode, Samba uses a single samba daemon that runs everything — file server, authentication, and AD DNS — in one process. This isn't just a name difference; the internal architecture is specifically designed to serve the AD database and replication.
Before provisioning, smb.conf must be reset to DC mode — Samba provides samba-tool domain provision, which writes the correct configuration for you. Start from a clean config:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo samba-tool domain provision \
--use-rfc2307 --interactive--interactive guides you through entering:
LAB.LOCAL (UPPERCASE format).LAB.dc.SAMBA_INTERNAL — AD DNS run by Samba itself.--use-rfc2307 adds the POSIX schema (UID/GID) to AD — required so AD users can be mapped to Unix identities in episode 10 (winbind). Without this option, integrating Linux logins into the domain will be difficult.
sudo systemctl unmask samba-ad-dc
sudo systemctl enable samba-ad-dc
sudo systemctl start samba-ad-dcOn Ubuntu/Debian systems, the smbd/nmbd services and samba-ad-dc are mutually exclusive — disable smbd/nmbd so they don't clash over ports 445/139 (both belong to the samba daemon in DC mode):
sudo systemctl disable --now smbd nmbdWarning
The most common mistake here: leaving smbd/nmbd running alongside samba-ad-dc. Both fight over ports 445/139, and the loser fails to start. When DC mode is active, systemctl status samba-ad-dc must be active (running) and port 445 served by the samba daemon — not smbd. Check with sudo ss -tlnp | grep 445.
DNS is the backbone of AD: clients find the DC via SRV records (_ldap._tcp.lab.local), not by guessing addresses. In DC mode, AD DNS is run internally by samba (the SAMBA_INTERNAL backend). Verify the AD DNS service:
sudo samba-tool domain info 127.0.0.1
samba-tool dns query localhost LAB.LOCAL @ A -U Administratordomain info shows the domain name, forest, and functional levels. samba-tool dns query inspects records stored in AD DNS. For clients, point their DNS at this DC's address — that's the only way they find the domain.
Samba doesn't provide a DHCP server — that's outside its scope. The common pattern: a DHCP server (ISC dhcpd, dnsmasq, or a router) hands clients an IP along with DNS = the DC's address. So "integrated DNS/DHCP" means the architecture is designed so DHCP points clients at the DC's DNS — not that Samba runs DHCP.
A single DC is a single point of failure. With two DCs, the AD database replicates automatically — a user created on DC1 appears on DC2 within seconds. To add a second DC:
sudo samba-tool domain join LAB.LOCAL DC -U Administrator --dns-backend=SAMBA_INTERNALAfter joining, check replication health:
sudo samba-tool drs showreplsamba-tool drs showrepl shows the replication list with partner DCs, success status, and last sync time. This is the analogue of repadmin /replsummary in the Windows world — a tool you must know by heart when managing a Samba domain.
The most common scenario: small-to-medium organizations (50-2000 users) that want to get off Windows Server licensing. The steps: set up a Samba DC as an additional DC in the same forest, let replication run, migrate objects, then decommission the Windows DC. An honest note on limitations:
Samba AD DC isn't a replacement for Windows Server in every large enterprise scenario — but for small-to-medium scale with standard needs (domain login, files, DNS, basic GPOs), it offers significant license savings with manageable risk.
Important
The decision to migrate a Windows DC to Samba is not purely technical — it's a business decision. Do a feature assessment (GPO, DFS, Exchange, line-of-business apps that write to AD) before committing. A provisioned domain isn't "cheap" to undo; Samba provides samba-tool domain demote, but that's not a shortcut for bad design.
A complete verification package:
sudo samba-tool domain level show
samba-tool domain info 127.0.0.1
samba-tool user list -U Administrator
host -t SRV _ldap._tcp.lab.localdomain level show: domain/forest functional levels.user list: stored users (should already include Administrator and krbtgt).host -t SRV: verify a client can find the DC via DNS — the final test of domain reliability.Key takeaways:
samba daemon; smbd/nmbd must be disabled.samba-tool domain provision --use-rfc2307 creates the domain, DNS, and initial admin.SAMBA_INTERNAL backend) is the heart of domain discovery; point clients at the DC for DNS.samba-tool drs showrepl; a second DC is added with samba-tool domain join.In episode 10 next, we'll cover winbind: AD user integration — joining as a domain member with net ads join, AD → UID/GID mapping by winbindd, Linux login authentication with AD users, and the security = ads, realm, and winbind use default domain configuration. Your Samba server will accept users from the domain!