Setting up Samba as an Active Directory Domain Controller
- 1 Introduction
- 2 Versions
- 3 Server Information
- 4 Installation
- 5 Provisioning The Samba Active Directory
- 6 Testing Your Samba Domain Controller
- 7 Configure DNS
- 8 Configure Kerberos
- 9 Configure NTP
- 10 Troubleshooting
- 11 Further Documentation
- 12 Report Your Success/Failure!
Since version 4.0, Samba can also act as a Domain Controller that is compatible with Microsoft Active Directory. This document explains how to set up Samba as an Active Directory Domain Controller. It also is the start for upgrading an existing Samba NT4-style domain to Samba AD.
If you are upgrading an existing Samba Active Directory Domain Controller, please consult your distribution upgrade procedure or refer to the Updating Samba HowTo.
We do not recommend using the Domain Controller as a file Server. This is due to issues with the winbind internal to the Domain Controller. The recommendation is to run separate file or Member Servers.
Whilst the Domain Controller seems capable of running as a full file server, it is suggested that organisations run a distinct file server to allow upgrades of each without disrupting the other. It is also suggested that medium-sized sites should run more than one DC. It also makes sense to have the DC's distinct from any file servers that may use the Domain Controllers. Also using distinct file Servers avoids the many issues with the winbind internal to the Active Directory Domain Controller.
Samba as an Active Directory Domain Controller requires at least version 4.0.0. But it's always recommended to use the latest stable version of Samba. It will contain fixes for bugs of previous releases and may contain improved Microsoft Active Directory compatibility and additional features. See the Samba Release Planning page for more details about the latest maintained versions and their Release Notes.
Below, we will be using the following configuration/settings:
Installation Directory: /usr/local/samba/ AD DC Hostname: DC1 AD DNS Domain Name: samdom.example.com Kerberos Realm: SAMDOM.EXAMPLE.COM NT4 Domain Name/NetBIOS Name: SAMDOM IP Address: 192.168.1.1 Server Role: Domain Controller (DC) Domain Admin Password: passw0rd Forwarder DNS Server: 192.168.1.254
Different Ways To Install
Always check the OS Requirements for dependencies and recommendations. Samba has its own LDAP and Kerberos implementation, using external LDAP and Kerberos server is not recommended.
You have a few options to install Samba:
- Build Samba yourself.
- Install binary distribution packages. Make sure, that you use a recent Samba installation with Active Directory Domain Controller capabilities!
- Install from SerNet Enterprise Samba package.
Take care when running Samba commands if you also have a previous version of Samba installed! To avoid inadvertently running the wrong version of a program, you should consider putting the „/usr/local/samba/bin/“ and „/usr/local/samba/sbin/“ directories at the beginning of your $PATH variable.
You can see what version of Samba and client tools, if any, is in your „$PATH“ variable by running:
# samba -V # smbclient -V
Provisioning The Samba Active Directory
Note (Migration): If you plan to migrate an existing Samba NT4 domain to Samba AD, you have to skip this step! See the Samba Classic Upgrade HowTo, instead.
Note (Adding additional Domain Controllers): If you already have an Active Directory and only want to join a new, additional Samba Domain Controller, you have to skip this step! See the Join a domain as a DC HowTo, instead.
When Samba sets up the first Domain Controller in a Domain, the provisioning creates an initial Active Directory database. Because of this, the provision command must be executed with root privileges, to be able to write to the installation directory and set the correct permissions on files and folders.
Before you start the provisioning, make yourself familiar with the parameters and options of „samba-tool“:
# samba-tool domain provision --help
If your future Domain Controller has multiple NICs, the following two options are required. This is because „samba-tool“ would auto-choose one of the IPv4/IPv6 addresses if multiple interfaces were found, therefore it is necessary to bind Samba to the desired interfaces using
--option="interfaces=lo eth0" --option="bind interfaces only=yes"
Interactively provision a new domain (parameter explanation below):
# samba-tool domain provision --use-rfc2307 --interactive Realm [SAMDOM.EXAMPLE.COM]: SAMDOM.EXAMPLE.COM Domain [SAMDOM]: SAMDOM Server Role (dc, member, standalone) [dc]: dc DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: SAMBA_INTERNAL DNS forwarder IP address (write 'none' to disable forwarding) [192.168.1.1]: 192.168.1.254 Administrator password: passw0rd Retype password: passw0rd Looking up IPv4 addresses Looking up IPv6 addresses No IPv6 address will be assigned Setting up share.ldb Setting up secrets.ldb Setting up the registry Setting up the privileges database Setting up idmap db Setting up SAM db Setting up sam.ldb partitions and settings Setting up sam.ldb rootDSE Pre-loading the Samba 4 and AD schema Adding DomainDN: DC=samdom,DC=example,DC=com Adding configuration container Setting up sam.ldb schema Setting up sam.ldb configuration data Setting up display specifiers Modifying display specifiers Adding users container Modifying users container Adding computers container Modifying computers container Setting up sam.ldb data Setting up well known security principals Setting up sam.ldb users and groups Setting up self join Adding DNS accounts Creating CN=MicrosoftDNS,CN=System,DC=samdom,DC=example,DC=com Creating DomainDnsZones and ForestDnsZones partitions Populating DomainDnsZones and ForestDnsZones partitions Setting up sam.ldb rootDSE marking as synchronized Fixing provision GUIDs A Kerberos configuration suitable for Samba 4 has been generated at /usr/local/samba/private/krb5.conf Setting up fake yp server settings Once the above files are installed, your Samba4 server will be ready to use Server Role: active directory domain controller Hostname: DC1 NetBIOS Domain: SAMDOM DNS Domain: samdom.example.com DOMAIN SID: S-1-5-21-2614513918-2685075268-614796884
--use-rfc2307: Enables the NIS extensions, they allow you to easily manage users/groups with the Windows tool Active Directory Users and Computers (ADUC), without manual counting UIDs/GIDs. It's recommended to enable this feature during the provisioning, there isn't any problem in not using it, but you may find that it becomes a requirement for you in the future and enabling it now, means that you do not have to manually add the Schema extension later. For further information about RFC2307, see the Using RFC2307 on a Samba DC HowTo.
--interactive: Start the interactive provisioning. The values in squared brackets are defaults that will be chose, if no input is made.
Realm: Kerberos Realm. It will also automatically be used as the Active Directory DNS domain name. The Realm always has to be in uppercase.
Domain: NT4/NetBIOS Domain Name. Usually the first part of the AD DNS domain name in uppercase.
Server Role: „dc“ for Domain Controller.
DNS backend: You have to decide here, to use the Internal DNS server or BIND9 as the DNS backend. The Internal DNS is default and the best choice for simple DNS requirements. It doesn't need any further action. For complex DNS requirements, BIND9_DLZ is recommended. Don't use BIND9_FLATFILE! It's not documented or supported! See DNS Backend BIND for further information about using BIND. The DNS backend choice made during the provisioning isn't permanent. It can be changed afterwards.
DNS forwarder IP address: You are only prompted for this if you chose the Internal DNS as the backend. It defines the IP address of one DNS server, to which DNS queries should be forwarded to when your DNS server isn't authoritative. Commonly it is your providers DNS server IP address.
Note: You should always use a subdomain of your domain name (e. g. samdom.example.com). Never use your domain name (example.com) for your Active Directory DNS domain, this will prevent problems accessing servers using that name (e. g. web server), but resolving to different IPs than your Domain Controllers!
Administrator password: The Domain Administrators password. It must meet the complex password requirements:
- At least 8 characters
- Containing three of the following four character groups
- Uppercase letters
- Lowercase letters
- Symbols (all keyboard characters not defined as letters or numerals)
If the password doesn't fulfil the complexity requirements, the provisioning will fail and you will have to start over (remove the „smb.conf“in that case).
Testing Your Samba Domain Controller
Note: If you are running any „smbd“, „nmbd“ or „winbindd“ processes from previous installations, they need to be stopped before starting „samba“ from your new installation!
To start the Samba Active Directory Domain Controller in „standard“ mode, which is suitable for production use, run
Samba doesn't yet have init scripts included. You can find examples on the Samba Init-Script page.
Run „smbclient“, to check if Samba provides the AD DC default shares „netlogon“ and „sysvol“ created in your „smb.conf“ during provisioning/upgrading:
$ smbclient -L localhost -U% Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.x.y] Sharename Type Comment --------- ---- ------- netlogon Disk sysvol Disk IPC$ IPC IPC Service (Samba 4.x.y) Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.x.y] Server Comment --------- ------- Workgroup Master --------- -------
To test that authentication is working, you should try to connect to the „netlogon“ share, using the Domain Administrator account, created during provisioning:
$ smbclient //localhost/netlogon -UAdministrator -c 'ls' Enter Administrator's password: passw0rd Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.x.y] . D 0 Sat Jul 5 08:40:00 2014 .. D 0 Sat Jul 5 08:40:00 2014 49386 blocks of size 524288. 42093 blocks available
If the tests fail, check out the Samba AD DC Troubleshooting page.
A working DNS is essential to the correct operation of Active Directory. E. g. without the right DNS entries, Kerberos won't work, which in turn means that many of the basic features won't work! It is worth spending some extra time ensuring your DNS setup is correct, as debugging problems caused by incorrect DNS configuration, can take a lot of time later.
For additional information on the supported DNS backends and as a decision aid to help choose which fits best to your needs, see the DNS page.
Samba Internal DNS Server
By default Samba uses its Internal DNS and no further configuration is required. The forwarder was already set during the provisioning and can be changed in your „smb.conf“ (reload of „samba“ is required after changes).
BIND9 DNS Backend
If you chose „BIND9_DLZ“ during your provisioning, see the Bind as DNS backend documentation for additional setup instructions.
Your Domain Controller requires a name server that knows your AD zone to resolve Active Directory DNS queries correctly. To accomplish this, you can add just your AD DCs IP and domain name to your „/etc/resolv.conf“:
domain samdom.example.com nameserver 192.168.1.1
Note: If your server is set up to receive its IP configuration via DHCP, the „/etc/resolv.conf“ file might be automatically updated. Refer to your distributions documentation on how to stop/change this behavior, although DHCP is not recommended on a DC!
To test that DNS is working properly, run the following commands and compare the output to what is shown:
$ host -t SRV _ldap._tcp.samdom.example.com. _ldap._tcp.samdom.example.com has SRV record 0 100 389 dc1.samdom.example.com.
$ host -t SRV _kerberos._udp.samdom.example.com. _kerberos._udp.samdom.example.com has SRV record 0 100 88 dc1.samdom.example.com.
$ host -t A dc1.samdom.example.com. dc1.samdom.example.com has address 192.168.1.1
If you receive any errors, check your system logs to locate the problem.
Kerberos is an important part of Active Directory. Typically the configuration is done in /etc/krb5.conf. During provisioning, a working sample configuration will be created. You can replace your krb5.conf file with the sample by copying or creating a symlink:
# ln -sf /usr/local/samba/private/krb5.conf /etc/krb5.conf
Use „kinit“ to obtain a Kerberos ticket:
# kinit administrator@SAMDOM.EXAMPLE.COM Password for administrator@SAMDOM.EXAMPLE.COM: Warning: Your password will expire in 41 days on Sat Aug 16 21:41:28 2014
Note: You must specify your realm in uppercase letters!
Note: Depending on your distribution, „kinit“ may just return you to a prompt when successful.
To verify that Kerberos is working and that you had received a ticket, run:
# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: administrator@SAMDOM.EXAMPLE.COM Valid starting Expires Service principal 07/05/14 23:20:17 07/06/14 09:20:17 krbtgt/SAMDOM.EXAMPLE.COM@SAMDOM.EXAMPLE.COM renew until 07/06/14 23:20:15
Note: NTP is optional, but highly recommended!
Active Directory requires an accurate time synchronization between all participant machines for Kerberos to work properly. It's highly recommended to use NTP or another form of time synchronization on your Domain Controller!
The Time Synchronisation documentation will provide all neccessary information for configuring NTP on Domain Controllers, Member Servers and clients.
If you encounter any problems when using the documentation, see the Samba AD DC Troubleshooting page.
The Samba Wiki provides a lot of useful documentation on administering your DC, (backup and recovery, setup and configure file shares, etc.), daily work (join a Windows client to a Domain, installing RSAT on Windows for AD Management, etc.) or authenticating other services against AD.
See the Samba Wiki user documentation for many other HowTos, tutorials and information.
Report Your Success/Failure!
Suggestions on improving the documentation has the same importance as reporting Bugs and complications.