Skip to main content

How to setup Active Directory in Linux using Samba4

Samba version 4 can work as a domain controller which is compatible with Microsoft Active Directory, companies can save licensing cost by switching to Samba4 for Active Directory. I will put below the complete steps.

Software Requirements:
1. A latest linux based operating system, I will be using Centos 7 for this example, you can use any flavor of linux 
2. We will be using Sernet Samba version 4.2, because the samba package provided in Centos 7 DVD uses MIT Kerberos which does not support Active Directory.

Hardware Requirements:
1. A system with at least 1 GB RAM for better performance, at least 10 GB of disk space and a decent processor
2. You can use a desktop class or server class system depending on choice

Download Links for required softwares:
1. Download Centos 7 DVD from the below link
    CentOS 7 DVD
2. Download Sernet Samba & other required rpm packages
    Sernet Samba 4.2 and other dependent packages for Sernet Samba

Installing Centos 7:
I will be using be a virtual machine on Citrix Xen Server, you can use a Physical machine or any other virtualisation platform of your choice.
1. Boot from the Centos 7 DVD (you can use any other boot methods of your choice instead of DVD) and follow the below steps:

Select Install Centos 7 and press enter



Choose your preferred language and click continue



Click on Software Selection and choose minimal install, also select compatibility libraries and development tools (Compatibility and Development Tools are not required to configure Active Directory, but it will useful if you want to compile any other software on this system in future).


Click on Network & Hostname to configure networking, I am not going enable  IPv6 for this setup, choose ignore in ipv6 Tab





Set root password of your choice



Let the installation complete and click on reboot.



When the system boots up login as root. Set system hostname, type vi /etc/hostname and press enter replace default hostname with the hostname and domain name of your choice.


Open /etc/hosts file and delete all lines except the below one


I will be disabling Firewall and Selinux to reduce complexity of this Active Directory Setup. Follow the below steps to disable firewall


Do this to disable selinux, Run vi /etc/selinux/config and type SELINUX=disabled


Now I will be installing the sernet samba packages. To make sernet samba rpm installation smooth I will be configure yum repository. Run mkdir /rpms and copy all rpm files from the Packages folder from the DVD. Upload the downloaded sernetsamba.zip file to this machine and extract it (you can upload the files from a pendrive or using sftp from another linux host). Copy the extracted rpm files to /rpms folder.




To configure a local YUM repository the createrepo software is necessary. Install createrepo rpm. Go to /rpms folder and run rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm  package name may vary on your dvd, install any dependent packages if needed for createrepo from the /rpms folder.


Once the createrepo package is installed run   createrepo -v /rpms


Remove  unnecessary yum repo files go to /etc/yum.repos.d/ and rename the unwanted repo files. And create a new local.repo file with the contents as shown below




Refresh yum repository list type yum repolist

Now our repository is ready and we can install the sernet samba packages, type yum install sernet\* and press enter.




DNS service is a necessity to run active directory. Samba4 has its own internal dns service which is enough to run your active directory, if you want more advanced dns service you can use bind as a dns service. To use bind as a dns service we need to install it. Type yum install bind bind-dyndb-ldap and press enter, it will install the bind and bind dyndb packages, do no install bind-chroot, because samba4 does not support it.


Now sernet-smaba has been installed and we are ready to provision our new linux based domain controller.

Run the command  samba-tool domain provision --use-rfc2307 --interactive as root and press enter, and choose the proper options of your choice. The first question is REALM, which is your domain name in capital letters, the command will choose it automatically just press enter, next is domain name, it will also be set automatically, press enter, choose the server role, in our case it will be dc, next choose dns backend, will be using SAMBA_INTERNAL, choose none for dns forwarder ip, type administrator password and remember it.



Set samba start mode in /etc/default/sernet-samba, type delete none and type ad on the line SAMBA_START_MODE and save the file. Run /etc/init.d/sernet-samba-ad start and press enter.





Kerberos is a necessary to run active directory, so we need to configure and check whether it is configured properly. Intall krb5-workstation package, run yum install krb5-workstation and press enter. Copy the /var/lib/samba/private/krb5.conf which has been created by samba-tool during our domain provisioning to /etc/krb5.conf.








Run "smbclient", to check if Samba provides the AD DC default shares "netlogon" and "sysvol", that were created in your "smb.conf" during provisioning/upgrading:


Type smbclient -L localhost -U% and press enter.



Now our domain controller is configured, try to join some windows client to this new domain controller.

Comments

Post a Comment

Popular posts from this blog

"samba-tool" to Manage a Linux based Active Directory

A linux based Active Directory server can be managed from a Windows client using the Remote System Administration Tool very easily, and it is the convenient way for system administrators with only Microsoft Windows background. But for administrators who love to use the command line,  "samba-tool" is a great command line tool to manage Active Directory configured on a Linux Box. Throughout this post and on my future posts I will be showing hands-on examples about using the  "samba-tool"  command. User Management using samba-tool Create a new user using samba-tool Syntax: samba-tool user create <username> [<password>] [options] samba-tool user create user1 password --given-name=firstname --surname=surname The above command will create a new user with the name as user1 and password will be password, you can type your desired password. The options --given-name and --surname are to assign user first name and surname. To make the user change ...

Managing a Linux based Domain Controller from a Windows Machine

On my last post I had demonstrated how to setup a Linux machine as Active Directory Domain Controller. On this post I will help you managing a Linux based domain controller from a Windows client machine. Most of the Active Directory administration tasks such as user & group creation, dns management cab be done using Samba server provided tool "samba-tool" , but for system administrators who has no experience working in a linux environment it can be a difficult task, even for experienced linux administrators it can be a bit time consuming to use "samba-tool" command for managing every active directory task. The Microsoft Remote System Administration Tool is a very nice software to manage a Linux based domain controller. Next I will help you downloading, installing and managing a Linux based domain controller from Windows client machine. I will be using a 64 bit Windows 7 pc for this example. RSAT Download Link: https://www.microsoft.com/en-in/download/det...