Ubuntu as a Domain Controller

In this guide, we will be setting up Ubuntu as a domain controller with kerberos and samba.

sudo apt update && sudo apt upgrade -y
sudo passwd root
sudo hostnamectl set-hostname srv

At this point create one password for the user ‘root‘, because you will have to proceed as ‘su‘ instead of the command ‘sudo‘. Then switch to root user:

apt-get install samba krb5-config winbind net-tools smbclient -y

Three questions will popup. Answer the Default Kerberos v5 realm in UPPERCASE:


Than answer twice in lowercase the FQDN for the server of your domain:


Issue the command below, but replace the IP ‘‘ with your ‘srv‘ IP and domain name:

echo ' srv srv.company.com' >> /etc/hosts

Issue the commands to start a new Samba configuration:

mv /etc/samba/smb.conf /etc/samba/smb.conf.bkp
samba-tool domain provision

For the DNS Forward, we are going to use the Google Public DNS Server (‘‘).

Set the password to the user ‘Administrator‘

Finally, enable and start the service -

cp /var/lib/samba/private/krb5.conf /etc/
systemctl disable --now smbd nmbd winbind systemd-resolved
systemctl unmask samba-ad-dc.service
systemctl enable --now samba-ad-dc.service
samba-tool domain level show

rm /etc/resolv.conf
echo 'nameserver' >> /etc/resolv.conf

Some useful samba-tool commands

sudo samba-tool user list
sudo samba-tool user create UserName
sudo samba-tool user delete UserName
sudo samba-tool user disable UserName
sudo samba-tool user enable UserName
sudo samba-tool user setpassword UserName
sudo samba-tool user setexpiry UserName --days=30
sudo samba-tool group list
sudo samba-tool group listmembers GroupName
sudo samba-tool group add GroupName
sudo samba-tool group delete GroupName
sudo samba-tool group addmembers GroupName UserName
sudo samba-tool group removemembers GroupName UserName
sudo samba-tool computer list
sudo samba-tool group add –h
sudo samba-tool user add -h
sudo samba-tool user add domainName --given-name=givenName --surname=surName --mail-address=userName@example.com --login-shell=/bin/bash
sudo samba-tool domain passwordsettings show
sudo samba-tool domain passwordsettings set -h
sudo samba-tool gpo listall
sudo samba-tool drs showrepl
sudo samba-tool dns -help
sudo samba-tool dns query example.com zone A -U Administrator
sudo samba-tool dns zonecreate domain.local 0.0.10.in-addr.arpa -U Administrator
sudo samba-tool processes
sudo samba-tool visualize ntdsconn
sudo samba-tool visualize reps

netplan example

  version: 2
  renderer: networkd
        search: [COMPANY.COM]
        addresses: [,]
        - to: default