Edited 2 days ago by ExtremeHow Editorial Team
SambaActive DirectoryServer SetupConfigurationNetworkingUser ManagementAuthenticationCross-PlatformPermissionsAdmin
This content is available in 7 different language
Samba is an open-source software suite that provides seamless file and print services to SMB/CIFS clients. An interesting feature of Samba is its ability to act as an Active Directory domain controller. This guide provides comprehensive steps to install and configure Samba as an Active Directory domain controller on a Linux server.
Samba is a free software re-implementation of the SMB/CIFS networking protocol that allows you to interact with a Windows client or server. Samba enables interoperation between Linux/Unix servers and Windows-based clients. The protocol used by Samba falls under the category of "network file sharing protocols", and its main function is to share files and printers between Unix-like systems such as Windows and Linux.
Before you begin setting up Samba Active Directory, make sure you have the following:
The configuration of the hostname on your Linux server is important for the proper functioning of Samba. Use the following command to set or change the hostname:
sudo hostnamectl set-hostname
Verify the change by checking your current hostname:
hostnamectl
You need to make sure that your machine's hosts file has the correct hostname and IP mapping. Edit the /etc/hosts file:
sudo nano /etc/hosts
If your server's IP address and newly set hostname don't already exist, add or modify them:
127.0.0.1 localhost 192.168.xx .yourdomain
127.0.0.1 localhost 192.168.xx .yourdomain
Install the Samba package and required dependencies. Use the appropriate package manager for your Linux distribution.
sudo apt update sudo apt install samba smbclient krb5-user
sudo yum update sudo yum install samba samba-client samba-common
During installation, you may be asked to configure Kerberos. If so, enter a description of the region (for example, EXAMPLE.COM) and domain in capital letters.
Before you can promote your server to an Active Directory Domain Controller (AD DC), you must provision Samba AD.
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak sudo samba-tool domain provision --use-rfc2307 --realm=YOURDOMAIN.COM --domain=YOURDOMAIN --adminpass=YourStrongPassword
Replace "YOURDOMAIN.COM" with your actual domain name and "YourStrongPassword" with a secure password of your choice. The configuration process sets up a basic domain setup with Kerberos, DNS, LDAP, and SMB.
Start the Samba services using the following:
sudo systemctl start smbd nmbd sudo systemctl enable smbd nmbd
sudo systemctl start smb nmb sudo systemctl enable smb nmb
Verify if Samba services are running properly:
systemctl status smbd systemctl status nmbd
Samba uses its own DNS server to manage AD Active Directory services. Make sure SAMBA_DNS is set to internal:
sudo nano /etc/samba/smb.conf
Make sure the parameter under the [global] section is:
dns forwarder = YourDNSIP #or leave it empty to disable
Restart Samba DNS:
sudo systemctl restart samba-ad-dc
To verify that the Active Directory domain controller is working, perform the following checks:
sudo samba-tool domain level show
host -t A . .com
host -t A . .com
host -t A . .com
ldapsearch -x -b "dc=yourdomain,dc=com" -H ldap://localhost
To integrate your Samba AD DC with Windows machines:
Reboot the system and make sure users can log in with their domain credentials.
ping <hostname>
.Setting up Samba as an Active Directory domain controller can provide a strong alternative to Windows Server, bringing centralized user management and authentication to a Linux-based infrastructure. These steps provide a base configuration that can be expanded to match more specific enterprise needs.
If you find anything wrong with the article content, you can