{"id":220,"date":"2020-09-26T13:32:33","date_gmt":"2020-09-26T13:32:33","guid":{"rendered":"https:\/\/dft.wiki\/?p=220"},"modified":"2021-04-16T22:25:17","modified_gmt":"2021-04-16T22:25:17","slug":"linux-as-domain-controller-ad","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=220","title":{"rendered":"Linux as Active Directory \/ Domain Controller (AD-DC) Principal"},"content":{"rendered":"<p>This is how to create one Linux (Ubuntu 18.04 LTS) Domain Controller to work as a Windows Server Active Directory.<\/p>\n<p>Lets make few assumptions and clarify something before the start:<\/p>\n<p>Be aware that in some moments the domain or the machine name has to be in &#8216;<strong>UPPERCASE<\/strong>&#8216; and other moments in &#8216;<strong>lowercase<\/strong>&#8216;.<\/p>\n<p>For this example,<strong> we will use<\/strong> the domain &#8216;<strong>company.com<\/strong>&#8216; and the server will have the name &#8216;<strong>srv<\/strong>&#8216;.<\/p>\n<p>Start issuing the commands:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo passwd root\r\n<span data-offset-key=\"e176a894f29244fc836579077fee2a91:0\"><span class=\"prism-token token 2 function \">sudo hostnamectl set-hostname srv<\/span><\/span><\/pre>\n<p>At this point create one password for the user &#8216;<strong>root<\/strong>&#8216;, because you will have to proceed as &#8216;<strong>su<\/strong>&#8216; instead of the command &#8216;<strong>sudo<\/strong>&#8216;. Then switch to root user:<\/p>\n<pre>su\r\napt-get install samba krb5-config winbind net-tools smbclient -y<\/pre>\n<p>Three questions will popup. Answer the domain name in UPPERCASE:<\/p>\n<pre>COMPANY.COM<\/pre>\n<p>Than answer <strong>twice<\/strong> in <strong>lowercase<\/strong> the FQDN for the server of your domain:<\/p>\n<pre>srv.company.com<\/pre>\n<p>Issue the command below, but replace the IP &#8216;<strong>10.0.2.254<\/strong>&#8216; with your &#8216;<strong>srv<\/strong>&#8216; IP and domain name:<\/p>\n<pre>echo '10.0.4.254 srv srv.company.com' &gt;&gt; \/etc\/hosts<\/pre>\n<p>Issue the commands to start a new Samba configuration:<\/p>\n<pre>mv \/etc\/samba\/smb.conf \/etc\/samba\/smb.conf.bkp\r\nsamba-tool domain provision<\/pre>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-490\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-87.png\" alt=\"\" \/><\/figure>\n<p>Follow the steps from the image above. For the DNS Forward, we are going to use the Google Public DNS Server (&#8216;<strong>8.8.8.8<\/strong>&#8216;). Then set the password to the user &#8216;<strong>Administrator<\/strong>&#8216; of the Active Directory, and you may get the same result:<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-491\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-88.png\" alt=\"\" \/><\/figure>\n<p>Here the Samba configuration starts:<\/p>\n<pre>cp \/var\/lib\/samba\/private\/krb5.conf \/etc\/\r\nsystemctl disable --now smbd nmbd winbind systemd-resolved\r\nsystemctl unmask samba-ad-dc.service\r\nsystemctl enable --now samba-ad-dc.service\r\nsamba-tool domain level show<\/pre>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-482\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-85.png\" alt=\"\" \/><\/figure>\n<pre>rm \/etc\/resolv.conf\r\necho 'nameserver 127.0.0.1' &gt;&gt; \/etc\/resolv.conf<\/pre>\n<p>DONE! Now check that everything is working properly:<\/p>\n<p>Go to the client computer (Windows or Linux) and change the DNS server to the IP address of your server (in my example was <strong>10.0.2.254<\/strong>).<\/p>\n<p>Then go to the command prompt and try to ping &#8216;<strong>srv.company.com<\/strong>&#8216;, &#8216;<strong>company.com<\/strong>&#8216;, &#8216;<strong>srv<\/strong>&#8216;, and &#8216;<strong>google.com<\/strong>&#8216;.<\/p>\n<p>If all the ping were resolved and the pings went through, go ahead and try to join the computer to de domain.<\/p>\n<p>Now joining the computers to the domain and create users in the AD.<\/p>\n<p>Most popular commands of commands:<\/p>\n<pre>sudo samba-tool user list\r\nsudo samba-tool user create UserName\r\nsudo samba-tool user delete UserName\r\nsudo samba-tool user disable UserName\r\nsudo samba-tool user enable UserName\r\nsudo samba-tool user setpassword UserName\r\nsudo samba-tool user setexpiry UserName --days=30\r\nsudo samba-tool group list\r\nsudo samba-tool group listmembers GroupName\r\nsudo samba-tool group add GroupName\r\nsudo samba-tool group delete GroupName\r\nsudo samba-tool group addmembers GroupName UserName\r\nsudo samba-tool group removemembers GroupName UserName\r\nsudo samba-tool computer list<\/pre>\n<p>Few other commands for special requests:<\/p>\n<pre>sudo samba-tool group add \u2013h\r\nsudo samba-tool user add -h\r\nsudo samba-tool user add domainName --given-name=givenName --surname=surName --mail-address=userName@example.com --login-shell=\/bin\/bash\r\nsudo samba-tool domain passwordsettings show\r\nsudo samba-tool domain passwordsettings set -h\r\nsudo samba-tool gpo listall\r\nsudo samba-tool drs showrepl\r\nsudo samba-tool dns -help\r\nsudo samba-tool dns query 10.0.0.1 example.com zone A -U Administrator\r\nsudo samba-tool dns zonecreate domain.local 0.0.10.in-addr.arpa -U Administrator\r\nsudo samba-tool processes\r\nsudo samba-tool visualize ntdsconn\r\nsudo samba-tool visualize reps<\/pre>\n<p>Wouldn&#8217;t be complete without the\u00a0<strong>Remote Server Administration Tools for Windows 10<\/strong> [<a href=\"https:\/\/www.microsoft.com\/en-US\/download\/details.aspx?id=45520\">Link<\/a>].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is how to create one Linux (Ubuntu 18.04 LTS) Domain Controller to work as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=220"}],"version-history":[{"count":15,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":1955,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/220\/revisions\/1955"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}