Joining a Ubuntu Server DC to existing Samba AD DC directory is quite like building a AD DC but a little bit different at the end, namely joining and instead of building a AD DC. Here are my directions to building a Ubuntu 16.04 LTS server that I used for this post.

Note: When installing Ubuntu server I would recommend you also install openSSH Server with default Standard System Utilities in the Software Installation page. However do not install Samba File Server; if you do do an ” apt purge samba* ” before you actually install Samba from source.

I will be using this information for the Samba AD DC second server:

Samba Server: dc2
IP Address: 192.168.2.101
Netmask: 255.255.255.0
Default Gateway: 192.168.2.1
DNS1=192.168.2.100
DNS2=192.168.2.101
DNS3=192.168.2.1
DNS Domain Name: bales.lan
NetBIOS Domain Name: BALES
DNS Backend: SAMBA_INTERNAL

After Installing CentOS:

Using SSH with the root username, first update the server.

 apt update

Then upgrade.

apt dist-upgrade

Then disabled the firewall:

ufw disable

Reboot.

Prerequisite CentOS:

I changed the network.  Note that I put the first DNS of the first Samba AD DC of ‘dc1’ IP address, 192.168.2.100, so that the second server will be able to find it.

nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.2.101
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.100 192.168.2.101 192.168.2.1

Then I changed the /etc/hosts file to match the actual IP of my server (dc2):

27.0.0.1 localhost
192.168.2.101 dc2.bales.lan dc2
127.0.1.1 dc2

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

I then changed the path directory by adding’:/usr/local/samba/bin:/usr/local/samba/sbin’ a new file called samba-path.sh in the /etc/profile.d/ directory:

nano /etc/profile.d/samba-path.sh

PATH=${PATH}:/usr/local/samba/bin:/usr/local/samba/sbin

I also added the same to the secure_path to the /etc/sudoers file.

nano /etc/sudoers

...
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/samba/bin:/usr/local/samba/sbin"
...

Install the requirements/dependencies for Samba AD DC:

apt-get install acl attr autoconf bison build-essential debhelper dnsutils docbook-xml docbook-xsl flex gdb krb5-user libacl1-dev libaio-dev libattr1-dev libblkid-dev libbsd-dev libcap-dev libcups2-dev libgnutls28-dev libjson-perl libldap2-dev libncurses5-dev libpam0g-dev libparse-yapp-perl libpopt-dev libreadline-dev perl perl-modules pkg-config python-all-dev python-dev python-dnspython python-crypto xsltproc zlib1g-dev libsystemd-dev libgpgme11-dev python-gpgme python-m2crypto

Reboot.

Installing Samba and Joining the bales.lan:

Make a directory for samba and download the current samba file:

mkdir /samba
cd /samba
wget https://download.samba.org/pub/samba/stable/samba-4.6.1.tar.gz

Then I extract the file.

tar -zxf samba-4.6.1.tar.gz

Go to /samba/samba-4.6.1 directory and first configure Samba.

./configure

Then a make:

make

Then make install:

make install

Then lastly adding this 3 lines in /etc/krb5.conf:

[libdefaults]
    dns_lookup_realm = false
    dns_lookup_kdc = true
    default_realm = BALES.LAN

Reboot.

Time to join a Samba AD DC:

# samba-tool domain join bales.lan DC -U"BALES\administrator" --dns-backend=SAMBA_INTERNAL

Found DC dc1.bales.lan
Password for [WORKGROUP\administrator]:
workgroup is BALES
realm is bales.lan
checking sAMAccountName
Adding CN=DC2,OU=Domain Controllers,DC=bales,DC=lan
Adding CN=DC2,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=bales,DC=lan
Adding CN=NTDS Settings,CN=DC2,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=bales,DC=lan
Adding SPNs to CN=DC2,OU=Domain Controllers,DC=bales,DC=lan
Setting account password for DC2$
Enabling account
Calling bare provision
Looking up IPv4 addresses
Looking up IPv6 addresses
No IPv6 address will be assigned
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
A Kerberos configuration suitable for Samba 4 has been generated at /usr/local/samba/private/krb5.conf
Provision OK for domain DN DC=bales,DC=lan
Starting replication
Schema-DN[CN=Schema,CN=Configuration,DC=bales,DC=lan] objects[402/1550] linked_values[0/0]
Schema-DN[CN=Schema,CN=Configuration,DC=bales,DC=lan] objects[804/1550] linked_values[0/0]
Schema-DN[CN=Schema,CN=Configuration,DC=bales,DC=lan] objects[1206/1550] linked_values[0/0]
Schema-DN[CN=Schema,CN=Configuration,DC=bales,DC=lan] objects[1550/1550] linked_values[0/0]
Analyze and apply schema objects
Partition[CN=Configuration,DC=bales,DC=lan] objects[402/1614] linked_values[0/0]
Partition[CN=Configuration,DC=bales,DC=lan] objects[804/1614] linked_values[0/0]
Partition[CN=Configuration,DC=bales,DC=lan] objects[1206/1614] linked_values[0/0]
Partition[CN=Configuration,DC=bales,DC=lan] objects[1608/1614] linked_values[0/0]
Partition[CN=Configuration,DC=bales,DC=lan] objects[1614/1614] linked_values[28/0]
Replicating critical objects from the base DN of the domain
Partition[DC=bales,DC=lan] objects[97/97] linked_values[23/0]
Partition[DC=bales,DC=lan] objects[364/267] linked_values[23/0]
Done with always replicated NC (base, config, schema)
Replicating DC=DomainDnsZones,DC=bales,DC=lan
Partition[DC=DomainDnsZones,DC=bales,DC=lan] objects[40/40] linked_values[0/0]
Replicating DC=ForestDnsZones,DC=bales,DC=lan
Partition[DC=ForestDnsZones,DC=bales,DC=lan] objects[18/18] linked_values[0/0]
Committing SAM database
Sending DsReplicaUpdateRefs for all the replicated partitions
Setting isSynchronized and dsServiceName
Setting up secrets database
Joined domain BALES (SID S-1-5-21-2467930394-1560492651-202832562) as a DC

