Difference between revisions of "Setting up Samba as an Active Directory Domain Controller"

m (Fix link)
(Major revision of the AD DC HowTo. Adding command output examples, reformatting, removing unnecessary (old) information, adding comments, being more detailed, etc.)
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
  
This document explains how to set up Samba (4.0+) as a simple Domain Controller that is compatible with Microsoft's Active Directory, for use particularly by Microsoft Windows clients that are joined to the Active Directory domain, for services such as Domain Logon. We refer to this capability as being an AD DC for short.  
+
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 AD DC, please consult your distribution upgrade procedure or refer to the [[Build_Samba#Upgrading_a_source_version|upgrading a source version]] HowTo.
+
If you are upgrading an existing Samba Active Directory Domain Controller, please consult your distribution upgrade procedure or refer to the [[Updating_Samba|Updating Samba]] HowTo.
 +
 
 +
If you encounter any problems when using the HowTo, see the [[#Troubleshooting|Troubleshooting]] section.
  
  
Line 11: Line 13:
 
= Versions =
 
= Versions =
  
This HowTo is frequently updated to reflect the latest changes. Please see the [[Samba_Release_Planning|Samba Release Planning]] for more specifics.
+
Samba as an Active Directory Domain Controller requires at least version 4.0.0. But it's always <u>recommended to use the latest version</u> 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|Samba Release Planning]] page for more details about the latest maintained versions and their Release Notes.
  
Please review the release notes for the version you have installed. It may contain important information, not yet reflected in this HowTo.
 
  
  
  
  
 +
= Server Information =
  
= Installing Samba =
+
Below, we will be using the following configuration/settings:
  
== Different ways to install ==
+
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:            pa$$w0rd
 +
 +
Forwarder DNS Server:              192.168.1.254
  
You have a few options to install Samba:
 
  
* [[Build_Samba| Build Samba]] by yourself.
 
  
* Install from your [[Binary_Distribution_Packages|distribution package manager]].
 
  
* Install from [http://www.enterprisesamba.com/samba/ SerNet Enterprise Samba] package.
 
  
See [[OS_Requirements|OS Requirements]] for dependencies and recommendations.
+
= Installation =
  
 +
== Different Ways To Install ==
  
 +
'''Always check the [[OS Requirements|OS Requirements]] for dependencies and recommendations.'''
  
== Paths ==
 
  
Take care when running Samba commands, if you also have a previous version of Samba installed.  To avoid inadvertently running the wrong version, you should consider putting the <tt>/usr/local/samba/bin/</tt> and <tt>/usr/local/samba/sbin/</tt> directories in the beginning of your <tt>$PATH</tt> variable!
+
You have a few options to install Samba:
  
You can see what version of Samba, if any, is in your <tt>PATH</tt> variable by running:
+
* [[Build_Samba|Build Samba]] by yourself.
# samba -V
 
  
 +
* Install [[Binary_Distribution_Packages|binary distribution packages]]. Make sure, that you use a recent Samba installation with Active Directory Domain Controller capabilities!
  
 +
:* Install from [http://www.enterprisesamba.com/samba/ SerNet Enterprise Samba] package.
  
== Server information ==
 
  
For the rest of this HowTo, we will be using the following configuration/settings for our example AD DC:
 
  
Installation Directory: /usr/local/samba/
+
== Paths ==
Server Hostname:        DC1
 
DNS Domain Name:        samdom.example.com (This will also be your realm)
 
NT4 Domain Name:        samdom
 
IP Address:            192.168.1.1
 
Server Role:            DC
 
  
 +
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 <u>beginning of your $PATH variable</u>.
  
  
== Provisioning Samba (Setting up a new domain) ==
+
You can see what version of Samba and client tools, if any, is in your „$PATH“ variable by running:
  
Provisioning creates a basic database, and is only done when you configure your first Samba DC in its own domain. Once your domain is up and running and you want to add another Samba server as an additional domain controller, then please see the [[Join_a_domain_as_a_DC|Join a domain as a DC]] HowTo.
+
# samba -V
 +
# smbclient -V
  
The user running the provision command must have permission to write to the install directory, otherwise you will get permission denied errors.
 
  
To interactively provision a new domain, run:
 
  
# /usr/local/samba/bin/samba-tool domain provision --use-rfc2307 --interactive
 
  
This will run the provision tool, asking you various questions about the setup you require, so it is recommended, before carrying out the provision, to run:
 
  
# samba-tool domain provision --help
+
= Provisioning The Samba Active Directory =
  
This will display all the available options, the main options are:
+
'''''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_(NT4-style_domain_to_AD)|Samba Classic Upgrade]] HowTo, instead.''
  
The --realm option sets the kerberos realm and is usually the DNS domain name i.e. samdom.example.com
+
'''''Note (Adding additional Domain Controllers):''' If you have already 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|Join a domain as a DC]] HowTo, instead.''
  
The --domain option sets the Domain name (this was/is also known as the 'workgroup' name) and is usually the first part of the DNS domain name in uppercase i.e. SAMDOM
 
  
The --adminpass option is where you set the main domain administrators password, This must be a complex password, at least eight characters long, containing at least one uppercase letter and at least one number 
+
The provisioning creates an initial Active Directory database, when setting up the first Samba Domain Controller in a Domain. It must be executed with root privileges, to be able to write to the installation directory and set the correct permissions on files and folders.
  
The --server-role option is where you can set what type of server role the DC will carry out, please set this to 'dc', this is the only role that is available at present, but there are plans to implement 'member server' and 'standalone' roles as soon as is practicable.
 
  
The --function-level is where to set what function level you require the domain to operate at, the default is 2003 Native but you can set it to 2000, 2003,
+
Before you start the provisioning, make yourself familiar with the parameters and options of „samba-tool“:
2008 or 2008_R2.
 
 
The --use-rfc2307 option sets your Samba AD to use posix attributes more effectively. It also adds NIS information to your AD, this allows you to administrate UIDs/GIDs and other Unix settings (on the "Unix attributes" tab in ADUC). It's easier to enable this feature during provisioning, rather than setting it up later and even if it is not required (yet), it will not affect your installation. For futher information about RFC2307, see the [[Using_RFC2307_on_a_Samba_DC|Using RFC2307 on a Samba DC]] HowTo.
 
  
You can also run the provision non-interactively by giving all the information required on the command line.
+
  # samba-tool domain provision --help
 
 
  # /usr/local/samba/bin/samba-tool domain provision --realm=samdom.example.com --domain=SAMDOM --adminpass=P4ssw0rd* --use-rfc2307 --server-role='dc'
 
 
 
One reason to re-run the provisioning is if the admin password you choose doesn't fulfill the password complexity requirements. In this case, the provisioning script fails and you have to start all over. Make sure the password contains at least one uppercase letter, one number and is at least eight characters in length.
 
  
Notes on multiple NICs:
 
  
If you are having multiple NICs, the provisioning process auto-chooses the IPv4/v6 address of one NIC to setup the Domain Controller. To prevent this, add the following two parameters the the classicupgrade command. This would bind Samba to the given
+
Expecially the following two options are required, if your future Domain Controllers have multiple NICs. Because „samba-tool“ would auto-choose one of the IPv4/IPv6 addresses, if multiple where found, it might be necessary to bind Samba to the desired interfaces using
interface (eth0) and localhost (Samba should always listen on localhost, too).
 
  
 
  --option="interfaces=lo eth0" --option="bind interfaces only=yes"
 
  --option="interfaces=lo eth0" --option="bind interfaces only=yes"
  
Important notes on the provisioning:
 
  
* As of Samba 4.0.0rc1 the provision command uses the Samba Internal DNS server by default. If you would like to use [[DNS_Backend_BIND|Bind as the DNS backend]], add --dns-backend=BIND9_DLZ to the provisioning command. It's possible to switch the DNS backend at any time afterwards. See: [[Changing_the_DNS_backend|Changing the DNS backend]].
+
Interactively provision a new domain (parameter explanation below):
  
* If you need to re-run the provisioning, you need to remove the /usr/local/samba/etc/smb.conf, you will also need to remove any generated samba database files:
+
# 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: ''pa$$w0rd''
 +
Retype password: ''pa$$w0rd''
 +
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
  
# rm -rf /usr/local/samba/etc/smb.conf /usr/local/samba/private/*
 
  
* If your website is example.com, the domain of your AD should be a subdomain of it, like samdom.example.com (or ad.example.com, corp.example.com). Avoid using example.com internally.
+
<u>Parameter explanations:</u>
  
  
 +
<u>--use-rfc2307:</u> Enables the NIS extensions, that allows to easily [[Using_RFC2307_on_a_Samba_DC#Administer_Unix_Attributes_in_Active_Directory|manage users/groups with the Windows tool Active Directory Users and Computers (ADUC)]], without manual counting UIDs/GIDs. It's recommented to enable this feature during the provisioning. Byside that it won't have any disadvantages if you don't use it, it may get a requirement in the future and prevent the necessity to manually do a Schema extension afterwards. For further information about RFC2307, see the [[Using_RFC2307_on_a_Samba_DC|Using RFC2307 on a Samba DC]] HowTo.
  
  
 +
<u>--interactive:</u> Start the interactive provisioning. The values in squared brackets are defaults, that will be choose, if no input was made.
  
== Classicupgrade (Migrating a Samba NT4-style domain to AD) ==
 
  
If you plan to migrate an existing Samba NT4 domain to Samba AD, see the [[Samba_Classic_Upgrade_(NT4-style_domain_to_AD)|Samba Classic Upgrade HowTo]].
+
<u>Realm:</u> Kerberos Realm. It will be automatically used as Active Directory DNS domain name, too. The Realm has always to be in uppercase.
  
  
 +
<u>Domain:</u> NT4/NetBIOS Domain Name. Usually the first part of the AD DNS domain name in uppercase.
  
== Starting Your Samba AD DC ==
 
  
'''Note: If you are running any <tt>smbd</tt>, <tt>nmbd</tt> or <tt>winbindd</tt> processes from previous installations, they need to be stopped before starting <tt>samba</tt> from your new installation!'''
+
<u>Server Role:</u> „dc“ for Domain Controller
  
If you are planning to run Samba as a production server, then simply run the binary as root:
 
  
# /usr/local/samba/sbin/samba
+
<u>DNS backend:</u> You have to decide here, to use the Internal DNS server or BIND9 as DNS backend. The Internal DNS is default and the best choice for simple DNS requirements. It doesn't need any further actions. For complex DNS requirements, BIND9_DLZ is recommended. Don't use BIND9_FLATFILE! It's not documented and supported! See [[DNS_Backend_BIND|DNS Backend BIND]] for further information about using BIND. The DNS backend choice made during the provisioning isn't permanent. [[Changing_the_DNS_backend|It can be changed afterwards]].
  
That will run Samba in 'standard' mode, which is suitable for production use. Samba doesn't yet have init scripts included for each platform, but writing one for your platform should not be
+
A „DNS forwarder IP address“ is only prompted, if you had choosen the Internal DNS as backend. It defines the IP address of one DNS server, to which DNS queries should be forwarded, when your DNS server isn't authoritative. Commonly it is your providers DNS server IP address.
difficult. There are some example scripts on the [[Samba4/InitScript|Samba4 Init-Script]] page.
 
  
If you are running Samba as a developer you may find the following more useful:
+
'''''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, to prevent problems accessing servers using that name (e. g. web server), but resolving to different IPs than your Domain Controllers!''
  
# /usr/local/samba/sbin/samba -i -M single
 
  
This will start Samba with all log messages printed to stdout, and restricting it to a single process. That mode of operation makes debugging Samba with gdb easier. To launch Samba under gdb, run as follows:
+
<u>Administrator password:</u> 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
 +
** Numerals
 +
** Symbols (all keyboard characters not defined as letters or numerals)
 +
If the password doesn't fulful the complexity requirements, the provisioning will fail and you have to start over (remove the „smb.conf“in that case).
  
# gdb --args /usr/local/samba/sbin/samba -i -M single
 
  
  
  
== Testing Connectivity to Your Samba AD DC ==
 
  
First check that you have the right version of <tt>smbclient</tt> by running:
+
= Testing Your Samba Domain Controller =
  
  $ /usr/local/samba/bin/smbclient --version
+
'''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!'''
  
This should show you a version starting with "Version 4.x".
+
To start the Samba Active Directory Domain Controller in „standard“ mode, which is suitable for production use, run
  
Now run this command to list the shares on your Samba server:
+
# samba
  
$ /usr/local/samba/bin/smbclient -L localhost -U%
 
 
        Sharename      Type      Comment
 
        ---------      ----      -------
 
        netlogon        Disk
 
        sysvol          Disk
 
        IPC$            IPC      IPC Service (Samba 4.x.y)
 
  
The output of the command should be similar to what is shown. The <tt>netlogon</tt> and <tt>sysvol</tt> shares are default shares needed for Active Directory server operation and created in your <tt>smb.conf</tt> during provisioning/upgrading.
+
Samba doesn't yet have init scripts included. You can find examples on the [[Samba4/InitScript|Samba Init-Script]] page.
  
If the command failed, restart samba:
 
  
# killall samba
+
Run „smbclient“, to check if Samba provides the AD DC default shares „netlogon“ and „sysvol“ created in your „smb.conf“ during provisioning/upgrading:
# /usr/local/samba/sbin/samba
 
  
To test that authentication is working, you should try to connect to the <tt>netlogon</tt> share, using the Administrator account created during provisioning. The output of the command should be similar to what is shown below:
+
  $ smbclient -L localhost -U%
 
+
Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.x.y]
  $ smbclient //localhost/netlogon -UAdministrator -c 'ls'
 
 
   
 
   
 +
        Sharename      Type      Comment
 +
        ---------      ----      -------
 +
        netlogon        Disk     
 +
        sysvol          Disk     
 +
        IPC$            IPC      IPC Service (Samba 4.x.y)
 
  Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.x.y]
 
  Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.x.y]
  .                                  D        0 Tue Dec 11 20:00:00 2012
+
   
  ..                                  D        0 Tue Dec 11 20:00:00 2012
+
        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:
  
== Configure DNS ==
+
$ smbclient //localhost/netlogon -UAdministrator -c 'ls'
 +
Enter Administrator's password: ''pa$$w0rd''
 +
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
  
A working DNS setup is essential to the correct operation of Samba and AD. 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 to ensure your DNS setup is correct, as debugging problems caused by mis-configured DNS can take a lot of time later on. To manage DNS entries the DNS MMC on a Windows client can be used, or samba-tool on Linux - see [[DNS Administration]] for more information.
 
  
 +
If the tests fail, check out the [[#Troubleshooting|Troubleshooting]] section.
  
  
=== DNS Backends ===
 
  
For additional information on the supported DNS backends and a decision aid, which fits best to your needs, see the [[DNS#Which_DNS_backend_should_I_choose.3F|DNS]] page.
 
  
  
 +
= Configure DNS =
  
==== Samba Internal DNS Server ====
+
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 to ensure your DNS setup is correct, as debugging problems caused by misconfigured DNS can take a lot of time later.
  
Per default Samba uses its Internal DNS and no further configuration is required.
 
  
Typically you want the DNS server to forward requests that it isn't responsible for. Simply add
 
dns forwarder = {IP-Address of the DNS you want to forward to}
 
to your <tt>smb.conf</tt> and restart Samba.
 
  
To enable the Internal DNS to start, port 53 udp/tcp must not be taken by any other program (like another DNS server, Dnsmasq, etc.). You'll see errors in your samba logfile, if Samba can't bind to port 53:
+
== DNS Backends ==
  
Failed to bind to 0.0.0.0:53 TCP - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED
+
For additional information on the supported DNS backends and a decision aid, which fits best to your needs, see the [[DNS#Which_DNS_backend_should_I_choose.3F|DNS]] page.
  
To check, which program is listening on port 53, run as root
 
  
# netstat -tunpe | grep ":53"
 
  
It should return only <tt>samba</tt> processes, bound to this port.
+
=== Samba Internal DNS Server ===
  
More information about troubleshooting can be found on the [[Samba_troubleshooting_temp|Samba Troubleshooting]] page.
+
Per 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).
  
  
  
==== BIND as DNS backend ====
+
=== BIND9 DNS Backend ===
  
If you chose <tt>BIND9_DLZ</tt> in your provisioning, see the [[DNS_Backend_BIND|Bind as DNS backend]] HowTo for additional setup instructions. There you will find much information on how to setup and configure Bind in general and how to configure it with Samba AD. If you provisioned your DC with the Internal DNS, you can [[DNS#Changing_from_Internal_DNS_to_BIND|switch to BIND]], whenever it's necessary.
+
If you had choosen „BIND9_DLZ“ during your provisioning, see the [[DNS_Backend_BIND|Bind as DNS backend]] documentation for additional setup instructions.
  
  
  
=== Configure /etc/resolv.conf ===
+
== Configure /etc/resolv.conf ==
  
For the local DNS lookups to resolve correctly, we need to modify the server's <tt>/etc/resolv.conf</tt>. The following example should be sufficient to have DNS resolve properly (adapt the domain and IP of your DC to your environment):
+
Your Domain Controller requires to resolve Active Directory DNS queries correctly. To accomplish this, it is necessary to add your AD DCs IP and domain name to your „/etc/resolv.conf“:
  
 
  domain samdom.example.com
 
  domain samdom.example.com
 
  nameserver 192.168.1.1
 
  nameserver 192.168.1.1
  
* Note: If your server is set up to receive its IP configuration via DHCP, the <tt>/etc/resolv.conf</tt> 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.
+
'''''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!''
  
  
  
=== Testing DNS ===
+
== Testing DNS ==
  
 
To test that DNS is working properly, run the following commands and compare the output to what is shown:
 
To test that DNS is working properly, run the following commands and compare the output to what is shown:
Line 239: Line 282:
 
  dc1.samdom.example.com has address 192.168.1.1
 
  dc1.samdom.example.com has address 192.168.1.1
  
The answers you get, should be similar to the ones above (adjusted for your domain name, hostname and IP). If you get any errors, carefully check your system logs to locate the problem.
+
 
 +
If you receive any errors, check your system logs to locate the problem.
 +
 
 +
 
  
  
  
== Configure Kerberos ==
+
= Configure Kerberos =
  
Kerberos configuration is handled by the <tt>krb5.conf</tt> file. This file is typically located in the <tt>/etc/</tt> directory. Please refer to your distribution documentation for the location of this file on your system.  There is a sample file created during provisioning located at <tt>/usr/local/samba/share/setup/krb5.conf</tt>, that is a suitable replacement for an existing file. Its default content is:
+
Kerberos is an important part of Active Directory. Typically the configuration is done in /etc/krb5.conf. During the provisioning, a working sample configuration was created. You can replace your krb5.conf file with the sample by copying or creating a symlink:
  
  [libdefaults]
+
  # ln -sf /usr/local/samba/share/setup/krb5.conf /etc/krb5.conf
        default_realm = ${REALM}
 
        dns_lookup_realm = false
 
        dns_lookup_kdc = true
 
  
* Note: If you have forgotten your realm, run <tt>samba-tool testparm --suppress-prompt | grep realm</tt>, to find it out.
 
  
  
 +
== Testing Kerberos ==
  
=== Testing Kerberos ===
+
Use „kinit“ to obtain a Kerberos ticket:
  
The simplest test is to use the <tt>kinit</tt> command as follows:
+
$ # 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
  
$ kinit administrator@SAMDOM.EXAMPLE.COM
+
'''''Note:''' You must specify your realm in uppercase letters!''
  
* Note: You must specify your domain realm in '''uppercase letters'''!
+
'''''Note:''' Depending on your distribution, „kinit“ may just return you to a prompt, when successful.''
  
* Note: Depending on your distribution, <tt>kinit</tt> may just return you to a prompt, however, some distributions may return something like <tt>Warning: Your password will expire in x days on ...</tt>
 
  
To verify that Kerberos is working, and that you received a ticket, run:
+
To verify that Kerberos is working and that you had received a ticket, run:
  
 
  $ klist
 
  $ klist
  Ticket cache: FILE:/tmp/krb5cc_1000
+
  Ticket cache: FILE:/tmp/krb5cc_0
 
  Default principal: administrator@SAMDOM.EXAMPLE.COM
 
  Default principal: administrator@SAMDOM.EXAMPLE.COM
 
+
 
  Valid starting    Expires            Service principal
 
  Valid starting    Expires            Service principal
  02/10/13 19:39:48 02/11/13 19:39:46 krbtgt/SAMDOM.EXAMPLE.COM@SAMDOM.EXAMPLE.COM
+
  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
 +
 
 +
 
 +
 
 +
 
 +
 
 +
= Configure NTP =
 +
 
 +
'''''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|Time Synchronisation]] documentation will provide all neccessary information for configuring NTP on Domain Controllers, Member Servers and clients.
 +
 
 +
 
 +
 
  
If either <tt>kinit</tt> or <tt>klist</tt> do not exist on your system, refer to [[OS_Requirements|OS Requirements]] on how to install the necessary packages.
 
  
You can also test Kerberos from a remote client, but you must first configure the client's <tt>krb5.conf</tt> and <tt>resolve.conf</tt> as shown previously.
+
= Further Documentation =
  
* Note: If you are using a client behind NAT then you have to add the following to the <tt>krb5.conf</tt> on the domain controller:
+
The Samba Wiki provides many useful [[User_Documentation|documentation]] on administering your DC, ([[Backup_and_Recovery|backup and recovery]], [[Setup_and_configure_file_shares_with_Windows_ACLs|setup and configure file shares]], etc.), daily work ([[Configuring_a_windows_client_for_AD|configuring a Windows client for AD]], [[Installing_RSAT_on_Windows_for_AD_Management|installing RSAT on Windows for AD Management]], etc.) or [[Authenticating_other_services_against_AD|authenticating other services against AD]].
  
[kdc]
 
        check-ticket-addresses = false
 
  
* Note: If provision generated a password and you forgot it or didn't save it in some way, you can use <tt>samba-tool user setpassword administrator</tt> as root to reset it.
+
See the [[User_Documentation|Samba Wiki user documentation]] for many further HowTos, tutorials and information.
  
  
  
== Configure NTP (Optional, but highly recommended) ==
 
  
Active Directory requires an accurate time synchronization between the clients and the DC(s). It's highly recommended to run NTP or another form of time synchronization.
 
  
The [[Time_Synchronisation|Time Synchronisation]] HowTo will provide all neccessary information for configuring NTP on a DC, Member Servers and Clients.
+
= Report Your Success/Failure! =
  
 +
We would encourage you to report your successes and failures to the [mailto:samba@lists.samba.org samba] mailing list on http://lists.samba.org.
  
 +
Suggestions on improving the documentation are the same important, as reporting [https://bugzilla.samba.org/ Bugs] and complications.
  
  
  
= Optional and Further Information =
 
  
The Samba Wiki provides you many useful further documentation on administrating your DC ([[Backup_and_Recovery|Backup and recovery]], [[Setup_and_configure_file_shares_with_Windows_ACLs|Setup and configure file shares]], etc.), daily work ([[Configuring_a_windows_client_for_AD|Configuring a windows client for AD]], [[Installing_RSAT_on_Windows_for_AD_Management|Installing RSAT on Windows for AD Management]], etc.) or [[Authenticating_other_services_against_AD|Authenticating other services against AD]].
 
  
Some thoughts on SELinux and discretionary access control permissions that can prevent login using AD users are on the [[Samba_AD_DC_access_control_settings|Samba AD DC Access Control Settings]] page.
+
= Troubleshooting =
 +
 
 +
== „samba“ or child processes don't start ==
 +
 
 +
Check out the [[Samba_port_usage#Port_usage_when_Samba_runs_as_DC|Samba port usage for a Domain Controller]] documentation and compare it with the output of
 +
 
 +
# netstat -tulpn | egrep "samba|smbd|nmbd|winbind"
 +
 
 +
If Samba isn't listening on all ports it should, check your Samba logs for further debugging.
 +
 
 +
 
 +
== Samba Internal DNS doesn't start ==
 +
 
 +
The Samba logfile shows
 +
 
 +
[2014/07/05 22:46:07.334864,  0] ../source4/smbd/service_stream.c:346(stream_setup_socket)
 +
  Failed to listen on 127.0.0.1:53 - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED
 +
 
 +
Make sure, that no other service is listening on port 53/udp and 53/tcp. Typically for this kind of problem is, that e. g. Dnsmask or a different DNS server is listening on this port. Check by using
 +
 
 +
# netstat -tulpn | grep ":53"
 +
 
 +
It should return only „samba“ processes, bound to this port, if using the Internal DNS.
 +
 
  
See the [[User_Documentation|Samba Wiki user documentation]] page for many further HowTos, tutorials and information.
 
  
 +
== kinit/klist don't exist on your system ==
  
 +
See [[OS Requirements|OS Requirements]].
  
  
  
= Report Your Success/Failure! =
+
== SELinux ==
  
We'd like to hear from users about their successes and failures. We would encourage you to report your successes and failures to the [mailto:samba@lists.samba.org samba] mailing list on http://lists.samba.org
+
Some thoughts on SELinux and discretionary access control permissions that can prevent login using AD users are on the [[Samba_AD_DC_access_control_settings|Samba AD DC Access Control Settings]] page.

Revision as of 23:31, 5 July 2014

Introduction

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.

If you encounter any problems when using the HowTo, see the Troubleshooting section.



Versions

Samba as an Active Directory Domain Controller requires at least version 4.0.0. But it's always recommended to use the latest 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.



Server Information

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:             pa$$w0rd

Forwarder DNS Server:              192.168.1.254



Installation

Different Ways To Install

Always check the OS Requirements for dependencies and recommendations.


You have a few options to install Samba:

  • Install binary distribution packages. Make sure, that you use a recent Samba installation with Active Directory Domain Controller capabilities!


Paths

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 have already 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.


The provisioning creates an initial Active Directory database, when setting up the first Samba Domain Controller in a Domain. It 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 


Expecially the following two options are required, if your future Domain Controllers have multiple NICs. Because „samba-tool“ would auto-choose one of the IPv4/IPv6 addresses, if multiple where found, it might be 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: pa$$w0rd
Retype password: pa$$w0rd
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


Parameter explanations:


--use-rfc2307: Enables the NIS extensions, that allows to easily manage users/groups with the Windows tool Active Directory Users and Computers (ADUC), without manual counting UIDs/GIDs. It's recommented to enable this feature during the provisioning. Byside that it won't have any disadvantages if you don't use it, it may get a requirement in the future and prevent the necessity to manually do a Schema extension afterwards. 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 choose, if no input was made.


Realm: Kerberos Realm. It will be automatically used as Active Directory DNS domain name, too. The Realm has always 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 DNS backend. The Internal DNS is default and the best choice for simple DNS requirements. It doesn't need any further actions. For complex DNS requirements, BIND9_DLZ is recommended. Don't use BIND9_FLATFILE! It's not documented and 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.

A „DNS forwarder IP address“ is only prompted, if you had choosen the Internal DNS as backend. It defines the IP address of one DNS server, to which DNS queries should be forwarded, 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, to 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
    • Numerals
    • Symbols (all keyboard characters not defined as letters or numerals)

If the password doesn't fulful the complexity requirements, the provisioning will fail and you 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


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: pa$$w0rd
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 Troubleshooting section.



Configure DNS

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 to ensure your DNS setup is correct, as debugging problems caused by misconfigured DNS can take a lot of time later.


DNS Backends

For additional information on the supported DNS backends and a decision aid, which fits best to your needs, see the DNS page.


Samba Internal DNS Server

Per 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 had choosen „BIND9_DLZ“ during your provisioning, see the Bind as DNS backend documentation for additional setup instructions.


Configure /etc/resolv.conf

Your Domain Controller requires to resolve Active Directory DNS queries correctly. To accomplish this, it is necessary to add 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!


Testing DNS

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.



Configure Kerberos

Kerberos is an important part of Active Directory. Typically the configuration is done in /etc/krb5.conf. During the provisioning, a working sample configuration was created. You can replace your krb5.conf file with the sample by copying or creating a symlink:

# ln -sf /usr/local/samba/share/setup/krb5.conf /etc/krb5.conf


Testing Kerberos

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



Configure NTP

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.



Further Documentation

The Samba Wiki provides many useful documentation on administering your DC, (backup and recovery, setup and configure file shares, etc.), daily work (configuring a Windows client for AD, installing RSAT on Windows for AD Management, etc.) or authenticating other services against AD.


See the Samba Wiki user documentation for many further HowTos, tutorials and information.



Report Your Success/Failure!

We would encourage you to report your successes and failures to the samba mailing list on http://lists.samba.org.

Suggestions on improving the documentation are the same important, as reporting Bugs and complications.



Troubleshooting

„samba“ or child processes don't start

Check out the Samba port usage for a Domain Controller documentation and compare it with the output of

# netstat -tulpn | egrep "samba|smbd|nmbd|winbind"

If Samba isn't listening on all ports it should, check your Samba logs for further debugging.


Samba Internal DNS doesn't start

The Samba logfile shows

[2014/07/05 22:46:07.334864,  0] ../source4/smbd/service_stream.c:346(stream_setup_socket)
  Failed to listen on 127.0.0.1:53 - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED

Make sure, that no other service is listening on port 53/udp and 53/tcp. Typically for this kind of problem is, that e. g. Dnsmask or a different DNS server is listening on this port. Check by using

# netstat -tulpn | grep ":53"

It should return only „samba“ processes, bound to this port, if using the Internal DNS.


kinit/klist don't exist on your system

See OS Requirements.


SELinux

Some thoughts on SELinux and discretionary access control permissions that can prevent login using AD users are on the Samba AD DC Access Control Settings page.