Join Linux CENTOS-7 to Microsoft Active Directory Domain.

First lets check our network interfaces by using this command:

[root@cetnos /]# ip addr

We can see that we get IP address 192.168.10.6 on interface ens33

So lets change this from DHCP to static IP and add the DNS servers, we do it by changing the interface config file.


[root@cetnos /]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

Please add the Marked lines to your network interface config file.

Now save it by using this command :qw!

Please reboot the server for changes will take effect.

After the system has finish to reboot we need to change one last thing before we join this machine to the domain, please open resolve.conf file by using this command:

[root@cetnos /]# vi /etc/resolv.conf

Make sure that you add your Domain name here and you have the IP address of your DNS servers, don’t forget to save it by using this command :qw!

Now after we finish, we can go on and join this machine to the Domain, we doing it by using this commands.

[root@cetnos /]# yum install sssd realmd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation openldap-clients policycoreutils-python -y
[root@centos ~]# realm join --user=administrator example.com
Password for administrator:

Once this has completed successfully, a computer object will be created in Active Directory in the default computers container as shown below.

Now that our Linux server is a member of the Active Directory domain we can perform some tests. we need to specify the domain name. For example with the ‘id’ command below,

[root@centos ~]# id administrator@example.com
uid=1829600500(administrator@example.com) gid=1829600513(domain users@example.com) groups=1829600513(domain users@example.com),1829600512(domain admins@example.com),1829600572(denied rodc password replication group@example.com),1829600519(enterprise admins@example.com),1829600518(schema admins@example.com),1829600520(group policy creator owners@example.com)

We can also SSH in as any domain user from Active Directory with default settings.

Leaving The Domain

If you want to reverse the process and remove yourself from the domain, simply run the ‘realm leave’ command followed by the domain name, as shown below.

[root@centos ~]# realm leave example.com

One thought on “Join Linux CENTOS-7 to Microsoft Active Directory Domain.

  1. Howdy! This is my first visit to your blog! We are a collection of volunteers and starting a new project in a community in the same niche. Your blog provided us useful information to work on. You have done a extraordinary job!

    Liked by 1 person

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.