Start samba:

samba

Testing your new joined Centos2 domain controller:

Resolving your A record:

host -t A dc2.bales.lan

dc2.bales.lan has address 192.168.2.101

If it cannot resolve it then add it.

# samba-tool dns add dc1 bales.lan dc2 A 192.168.2.101 -Uadministrator

Password for [BALES\administrator]: *
Record added successfully

Resolve the objectGUID CNAME record:

# ldbsearch -H /usr/local/samba/private/sam.ldb '(invocationId=*)' --cross-ncs objectguid

# record 1
dn: CN=NTDS Settings,CN=DC1,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=bales,DC=lan
objectGUID: b490caa1-1fef-45ad-89b7-3a96c2666515

# record 2
dn: CN=NTDS Settings,CN=DC2,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=bales,DC=lan
objectGUID: c0754d24-ebaf-4cac-81b1-f28372e88bb6

# returned 2 records
# 2 entries
# 0 referrals

Then test for the CNAME for centos2:

# host -t CNAME c0754d24-ebaf-4cac-81b1-f28372e88bb6._msdcs.bales.lan

c0754d24-ebaf-4cac-81b1-f28372e88bb6._msdcs.bales.lan is an alias for dc2.bales.lan.

If not found add it:

# samba-tool dns add dc1 _msdcs.bales.lan c0754d24-ebaf-4cac-81b1-f28372e88bb6 CNAME dc2.bales.lan -Uadministrator
Password for [BALES\administrator]: *
Record added successfully

Add dns forwarder and rfc2307 is the smb.conf file:

# Global parameters
[global]
 workgroup = BALES
 realm = bales.lan
 netbios name = dc2
 server role = active directory domain controller
 dns forwarder = 192.168.2.1
 idmap_ldb:use rfc2307 = yes

[netlogon]
 path = /usr/local/samba/var/locks/sysvol/bales.lan/scripts
 read only = No

[sysvol]
 path = /usr/local/samba/var/locks/sysvol
 read only = No

Then check your servers are replicating. You should have all 0 consecutive failure(s) both inbound and outbound connections. It may take several minutes to complete though; if it doesn’t complete after 15 minutes do it manually with Microsoft OS.

# samba-tool drs showrepl

Default-First-Site-Name\DC2
DSA Options: 0x00000001
DSA object GUID: 83fcd92e-6909-4d05-937b-6e209b2e5a0b
DSA invocationId: 821cb161-f8a0-409f-9b0d-f5db0322e928

==== INBOUND NEIGHBORS ====

CN=Schema,CN=Configuration,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ Thu Feb 16 11:12:08 2017 PST was successful
 0 consecutive failure(s).
 Last success @ Thu Feb 16 11:12:08 2017 PST

DC=DomainDnsZones,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ Thu Feb 16 11:12:08 2017 PST was successful
 0 consecutive failure(s).
 Last success @ Thu Feb 16 11:12:08 2017 PST

CN=Configuration,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ Thu Feb 16 11:12:09 2017 PST was successful
 0 consecutive failure(s).
 Last success @ Thu Feb 16 11:12:09 2017 PST

DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ Thu Feb 16 11:12:08 2017 PST was successful
 0 consecutive failure(s).
 Last success @ Thu Feb 16 11:12:08 2017 PST

DC=ForestDnsZones,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ Thu Feb 16 11:12:08 2017 PST was successful
 0 consecutive failure(s).
 Last success @ Thu Feb 16 11:12:08 2017 PST

==== OUTBOUND NEIGHBORS ====

CN=Schema,CN=Configuration,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ NTTIME(0) was successful
 0 consecutive failure(s).
 Last success @ NTTIME(0)

DC=DomainDnsZones,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ NTTIME(0) was successful
 0 consecutive failure(s).
 Last success @ NTTIME(0)

CN=Configuration,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ NTTIME(0) was successful
 0 consecutive failure(s).
 Last success @ NTTIME(0)

DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ NTTIME(0) was successful
 0 consecutive failure(s).
 Last success @ NTTIME(0)

DC=ForestDnsZones,DC=bales,DC=lan
 Default-First-Site-Name\DC1 via RPC
 DSA object GUID: f0e7d041-e2ee-4ef2-b410-2a5cb7c5a93b
 Last attempt @ NTTIME(0) was successful
 0 consecutive failure(s).
 Last success @ NTTIME(0)

==== KCC CONNECTION OBJECTS ====

Connection --
 Connection name: 464de171-838d-4e0b-9c0d-60f271aff3f0
 Enabled : TRUE
 Server DNS name : dc1.bales.lan
 Server DN name : CN=NTDS Settings,CN=DC1,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=bales,DC=lan
 TransportType: RPC
 options: 0x00000001
Warning: No NC replicated for Connection!
[root@dc2 ~]#

If is everything is ok, you got a joined domain controller! If not, go to https://wiki.samba.org/index.php/Samba_AD_DC_Troubleshooting.

The DNS configuration on domain controllers (DC) is important, because if it is unable to locate other DCs the replication will fail. If it all works make sure for the DNS of the domain controller that they crosswise direction, like I did the second server.

References:

https://wiki.samba.org/index.php/Join_an_additional_Samba_DC_to_an_existing_Active_Directory

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s