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

(Added --use-rfc2307 and short explanation to the provisioning command)
(Refactoring the page. Adding notes, updating content, removing unnecessary topics and referring to the Wiki User documentation page instead. Making the page better readable and more compact.)
Line 1: Line 1:
= HOWTO to set up Samba as an Active Directory compatible Domain Controller =
+
= Introduction =
  
This document explains how to setup a simple Samba
+
This document explains how to setup a simple Samba server as a 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.  
server as a Domain Controller 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.  
 
  
== Video Demonstrations of This HOWTO ==
+
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.
  
A set of [[samba4/videos|demonstration videos]] is available that
 
may provide a useful overview of the contents of this HOWTO.
 
  
== A Note on Versions ==
 
  
Samba is developing rapidly. This HOWTO is frequently updated to reflect the latest changes in the Samba git repository. Please see the [[Release_Planning_for_Samba_4.0|Samba 4.0 Release Planning]] for more specifics on the release planning.
 
  
Please review the [[Samba4#Previous_Releases|Release Notes]] for the version you have installed, it may contain important information not yet reflected in this HOWTO.
 
  
== Installing Samba ==
+
= A note on versions =
  
You will either need to install samba from a your distributions package manager or [[Build_Samba| Build Samba]]. At this time the packages are generally older and very hard to support due to the rapid development of the samba project, so it is recommended to build from source.
+
Samba is developing rapidly. This HowTo is frequently updated to reflect the latest changes. Please see the [[Samba_Release_Planning|Samba Release Planning]] for 4.0 and later for more specifics.
  
=== Upgrading ===
+
Please review the release notes for the version you have installed. It may contain important information, not yet reflected in this HowTo.
  
If you are upgrading from a previous release of Samba 4.x, be sure to review all the [[Samba4#Previous_Releases|Release Notes]] for the new version, as well as the notes for all the interim versions.
 
  
If you are upgrading from source please refer to the [[Build_Samba#Upgrading_a_source_version|upgrading a source version]] otherwise please consult your distributions upgrade procedure.
 
  
== Server Information ==
 
For the rest of this tutorial, we will be using the following configuration for our example AD DC configuration.
 
  
  Installation Directory: /usr/local/samba
 
  Server Hostname: samba (Your linux hostname will be used here)
 
  DNS Domain Name: samdom.example.com (This will also be your '''realm''')
 
  NT4 Domain Name: samdom
 
  IP Address: 192.168.1.2
 
  Server Role: DC
 
  
== Step 1: Provision Samba ==
+
= Installing Samba =
  
The provision step sets up a basic user database, and is used when you are setting up your Samba
+
== Different ways to install ==
server in its own domain. If you instead want to setup your Samba server as an additional domain controller
 
in an existing domain, then please see the [[#Joining a Windows Domain Controller as an Additional DC in a Domain|Joining a Windows Domain Controller as an Additional DC in a Domain]] section on this page.  If you want to migrate an existing Samba 3.x domain to Samba 4.0 as an AD DC, see the [[#Migrating_an_Existing_Samba_Domain_to_Samba|Migrating an Existing Samba 3 Domain to Samba 4]] section on this page.
 
  
The provision step must be run as a user with permission to write to the install directory.
+
You're having two options to install Samba:
  
  # /usr/local/samba/bin/samba-tool domain provision --use-rfc2307
+
* [[Build_Samba| Build Samba]] by yourself.
  
This will run the provision tool interactively. For realm use something like <tt>samdom.example.com</tt>, for domain (it should suggest this) use <tt>samdom</tt>.
+
* Installation from your distribution package manager or e. g. [https://portal.enterprisesamba.com/ https://portal.enterprisesamba.com/].
  
The <tt>--use-rfc2307</tt> allows you to store posix attributes in your Active Directory, too. It e. g. enables user accounts having automatically the objectClass posixAccount added and you can administrate the unix extensions in ADUC.
 
  
If you run the previous command with a user who does not have write permission to the install directory, you will get an error similar to this:
 
tdb_open_ex: could not open file /usr/local/samba/private/sam.ldb.d/DC=SAMDOM,DC=EXAMPLE,DC=COM. ldb: Permission denied
 
  
You can pass options to <tt>samba-tool domain provision</tt> command. You can run it with the <tt>--help</tt> option to see a list of them.
 
  
* Note: As of Samba 4.0.0 RC1 the provision command now uses Samba's internal DNS server by default, if you would like to use [[Dns-backend_bind|Bind as DNS backend]], add <tt>--dns-backend=BIND9_DLZ</tt> to the above provision command.
 
* Note: You may need to remove the <tt>/usr/local/samba/etc/smb.conf</tt> file if you are re-running the provision command.
 
* Note: If you use the --adminpass='password' switch, be aware that there are password complexity requirements, so if you are getting some odd error with provision, try a more complex password ie. 'Pa$$w0rd'
 
* Note: If you have a "password complexity" failure during domain provisioning - read the following! The password complexity requirement is at least one uppercase letter, and one number, and at least eight characters long. If you don't use a complex enough password, the provision script will error, and  you will need to delete the /usr/local/samba/private and /usr/local/samba/etc directories, then run samba-tool domain provision again - with a better password.
 
  
== Step 2: Starting your Samba AD DC ==
+
== Pathes ==
  
If you are planning to run Samba as a production server, then just run the <tt>samba</tt> binary as root
+
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 can see what version of Samba, if any, is in your <tt>PATH</tt> variable by running:
 +
# samba -V
 +
 
 +
 
 +
 
 +
 
 +
 
 +
== 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/
 +
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
 +
 
 +
 
 +
 
 +
 
 +
 
 +
== Provisioning Samba (Setting up a new domain) ==
 +
 
 +
The provisioning creates a basic database, and is used when you are configuring your first Samba DC in its own domain. If you instead want to setup your Samba server as an additional domain controller in an existing domain, then please see the [[Samba4/HOWTO/Join_a_domain_as_a_DC|Joining a Windows Domain Controller as an additional DC in a Domain]] HowTo.
 +
 
 +
The provision step must be run as a user with permission to write to the install directory. Otherwise you're getting permission denied errors.
 +
 
 +
To provision a new domain, run:
 +
 
 +
# /usr/local/samba/bin/samba-tool domain provision --use-rfc2307
 +
 
 +
This will run the provision tool interactively. Because some settings can't be set interactively, it's recommended to run <tt>samba-tool domain provision --help</tt> and have a look at the additional possibilities.
 +
 
 +
The <tt>--use-rfc2307</tt> option enables your Samba AD automatically to store posix attributes. It also creates NIS information in the AD, that allows you to administrate UIDs/GIDs and other Unix settings (on the „Unix attributes“ tab in ADUC). It's easier if you enable this feature during provisioning, than setting this up later by hand. And even if you don't required it (yet), it's not affecting your installation.
 +
 
 +
'''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 DNS backend]], add <tt>--dns-backend=BIND9_DLZ</tt> to the provisioning command. This decission isn't final. You can [DNS#Changing_the_DNS_backend|switch the backend]] whenever it's necessary.
 +
 
 +
* If you re-run the provisioning, you need to remove the <tt>/usr/local/samba/etc/smb.conf</tt>!
 +
 
 +
* The admin password need to fulfill the password complexity requirements. This means at least one uppercase letter, one number, and at least eight characters length. If you don't use a complex enough password, the provision script will fail, and you will need to start over with a better password (remove <tt>/usr/local/samba/private/</tt> and <tt>/usr/local/samba/etc/</tt>).
 +
 
 +
 
 +
 
 +
 
 +
 
 +
== Classicupgrade (Migrating a Samba NT4-style domain to AD) ==
 +
 
 +
If you plan to migrate an existing Samba NT4 domain to Samba AD, see the [[Samba4/samba-tool/domain/classicupgrade/HOWTO|Classicupgrade HowTo]].
 +
 
 +
 
 +
 
 +
 
 +
 
 +
== 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!'''
 +
 
 +
If you are planning to run Samba as a production server, then simply run the binary as root:
  
 
  # /usr/local/samba/sbin/samba
 
  # /usr/local/samba/sbin/samba
  
That will run Samba in 'standard' mode, which is suitable for
+
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
production use. Samba doesn't yet have init scripts included
+
difficult. There are some example scripts on the [[Samba4/InitScript|Samba4 Init-Script]] page.
for each platform, but making one for your platform should not be
 
difficult. There are some example scripts (for RedHat/Fedora, Debian and Ubuntu) on the [[Samba4/InitScript]] page.
 
  
If you are running Samba as a developer you may find
+
If you are running Samba as a developer you may find the following more useful:
the following more useful:
 
  
 
  # /usr/local/samba/sbin/samba -i -M single
 
  # /usr/local/samba/sbin/samba -i -M single
  
This will start <tt>samba</tt> with all log messages printed to stdout, and restricting it to a
+
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:
single process. That mode of operation makes debugging <tt>samba</tt> with <tt>gdb</tt>
 
easier.  
 
  
If you want to launch it under <tt>gdb</tt>, run <tt>samba</tt> as follows:
+
# gdb --args /usr/local/samba/sbin/samba -i -M single
  
# gdb --args /usr/local/samba/sbin/samba -i -M single
 
  
Note that if you are running any Samba 3 <tt>smbd</tt> or <tt>nmbd</tt> processes
 
they need to be stopped before starting <tt>samba</tt> from Samba 4.
 
  
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 can see what version of Samba, if any, is in your <tt>PATH</tt> variable by running the following:
 
# samba -V
 
  
== Step 3: Testing connectivity to your Samba AD DC ==
+
== Testing connectivity to your Samba AD DC ==
  
First check you have the right version of <tt>smbclient</tt> by running the following command:
+
First check that you have the right version of <tt>smbclient</tt> by running:
  
 
   $ /usr/local/samba/bin/smbclient --version
 
   $ /usr/local/samba/bin/smbclient --version
  
This should show you a version starting with "Version 4.0.XXXXX".  
+
This should show you a version starting with "Version 4.x".  
  
 
Now run this command to list the shares on your Samba server:
 
Now run this command to list the shares on your Samba server:
  
 
  $ /usr/local/samba/bin/smbclient -L localhost -U%
 
  $ /usr/local/samba/bin/smbclient -L localhost -U%
 
+
The output of the command should be similar to what is shown below:
 
 
 
 
         Sharename      Type      Comment
 
         Sharename      Type      Comment
 
         ---------      ----      -------
 
         ---------      ----      -------
 
         netlogon        Disk
 
         netlogon        Disk
 
         sysvol          Disk
 
         sysvol          Disk
         IPC$            IPC      IPC Service (Samba 4.0.0)
+
         IPC$            IPC      IPC Service (Samba 4.x.y)
  
The <tt>netlogon</tt> and <tt>sysvol</tt> shares are basic shares needed for Active Directory server
+
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.
operation.  
 
  
If the command failed, restart samba by running the following:
+
If the command failed, restart samba:
  
 
  # killall samba
 
  # killall samba
 
  # /usr/local/samba/sbin/samba
 
  # /usr/local/samba/sbin/samba
  
To test that authentication is working, you should try to connect to the <tt>netlogon</tt> share
+
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:
using the Administrator password you set earlier:
+
 
 +
$ smbclient //localhost/netlogon -UAdministrator% -c 'ls'
 +
 +
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
  
$ smbclient //localhost/netlogon -UAdministrator%'p4$$word' -c 'ls'
 
  
The output of the command should be similar to what is shown below:
 
  
Domain=[SAMDOM] OS=[Unix] Server=[Samba 4.0.0]
 
  .                                  D        0  Wed Sep 12 21:00:36 2012
 
  ..                                  D        0  Wed Sep 12 21:02:28 2012
 
  
== Step 4: Configure DNS ==
 
  
A working DNS setup is essential to the correct operation of
+
== Configure DNS ==
Samba. Without the right DNS entries, Kerberos won't work, which in
 
turn means that many of the basic features of Samba 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
+
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.
lot of time later on.
 
  
For additional information on the DNS backends and a decission aid, which backend fits best to your needs, see the [[DNS|DNS]] page.
 
  
==== Samba's Internal DNS Server ====
 
  
If you specified <tt>--dns-backend=SAMBA_INTERNAL</TT> or did not specify any backend at all when you provisioned, there is no further setup required for the DNS server.
+
=== DNS backends ===
After you have dns configured, you still need to configure your <tt>/etc/resolv.conf</tt> as shown in [[#Configure /etc/resolv.conf|Configure /etc/resolv.conf]]
 
  
If you want the internal DNS server to forward requests it isn't responsible for, then add the following to your smb.conf:
+
For additional information on the supported DNS backends and a decission aid, which fits best to your needs, see the [[DNS#Which_DNS_backend_should_I_choose.3F|DNS]] page.
  dns forwarder = {IP-Address of the DNS you want to forward to}
 
  
'''Warning:''' If you are running X windows on your machine, networkmanager could be spawning dnsmasq or if you are using another DNS server, check the logs for lines like:
+
 
 +
 
 +
==== Samba Internal DNS Server ====
 +
 
 +
Per default Samba uses its Internal DNS and no further configuration is required.
 +
 
 +
Typically you want the DNS server to forward requests, it isn't resposible 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 an other DNS server, Dnsmasq, etc.). You'll see errors in your samba logfile, if Samba can't bind to port 53:
  
 
  Failed to bind to 0.0.0.0:53 TCP - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED
 
  Failed to bind to 0.0.0.0:53 TCP - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED
  
If you need to disable this you can open <tt>/etc/NetworkManager/NetworkManager.conf</tt> in your favorite editor as root, and comment out the line <tt>dns=dnsmasq</tt>, then <tt>restart network-manager</tt>
+
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.
 +
 
 +
More information about troubleshooting can be found on the [[Samba_troubleshooting_temp|Samba Troubleshooting]] page.
 +
 
 +
 
  
* More information about troubleshooting can be found on the [[Samba_troubleshooting_temp|Samba Troubleshooting]] page.
+
==== BIND as DNS backend ====
  
==== Bind as DNS backend ====
+
If you choosed <tt>BIND9_DLZ</tt> in your provision, see the [[Dns-backend_bind|Bind as DNS backend]] HowTo for additional setup instructions. There you will find many information how to setup and configure Bind in general and to work 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 used any other --dns-backend= option in your provision line see the detailed [[Dns-backend_bind|Bind as DNS backend]] HowTo for additional setup instructions. There you will find many information how to setup and configure Bind in general and to work with Samba 4.
 
  
If the internal DNS currently maybe doesn't provide all features you require, you should also think about Bind as DNS backend. Is a good choice, if you e. g. already have or plan to have a complex DNS, beside the zones that should be administrated through samba.
 
  
 
=== Configure /etc/resolv.conf ===
 
=== Configure /etc/resolv.conf ===
  
For all the local DNS lookups to resolve correctly, we need to modify the server's <tt>/etc/resolv.conf</tt> file. The following example should be sufficient to have DNS resolve properly:
+
For all 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 to your environment):
  
 
  domain samdom.example.com
 
  domain samdom.example.com
  nameserver 192.168.1.2
+
  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.
 +
 
  
*Note: Remember to change the IP Address to your Samba server's IP Address
 
*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 distribution's documentation on how to stop this behavior.
 
  
 
=== Testing DNS ===
 
=== Testing DNS ===
Line 184: Line 215:
  
 
  $ host -t A samba.samdom.example.com.
 
  $ host -t A samba.samdom.example.com.
  samba.samdom.example.com has address 10.0.0.1
+
  samba.samdom.example.com has address 192.168.1.1
  
The answers you get should be similar to the ones above (adjusted for your DNS domain name and hostname). If you get any errors,  
+
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.
carefully check your system logs to locate the problem.
 
  
== Step 5: 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 located at <tt>/usr/local/samba/share/setup/krb5.conf</tt> that is a suitable replacement for an existing file. This file is generated by provision and will look similar to the following:
+
 
 +
 
 +
 
 +
== 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:
  
 
  [libdefaults]
 
  [libdefaults]
    default_realm = SAMDOM.EXAMPLE.COM
+
        default_realm = ${REALM}
    dns_lookup_realm = false
+
        dns_lookup_realm = false
    dns_lookup_kdc = true
+
        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.
 +
 
  
*Note: If you have forgotten your realm, running <tt>samba-tool testparm --suppress-prompt | grep realm</tt> will let you know what you used.
 
  
 
=== Testing Kerberos ===
 
=== Testing Kerberos ===
Line 205: Line 241:
  
 
  $ kinit administrator@SAMDOM.EXAMPLE.COM
 
  $ kinit administrator@SAMDOM.EXAMPLE.COM
Password:
 
  
*Note: You must specify your domain realm <tt>SAMDOM.EXAMPLE.COM</tt> in '''uppercase letters'''
+
* Note: You must specify your domain realm in '''uppercase letters'''!
*Note: Depending on your distribution <tt>kinit</tt> may just return you to a prompt, however, some distributions may return something like '''Warning: Your password will expire in 41 days on Thu Mar 28 04:38:35 2013.'''
 
  
To verify that Kerberos is working, and that you received a ticket, run the following:
+
* 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:
  
 
  $ klist
 
  $ klist
Line 223: Line 259:
 
You can also test Kerberos form a remote client, but you must first configure the client's <tt>krb5.conf</tt> and <tt>resolve.conf</tt> as shown previously.
 
You can also test Kerberos form a remote client, but you must first configure the client's <tt>krb5.conf</tt> and <tt>resolve.conf</tt> as shown previously.
  
*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 server:
+
* 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:
  
 
  [kdc]
 
  [kdc]
    check-ticket-addresses = false
+
        check-ticket-addresses = false
 
 
*Note: If provision generated you a password and you forgot it or didn't get it saved in some way, you can use "samba-tool user setpassword administrator" as root to reset it.
 
  
== Configure NTP (Optional, but recommended) ==
+
* Note: If provision generated you a password and you forgot it or didn't get it saved in some way, you can use <tt>samba-tool user setpassword administrator</tt> as root to reset it.
Active Directory requires an accurate time syncronisation. That's why it's highly recommended to run NTP or an other way to sycronize the time. The [[Configure_NTP|Configure NTP]] page shows the full NTP configuration process including SELinux policies.
 
  
== Setup and configure a file share (Optional) ==
 
  
See the [[Setup_and_configure_file_shares|Setup and configure file shares]] HowTo.
 
  
== Samba as a Print Server ==
 
  
For a detailed description on that topic, see the [[Samba_as_a_print_server|Setup Samba as a Print Server]] HowTo.
 
  
= Configure a Windows Client to join our Samba Active Directory =
+
== Configure NTP (Optional, but highly recommended) ==
  
[[Configuring_a_windows_client_for_AD|Configuring a windows client to join our domain]] is useful when you need to start connecting windows clients.
+
Active Directory requires an accurate time syncronisation. That's why it's highly recommended to run NTP or an other way to sycronize the time. The [[Configure_NTP|Configure NTP]] page shows the full NTP configuration process including SELinux policies.
 
 
= Samba AD management =
 
 
 
You can manage your Samba AD just like a windows AD using the windows tools by using the following link [[Samba_AD_management_from_windows|Samba AD Management from windows]]
 
 
 
You may also want to use the linux command line, so you can [[Adding_users_with_samba_tool|add users with samba-tool]] as well.
 
 
 
= Joining a Windows Domain Controller as an Additional DC in a Domain =
 
  
Once you have a Samba domain controller set up, you can choose to join
 
additional domain controllers to the domain, whether they be
 
additional Samba domain controllers, or additional Windows domain
 
controllers.
 
  
If you wish to join an additional Samba domain controller to a domain,
 
then please see the [[Samba4/HOWTO/Join a domain as a DC|Joining a domain as a DC]] page. The instructions
 
on that page are the same for joining Samba to a Windows domain as
 
they are for joining Samba to an existing Samba domain.
 
  
If you wish to join a new Windows domain controller to a Samba domain,
 
then you should use the 'dcpromo' tool on the Windows machine. Please
 
see the normal instructions for installing dcpromo on Windows, with
 
the exception that you should not check the 'DNS server' option box
 
when it is offered. Right now you should either use Windows for DNS,
 
or use Samba and bind9 for DNS. Mixing the two can work, but it is an
 
advanced topic that is beyond the scope of this howto.
 
  
= Backup and Recovery of a Samba AD DC =
 
  
See the Samba [[Backup_and_Recovery|Backup and Recovery]] howto.
+
= Optional and further information =
  
= Migrating an Existing Samba Domain to Samba =
+
The Samba Wiki provides you many useful further documentation on administrating your DC ([[Backup_and_Recovery|Backup and recovery]], [[Setup_and_configure_file_shares|Setup and configure file shares]], etc.), daily work ([[Configuring_a_windows_client_for_AD|Configuring a windows client for AD]], [[Samba_AD_management_from_windows|Samba AD Management from windows]], etc.) or [[Authenticating_other_services_against_AD|Authenticating other services against AD]].
  
It is very likely that you already have a running Samba3 domain on your network.  The question is, how do you migrate that domain and all of its users and machines over to a new Samba 4 based domain without having to move every user profile and machine to the new domain?  The answer is the [[Samba4/samba-tool/domain/classicupgrade/HOWTO|samba-tool domain classicupgrade]] function.
+
See the [[Samba|Samba Wiki user documentation]] page for many further HowTos, tutorials and information.
  
= Connecting other services to your new/migrated Active Directory =
 
  
If you finished setting up or migrating to Samba 4, you maybe want to connect other services
 
to your new Active Directory. Have a look at the [[Authenticating_other_services_against_AD|Authenticating other services against AD]] page.
 
  
= Setup your firewall =
 
  
If you are setting up samba to work with your firewall, check out the [[Samba_port_usage|Samba port usage]] page.
 
  
 
= Report Your Success/Failure! =
 
= Report Your Success/Failure! =
  
Samba, as a replicating domain controller, is still developing rapidly.
+
Samba as a DC is still developing rapidly. 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-technical@lists.samba.org samba-technical] mailing list on http://lists.samba.org
We'd like to hear from users about their successes and
 
failures. We would encourage you to report both your successes and failures
 
to the [mailto:samba-technical@lists.samba.org samba-technical] mailing list on http://lists.samba.org
 

Revision as of 00:07, 17 July 2013

Introduction

This document explains how to setup a simple Samba server as a 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.

If you are upgrading an existing AD DC, please consult your distribution upgrade procedure or refer to the upgrading a source version HowTo.



A note on versions

Samba is developing rapidly. This HowTo is frequently updated to reflect the latest changes. Please see the Samba Release Planning for 4.0 and later for more specifics.

Please review the release notes for the version you have installed. It may contain important information, not yet reflected in this HowTo.



Installing Samba

Different ways to install

You're having two options to install Samba:



Pathes

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 /usr/local/samba/bin/ and /usr/local/samba/sbin/ directories in the beginning of your $PATH variable!

You can see what version of Samba, if any, is in your PATH variable by running:

# samba -V



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/
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



Provisioning Samba (Setting up a new domain)

The provisioning creates a basic database, and is used when you are configuring your first Samba DC in its own domain. If you instead want to setup your Samba server as an additional domain controller in an existing domain, then please see the Joining a Windows Domain Controller as an additional DC in a Domain HowTo.

The provision step must be run as a user with permission to write to the install directory. Otherwise you're getting permission denied errors.

To provision a new domain, run:

# /usr/local/samba/bin/samba-tool domain provision --use-rfc2307

This will run the provision tool interactively. Because some settings can't be set interactively, it's recommended to run samba-tool domain provision --help and have a look at the additional possibilities.

The --use-rfc2307 option enables your Samba AD automatically to store posix attributes. It also creates NIS information in the AD, that allows you to administrate UIDs/GIDs and other Unix settings (on the „Unix attributes“ tab in ADUC). It's easier if you enable this feature during provisioning, than setting this up later by hand. And even if you don't required it (yet), it's not affecting your installation.

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 Bind as DNS backend, add --dns-backend=BIND9_DLZ to the provisioning command. This decission isn't final. You can [DNS#Changing_the_DNS_backend|switch the backend]] whenever it's necessary.
  • If you re-run the provisioning, you need to remove the /usr/local/samba/etc/smb.conf!
  • The admin password need to fulfill the password complexity requirements. This means at least one uppercase letter, one number, and at least eight characters length. If you don't use a complex enough password, the provision script will fail, and you will need to start over with a better password (remove /usr/local/samba/private/ and /usr/local/samba/etc/).



Classicupgrade (Migrating a Samba NT4-style domain to AD)

If you plan to migrate an existing Samba NT4 domain to Samba AD, see the Classicupgrade HowTo.



Starting your Samba AD DC

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!

If you are planning to run Samba as a production server, then simply run the binary as root:

# /usr/local/samba/sbin/samba

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 difficult. There are some example scripts on the Samba4 Init-Script page.

If you are running Samba as a developer you may find the following more useful:

# /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:

# 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 smbclient by running:

 $ /usr/local/samba/bin/smbclient --version

This should show you a version starting with "Version 4.x".

Now run this command to list the shares on your Samba server:

$ /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 netlogon and sysvol shares are default shares needed for Active Directory server operation and created in your smb.conf during provisioning/upgrading.

If the command failed, restart samba:

# killall samba
# /usr/local/samba/sbin/samba

To test that authentication is working, you should try to connect to the netlogon share, using the Administrator account created during provisioning. The output of the command should be similar to what is shown below:

$ smbclient //localhost/netlogon -UAdministrator% -c 'ls'

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



Configure DNS

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.


DNS backends

For additional information on the supported DNS backends and a decission 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.

Typically you want the DNS server to forward requests, it isn't resposible for. Simply add

dns forwarder = {IP-Address of the DNS you want to forward to}

to your smb.conf and restart Samba.

To enable the Internal DNS to start, port 53 udp/tcp must not be taken by any other program (like an other DNS server, Dnsmasq, etc.). You'll see errors in your samba logfile, if Samba can't bind to port 53:

Failed to bind to 0.0.0.0:53 TCP - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED

To check, which program is listening on port 53, run as root

# netstat -tunpe | grep ":53"

It should return only samba processes, bound to this port.

More information about troubleshooting can be found on the Samba Troubleshooting page.


BIND as DNS backend

If you choosed BIND9_DLZ in your provision, see the Bind as DNS backend HowTo for additional setup instructions. There you will find many information how to setup and configure Bind in general and to work with Samba AD. If you provisioned your DC with the Internal DNS, you can switch to BIND, whenever it's necessary.


Configure /etc/resolv.conf

For all the local DNS lookups to resolve correctly, we need to modify the server's /etc/resolv.conf. The following example should be sufficient to have DNS resolve properly (adapt the domain and IP to your environment):

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.


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 samba.samdom.example.com.
$ host -t SRV _kerberos._udp.samdom.example.com.
_kerberos._udp.samdom.example.com has SRV record 0 100 88 samba.samdom.example.com.
$ host -t A samba.samdom.example.com.
samba.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.



Configure Kerberos

Kerberos configuration is handled by the krb5.conf file. This file is typically located in the /etc/ 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 /usr/local/samba/share/setup/krb5.conf, that is a suitable replacement for an existing file. Its default content is:

[libdefaults]
        default_realm = ${REALM}
        dns_lookup_realm = false
        dns_lookup_kdc = true
  • Note: If you have forgotten your realm, run samba-tool testparm --suppress-prompt | grep realm, to find it out.


Testing Kerberos

The simplest test is to use the kinit command as follows:

$ kinit administrator@SAMDOM.EXAMPLE.COM
  • Note: You must specify your domain realm in uppercase letters!
  • Note: Depending on your distribution, kinit may just return you to a prompt, however, some distributions may return something like Warning: Your password will expire in x days on ...

To verify that Kerberos is working, and that you received a ticket, run:

$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: administrator@SAMDOM.EXAMPLE.COM
 
Valid starting     Expires            Service principal
02/10/13 19:39:48  02/11/13 19:39:46  krbtgt/SAMDOM.EXAMPLE.COM@SAMDOM.EXAMPLE.COM

If either kinit or klist do not exist on your system, refer to Samba_4_OS_Requirements on how to install the necessary packages.

You can also test Kerberos form a remote client, but you must first configure the client's krb5.conf and resolve.conf as shown previously.

  • Note: If you are using a client behind NAT then you have to add the following to the krb5.conf on the domain controller:
[kdc]
        check-ticket-addresses = false
  • Note: If provision generated you a password and you forgot it or didn't get it saved in some way, you can use samba-tool user setpassword administrator as root to reset it.



Configure NTP (Optional, but highly recommended)

Active Directory requires an accurate time syncronisation. That's why it's highly recommended to run NTP or an other way to sycronize the time. The Configure NTP page shows the full NTP configuration process including SELinux policies.



Optional and further information

The Samba Wiki provides you many useful further documentation on administrating your DC (Backup and recovery, Setup and configure file shares, etc.), daily work (Configuring a windows client for AD, Samba AD Management from windows, etc.) or Authenticating other services against AD.

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



Report Your Success/Failure!

Samba as a DC is still developing rapidly. We'd like to hear from users about their successes and failures. We would encourage you to report your successes and failures to the samba-technical mailing list on http://lists.samba.org