Starting with version 4.0, Samba is able to run as an Active Directory (AD) domain controller (DC). If you are installing Samba in an production environment, it is recommended to run two or more DCs for failover reasons.

+

Starting from version 4.0, Samba is able to run as an Active Directory (AD) domain controller (DC). If you are installing Samba in a production environment, it is recommended to run two or more DCs for failover reasons.

This documentation describes how to set up Samba as the first DC to build a new AD forest. Additionally, use this documentation if you are migrating a Samba NT4 domain to Samba AD. To join Samba as an additional DC to an existing AD forest, see [[Joining_a_Samba_DC_to_an_Existing_Active_Directory|Joining a Samba DC to an Existing Active Directory]].

This documentation describes how to set up Samba as the first DC to build a new AD forest. Additionally, use this documentation if you are migrating a Samba NT4 domain to Samba AD. To join Samba as an additional DC to an existing AD forest, see [[Joining_a_Samba_DC_to_an_Existing_Active_Directory|Joining a Samba DC to an Existing Active Directory]].

Line 7:

Line 7:

Samba as an AD DC only supports:

Samba as an AD DC only supports:

* the integrated LDAP server as AD back end. For details, see the frequently asked question (FAQ) [[FAQ#Does_Samba_AD_DCs_Support_OpenLDAP_or_Other_LDAP_Servers_as_Back_End.3F|Does Samba AD DCs Support OpenLDAP or Other LDAP Servers as Back End?]]

* the integrated LDAP server as AD back end. For details, see the frequently asked question (FAQ) [[FAQ#Does_Samba_AD_DCs_Support_OpenLDAP_or_Other_LDAP_Servers_as_Back_End.3F|Does Samba AD DCs Support OpenLDAP or Other LDAP Servers as Back End?]]

−

* the [http://www.h5l.se/ Heimdal] Kerberos key distribution center (KDC). The AD-compatible Heimdal KDC is included in Samba and automatically installed.

: Samba provides experimental support for the [https://web.mit.edu/kerberos/ MIT Kerberos] KDC provided by your operating system if you run Samba 4.7 or later and has been built using the <code>--with-system-mitkrb5</code> option. In other cases Samba uses the Heimdal KDC included in Samba. For further details about Samba using the MIT KDC, and why it is experimental see [[Running a Samba AD DC with MIT Kerberos KDC]].

−

+

= Preparing the Installation =

+

* Select a host name for your AD DC.

+

: Do not use NT4-only terms as host name, such as <code>PDC</code> or <code>BDC</code>. These modes do not exist in an AD and cause confusion.

−

= Preparing the Installation =

+

* Select a DNS domain for your AD forest. The name will also be used as the AD Kerberos realm.

−

−

* Select a DNS domain for your Active Directory (AD) forest. The name is additionally used as AD Kerberos realm.

: {{Imbox

: {{Imbox

| type = important

| type = important

−

| text = Make sure that you provision the AD using a DNS domain that does not change. Samba does not support renaming the AD DNS zone and Kerberos realm.

+

| text = Make sure that you provision the AD using a DNS domain that will not need to be changed. Samba does not support renaming the AD DNS zone and Kerberos realm. Do not use <code>.local</code> for the TLD, this is used by Avahi.

* Disable tools, such as <code>resolvconf</code>, that automatically update your <code>/etc/resolv.conf</code> DNS resolver configuration file. Active Directory (AD) DCs and domain members must use an DNS server that is able to resolve the AD DNS zones.

+

* Disable tools, such as <code>resolvconf</code>, that automatically update your <code>/etc/resolv.conf</code> DNS resolver configuration file. AD DCs and domain members must use an DNS server that is able to resolve the AD DNS zones.

* Verify that no Samba processes are running:

* Verify that no Samba processes are running:

Line 31:

Line 31:

* Verify that the <code>/etc/hosts</code> file on the DC correctly resolves the fully-qualified domain name (FQDN) and short host name to the LAN IP address of the DC. For example:

* Verify that the <code>/etc/hosts</code> file on the DC correctly resolves the fully-qualified domain name (FQDN) and short host name to the LAN IP address of the DC. For example:

−

127.0.0.1 localhost.localdomain localhost

+

127.0.0.1 localhost localhost.localdomain

10.99.0.1 DC1.samdom.example.com DC1

10.99.0.1 DC1.samdom.example.com DC1

:The host name and FQDN must not resolve to the <code>127.0.0.1</code> IP address or any other IP address than the one used on the LAN interface of the DC.

:The host name and FQDN must not resolve to the <code>127.0.0.1</code> IP address or any other IP address than the one used on the LAN interface of the DC.

−

* If you previously run a Samba installation on this host:

+

* If you previously ran a Samba installation on this host:

:* Remove the existing <code>smb.conf</code> file. To list the path to the file:

:* Remove the existing <code>smb.conf</code> file. To list the path to the file:

Line 49:

Line 49:

PRIVATE_DIR: /usr/local/samba/private/

PRIVATE_DIR: /usr/local/samba/private/

−

: Starting with a clean environment helps you to prevent confusion and no files from your previous Samba installation are mixed with your new domain DC installation.

+

: Starting with a clean environment helps to prevent confusion and ensures that no files from any previous Samba installation will be mixed with your new domain DC installation.

The Samba AD provisioning process creates the AD databases and adds initial records, such as the domain administrator account and required DNS entries.

If you are migrating a Samba NT4 domain to AD, skip this step and run the Samba classic upgrade. For details, see [[Migrating_a_Samba_NT4_Domain_to_Samba_AD_(Classic_Upgrade)|Migrating a Samba NT4 Domain to Samba AD (Classic Upgrade)]].

If you are migrating a Samba NT4 domain to AD, skip this step and run the Samba classic upgrade. For details, see [[Migrating_a_Samba_NT4_Domain_to_Samba_AD_(Classic_Upgrade)|Migrating a Samba NT4 Domain to Samba AD (Classic Upgrade)]].

Line 87:

Line 86:

{{Imbox

{{Imbox

| type = note

| type = note

−

| text = When provisioning a new AD, it is recommended to enable the NIS extensions by passing the <code>--use-rfc2307</code> parameter to the <code>samba-tool domain provision</code> command. This enables you to store Unix attributes in AD, such as user IDs (UID), home directories paths, group IDs (GID). Enabling the NIS extensions has no disadvantages not used. However, to enable them in an existing domain requires to manually extend the AD schema. For further details about Unix attributes in AD, see:

+

| text = When provisioning a new AD, it is recommended to enable the NIS extensions by passing the <code>--use-rfc2307</code> parameter to the <code>samba-tool domain provision</code> command. This enables you to store Unix attributes in AD, such as user IDs (UID), home directories paths, group IDs (GID). Enabling the NIS extensions has no disadvantages. However, enabling them in an existing domain requires manually extending the AD schema. For further details about Unix attributes in AD, see:

* [[Setting_up_RFC2307_in_AD|Setting up RFC2307 in AD]]

* [[Setting_up_RFC2307_in_AD|Setting up RFC2307 in AD]]

* [[Idmap_config_ad|idmap config = ad]]

* [[Idmap_config_ad|idmap config = ad]]

Line 96:

Line 95:

== Parameter Explanation ==

== Parameter Explanation ==

−

You have to set the following parameters during the provisioning process:

+

Set the following parameters during the provisioning:

{| class="wikitable"

{| class="wikitable"

Line 109:

Line 108:

|<code>Realm</code>

|<code>Realm</code>

|<code>--realm</code>

|<code>--realm</code>

−

|Kerberos realm. This is also used as the AD DNS domain. For example: <code>samdom.example.com</code>.

+

|Kerberos realm. The uppercase version of the AD DNS domain. For example: <code>SAMDOM.EXAMPLE.COM</code>.

|-

|-

|<code>Domain</code>

|<code>Domain</code>

|<code>--domain</code>

|<code>--domain</code>

−

|NetBIOS domain name. Always use the first part of the AD DNS domain. For example: <code>samdom</code>.

+

|NetBIOS domain name (Workgroup). This can be anything, but it must be one word, not longer than 15 characters and not containing a dot. It is recommended to use the first part of the AD DNS domain. For example: <code>samdom</code>. Do not use the computers short hostname.

|-

|-

|<code>Server Role</code>

|<code>Server Role</code>

Line 121:

Line 120:

|<code>DNS backend</code>

|<code>DNS backend</code>

|<code>--dns-backend</code>

|<code>--dns-backend</code>

−

|Sets the DNS back end. The first DC in an AD must be installed using a DNS back end. Note that the <code>BIND9_FLATFILE</code> is not supported and removed in a future Samba version.

+

|Sets the DNS back end. The first DC in an AD must be installed using a DNS back end. Note that the <code>BIND9_FLATFILE</code> is not supported and will be removed in a future Samba version.

|-

|-

|<code>DNS forwarder IP address</code>

|<code>DNS forwarder IP address</code>

Line 134:

Line 133:

Other parameters frequently used with the <code>samba-tool domain provision</code> command:

Other parameters frequently used with the <code>samba-tool domain provision</code> command:

* <code>--option="interfaces=lo eth0" --option="bind interfaces only=yes"</code>: If your server has multiple network interfaces, use these options to bind Samba to the specified interfaces. This enables the <code>samba-tool</code> command to register the correct LAN IP address in the directory during the join.

* <code>--option="interfaces=lo eth0" --option="bind interfaces only=yes"</code>: If your server has multiple network interfaces, use these options to bind Samba to the specified interfaces. This enables the <code>samba-tool</code> command to register the correct LAN IP address in the directory during the join.

+

+

+

{{Imbox

+

| type = note

+

| text = do NOT use <code>NONE</code> as the DNS backend, it is not supported and will be removed in a future Samba version.

+

}}

+

+

{{Imbox

+

| type = note

+

| text = If using Bind as the DNS backend, do NOT use <code>BIND9_FLATFILE</code>, it is not supported and will be removed in a future Samba version.

+

}}

+

+

{{Imbox

+

| type = important

+

| text = Once you have provisioned the first DC in an AD domain, do not provision any further DCs in the same domain, [[Joining_a_Samba_DC_to_an_Existing_Active_Directory|Join]] any further DCs.

+

}}

Line 139:

Line 154:

== Provisioning Samba AD in Interactive Mode ==

== Provisioning Samba AD in Interactive Mode ==

−

To provision a Samba Active Directory (AD) interactively, run:

+

To provision a Samba AD interactively, run:

# samba-tool domain provision --use-rfc2307 --interactive

# samba-tool domain provision --use-rfc2307 --interactive

Line 199:

Line 214:

== Provisioning Samba AD in Non-interactive Mode ==

== Provisioning Samba AD in Non-interactive Mode ==

−

For example, to provision a Samba Active Directory (AD) non-interactively with the following settings:

+

For example, to provision a Samba AD non-interactively with the following settings:

* Server role: <code>dc</code>

* Server role: <code>dc</code>

* NIS extensions enabled

* NIS extensions enabled

Line 215:

Line 230:

= Setting up the AD DNS back end =

= Setting up the AD DNS back end =

−

Skip this step if you provisioned the domain controller (DC) using the <code>SAMBA_INTERNAL</code> DNS back end.

+

Skip this step if you provisioned the DC using the <code>SAMBA_INTERNAL</code> DNS back end.

* Set up the BIND DNS server and the <code>BIND9_DLZ</code> module. For details, see [[Setting_up_a_BIND_DNS_Server|Setting up a BIND DNS Server]].

* Set up the BIND DNS server and the <code>BIND9_DLZ</code> module. For details, see [[Setting_up_a_BIND_DNS_Server|Setting up a BIND DNS Server]].

Line 228:

Line 243:

= Configuring the DNS Resolver =

= Configuring the DNS Resolver =

−

Domain members in an Active Directory (AD) use DNS to locate services, such as LDAP and Kerberos. For that, they need to use a DNS server, that is able to resolve the AD DNS zone.

+

Domain members in an AD use DNS to locate services, such as LDAP and Kerberos. For that, they need to use a DNS server that is able to resolve the AD DNS zone.

−

On your domain controller (DC), set the AD DNS domain in the <code>domain</code> and the IP of your DC in the <code>nameserver</code> parameter of the <code>/etc/resolv.conf</code> file. For example:

+

On your DC, set the AD DNS domain in the <code>domain</code> and the IP of your DC in the <code>nameserver</code> parameter of the <code>/etc/resolv.conf</code> file. For example:

If you need more than one reverse zone (multiple subnets), just run the above command again but with the data for the other subnet.

+

+

The reverse zone is directly live without restarting Samba or BIND.

Line 241:

Line 272:

= Configuring Kerberos =

= Configuring Kerberos =

−

In an Active Directory (AD), Kerberos is used to authenticate users, machines, and services.

+

In an AD, Kerberos is used to authenticate users, machines, and services.

+

+

During the provisioning, Samba created a Kerberos configuration file for your DC. Copy this file to your operating system's Kerberos configuration. For example:

−

During the provisioning, Samba created a Kerberos configuration file for your domain controller (DC). To use, remove your existing <code>/etc/krb5.conf</code> file and create a symbolic link to the pre-configured Kerberos configuration:

+

# cp /usr/local/samba/private/krb5.conf /etc/krb5.conf

−

# rm /etc/krb5.conf

+

{{Imbox

−

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

+

| type = important

+

| text = Do not create a symbolic link to the the generated <code>krb5.conf</code> file. In Samba 4.7 and later, the <code>/usr/local/samba/private/</code> directory is no longer accessible by other users than the <code>root</code> user. If the file is a symbolic link, other users are not able to read the file and, for example, dynamic DNS updates fail if you use the <code>BIND_DLZ</code> DNS back end.

Samba does not provide System V init scripts, <code>systemd</code>, <code>upstart</code>, or other services configuration files.

Samba does not provide System V init scripts, <code>systemd</code>, <code>upstart</code>, or other services configuration files.

* If you installed Samba using packages, use the script or service configuration file included in the package to start Samba.

* If you installed Samba using packages, use the script or service configuration file included in the package to start Samba.

−

* If you built Samba, see your distribution's documentation for how to create a script or configuration to start services. For user-created example System V init scripts, see [[Samba_AD_Init_Script_Examples|Samba AD Init Script Examples]].

+

* If you built Samba, see [[Managing_the_Samba_AD_DC_Service|Managing the Samba AD DC Service]].

To verify that your AD DNS configuration works correctly, query some DNS records:

−

* The tcp-based <code>_ldap</code> service (SRV) resource record in the domain:

+

* The tcp-based <code>_ldap</code> SRV record in the domain:

$ host -t SRV _ldap._tcp.samdom.example.com.

$ host -t SRV _ldap._tcp.samdom.example.com.

Line 350:

Line 385:

renew until 02.11.2016 08:44:59

renew until 02.11.2016 08:44:59

−

If you one or more tests fail, see [[#Troubleshooting|Troubleshooting]].

+

If one or more tests fail, see [[#Troubleshooting|Troubleshooting]].

Line 366:

Line 401:

= Using the Domain Controller as a File Server =

= Using the Domain Controller as a File Server =

−

The Samba Active Directory (AD) domain controller (DC) is able to provide file shares, such as all other installation modes. However, the Samba team does not recommend to use a DC as file server because the DC <code>smbd</code> process has some limitations compared with the service in non-DC setups. For example, the auto-enabled <code>acl_xattr</code> virtual file system (VFS) object enables you only to configure shares with Windows access control lists (ACL). Running shares with POSIX ACLs on a Samba DC is not supported. To provide network shares with the full capabilities of Samba, set up a Samba domain member with file shares. For details, see:

+

Whilst the Samba AD DC is able to provide file shares, just like all other installation modes, the Samba team does not recommend using a DC as a file server for the following reasons:

+

+

* For anything but the smallest organisations, having more than one DC is a really good backup measure, and makes upgrades safer

+

* It encourages upgrades of the DC to also be upgrades of the host OS every year or two, because there isn't complex data to transition or other services involved.

+

* This means upgrades can be done by installing fresh, and replicating in the changes, which is better tested in Samba, gains new features and avoids a number of lingering data corruption risks.

+

* The DC and file-server have different points at which an organisation would wish to upgrade. The needs for new features on the DC and file server come at different times. Currently the AD DC is evolving rapidly to gain features, whereas the fileserver, after over 20 years, is quite rightly more conservative.

+

* mandatory smb signing is enforced on the DC.

+

+

+

If you do decide to use the Samba DC as a fileserver, please consider running a VM, on the DC, containing a separate Samba Unix domain member and use this instead.

+

+

If you must use the Samba DC as a fileserver, you should be aware that the auto-enabled <code>acl_xattr</code> virtual file system (VFS) object enables you to only configure shares with Windows access control lists (ACL). Using POSIX ACLs with shares on a Samba DC does not work.

+

+

+

To provide network shares with the full capabilities of Samba, set up a Samba domain member with file shares. For details, see:

* [[Setting_up_Samba_as_a_Domain_Member|Setting up Samba as a Domain Member]]

* [[Setting_up_Samba_as_a_Domain_Member|Setting up Samba as a Domain Member]]

* [[Samba_File_Serving|Samba File Serving]]

* [[Samba_File_Serving|Samba File Serving]]

−

If you do not want to follow the Samba team's recommendation and use the DC additionally as a file server, configure <code>libnss_winbind</code> before you start setting up shares. For details, see [[Setting_up_Samba_as_a_Domain_Member#Configuring_the_Name_Service_Switch|Configuring the Name Service Switch]].

+

+

If you only have a small domain (small office, home network) and do not want to follow the Samba team's recommendation and use the DC additionally as a file server, configure Winbindd before you start setting up shares. For details, see [[Configuring_Winbindd_on_a_Samba_AD_DC|Configuring Winbindd on a Samba AD DC]].

+

+

+

{{Imbox

+

| type = important

+

| text = If you do use an AD DC as a fileserver, do not add any of the 'idmap config' lines used on a Unix domain member. They will not work and will cause problems.

+

}}

+

+

{{Imbox

+

| type = important

+

| text = If you do use an AD DC as a fileserver, You must set the permissions from Windows, do not attempt to use any of the old methods (force user etc) . They will not work correctly and will cause problems.

Introduction

Starting from version 4.0, Samba is able to run as an Active Directory (AD) domain controller (DC). If you are installing Samba in a production environment, it is recommended to run two or more DCs for failover reasons.

This documentation describes how to set up Samba as the first DC to build a new AD forest. Additionally, use this documentation if you are migrating a Samba NT4 domain to Samba AD. To join Samba as an additional DC to an existing AD forest, see Joining a Samba DC to an Existing Active Directory.

Samba provides experimental support for the MIT Kerberos KDC provided by your operating system if you run Samba 4.7 or later and has been built using the --with-system-mitkrb5 option. In other cases Samba uses the Heimdal KDC included in Samba. For further details about Samba using the MIT KDC, and why it is experimental see Running a Samba AD DC with MIT Kerberos KDC.

Preparing the Installation

Select a host name for your AD DC.

Do not use NT4-only terms as host name, such as PDC or BDC. These modes do not exist in an AD and cause confusion.

Select a DNS domain for your AD forest. The name will also be used as the AD Kerberos realm.

Make sure that you provision the AD using a DNS domain that will not need to be changed. Samba does not support renaming the AD DNS zone and Kerberos realm. Do not use .local for the TLD, this is used by Avahi.

Disable tools, such as resolvconf, that automatically update your /etc/resolv.conf DNS resolver configuration file. AD DCs and domain members must use an DNS server that is able to resolve the AD DNS zones.

Verify that no Samba processes are running:

# ps ax | egrep "samba|smbd|nmbd|winbindd"

If the output lists any samba, smbd, nmbd, or winbindd processes, shut down the processes.

Verify that the /etc/hosts file on the DC correctly resolves the fully-qualified domain name (FQDN) and short host name to the LAN IP address of the DC. For example:

The AD provisioning requires root permissions to create files and set permissions.

The samba-tool domain provision command provides several parameters to use with the interactive and non-interactive setup. For details, see:

# samba-tool domain provision --help

When provisioning a new AD, it is recommended to enable the NIS extensions by passing the --use-rfc2307 parameter to the samba-tool domain provision command. This enables you to store Unix attributes in AD, such as user IDs (UID), home directories paths, group IDs (GID). Enabling the NIS extensions has no disadvantages. However, enabling them in an existing domain requires manually extending the AD schema. For further details about Unix attributes in AD, see:

Parameter Explanation

Kerberos realm. The uppercase version of the AD DNS domain. For example: SAMDOM.EXAMPLE.COM.

Domain

--domain

NetBIOS domain name (Workgroup). This can be anything, but it must be one word, not longer than 15 characters and not containing a dot. It is recommended to use the first part of the AD DNS domain. For example: samdom. Do not use the computers short hostname.

Server Role

--server-role

Installs the domain controller DC role.

DNS backend

--dns-backend

Sets the DNS back end. The first DC in an AD must be installed using a DNS back end. Note that the BIND9_FLATFILE is not supported and will be removed in a future Samba version.

Other parameters frequently used with the samba-tool domain provision command:

--option="interfaces=lo eth0" --option="bind interfaces only=yes": If your server has multiple network interfaces, use these options to bind Samba to the specified interfaces. This enables the samba-tool command to register the correct LAN IP address in the directory during the join.

do NOT use NONE as the DNS backend, it is not supported and will be removed in a future Samba version.

If using Bind as the DNS backend, do NOT use BIND9_FLATFILE, it is not supported and will be removed in a future Samba version.

Once you have provisioned the first DC in an AD domain, do not provision any further DCs in the same domain, Join any further DCs.

If you need more than one reverse zone (multiple subnets), just run the above command again but with the data for the other subnet.

The reverse zone is directly live without restarting Samba or BIND.

Configuring Kerberos

In an AD, Kerberos is used to authenticate users, machines, and services.

During the provisioning, Samba created a Kerberos configuration file for your DC. Copy this file to your operating system's Kerberos configuration. For example:

# cp /usr/local/samba/private/krb5.conf /etc/krb5.conf

Do not create a symbolic link to the the generated krb5.conf file. In Samba 4.7 and later, the /usr/local/samba/private/ directory is no longer accessible by other users than the root user. If the file is a symbolic link, other users are not able to read the file and, for example, dynamic DNS updates fail if you use the BIND_DLZ DNS back end.

Configuring Time Synchronisation

Kerberos requires a synchronised time on all domain members. For further details and how to set up the ntpd service, see Time Synchronisation.

Using the Domain Controller as a File Server

Whilst the Samba AD DC is able to provide file shares, just like all other installation modes, the Samba team does not recommend using a DC as a file server for the following reasons:

For anything but the smallest organisations, having more than one DC is a really good backup measure, and makes upgrades safer

It encourages upgrades of the DC to also be upgrades of the host OS every year or two, because there isn't complex data to transition or other services involved.

This means upgrades can be done by installing fresh, and replicating in the changes, which is better tested in Samba, gains new features and avoids a number of lingering data corruption risks.

The DC and file-server have different points at which an organisation would wish to upgrade. The needs for new features on the DC and file server come at different times. Currently the AD DC is evolving rapidly to gain features, whereas the fileserver, after over 20 years, is quite rightly more conservative.

mandatory smb signing is enforced on the DC.

If you do decide to use the Samba DC as a fileserver, please consider running a VM, on the DC, containing a separate Samba Unix domain member and use this instead.

If you must use the Samba DC as a fileserver, you should be aware that the auto-enabled acl_xattr virtual file system (VFS) object enables you to only configure shares with Windows access control lists (ACL). Using POSIX ACLs with shares on a Samba DC does not work.

To provide network shares with the full capabilities of Samba, set up a Samba domain member with file shares. For details, see:

If you only have a small domain (small office, home network) and do not want to follow the Samba team's recommendation and use the DC additionally as a file server, configure Winbindd before you start setting up shares. For details, see Configuring Winbindd on a Samba AD DC.

If you do use an AD DC as a fileserver, do not add any of the 'idmap config' lines used on a Unix domain member. They will not work and will cause problems.

If you do use an AD DC as a fileserver, You must set the permissions from Windows, do not attempt to use any of the old methods (force user etc) . They will not work correctly and will cause problems.