Create an Active Directory Infrastructure with Samba4 on Ubuntu – Part 1

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

107 Responses

  1. Edson says:

    There is an error in this piece if you use ctrl+c and ctrl-v.

    $ host –t A tecmint.lan
    $ host –t A adc1.tecmint.lan
    $ host –t SRV _kerberos._udp.tecmint.lan  # UDP Kerberos SRV record

    It’s written with a "–" instead of a "-".

  2. Micha de Vries says:

    Hi, so, it all works fine on the server, though i cannot ping the domain on the client, how is that?
    (And yes i set the only dns server the the samba dc server)

    • Micha de Vries says:

      oh and the administrator account at the last step doesnt seem to exist

    • Peter Galgano says:

      Check the dns network settings of your client, maybe it doesn’t address the IP of the AD server. Set the first dns server and/or gateway address on the clients IP4 settings to address of the AD server. You may need to change your dhcp settings for the clients.

      • Peter Galgano says:

        Oh, and it is common that the Administrator password doesn’t seem to be set by provisioning. Use samba-tool to set a new password.

  3. Kai Wadsack says:

    Thanks for this really great tutorial. It’s by far the most comprehensive I could find on the web.
    Still it leaves one unanswered question to me:

    Is this a Ubuntu/Samba only solution or can we go a mixed way with one Windows Server based DC and an additional Ubuntu DC?

    Suppose you wanted to replace an existing Windows Server 2012 R2 based DC with an Ubuntu based DC, can we still follow the steps described in “Part 5: Join an Additional Ubuntu DC to Samba4 AD DC” and join the additional Ubuntu DC to the AD and later remove the Windows based DC from the domain?

    Or should we start from scratch? Too scared to try this out myself.

  4. Tony Mcmahon says:

    Has anyone done this on Ubuntu 18.04? Are any of the steps different?

    • Antonis Desillas says:

      I tried it some time ago. You have to use netplan ( instead of /etc/network/insterfaces. If i remember well, I could not get the ping to work because you cannot use resolv.conf and i didn’t get much further after that.

      • Rusty says:

        What I’ve done and am doing again now, is install and get everything running on 16.04 and then upgrade to 18.04. That seems to work. I’ve done it on two domain controllers without issue.

      • eks says:

        If you are using netplan, you can do this to get the dns servers set in the netplan config file.

        # unlink /etc/resolv.conf
        # ln -snf /var/run/systemd/resolve/resolv.conf /etc/
        • Peter Galgano says:

          I had a further problem related to netplan, that took a while to find.

          By default, systemd.resolved (a local dns caching service) takes port 53, so the internal dns in samba can’t start.

          I think it will be necessary to disable systemd.resolved from starting

  5. Thank you for the perfect tutorial! I had the same problems with DNS where I could not ping the server. I found out after a second installation attempt, that I should follow the steps exactly as mentioned here and at the Ubuntu server installation instructions and after that everything worked fine.

    On my first attempt I installed the Linux server without looking the installation instructions and I installed the system as per usual. So I pre-installed DNS and other features, encrypted my home folder, and did not interrupt the network detection process to enter the settings manually.

    I also skipped step 3 from this page. On the second attempt I just entered the same hostname as on the installation process. I think this, or the pre-installed DNS server caused the problem.

    I also found two typos:
    At step 11 sudo mv /etc/krb6.conf /etc/krb5.conf.initial should be sudo mv /etc/krb5.conf /etc/krb5.conf.initial and at step 11, it should be broadcast.

  6. HJ Z says:

    Great tutorial,

    I did this on a Debian 9.6. Most things worked fine.

    I had to systemctl unmask samba-ad-dc, and install net-tools.

    I checked with smbclient -L localhost %U – It puzzles me why does Workgroup always return WORKGROUP?

  7. Juston Griggs says:


    Great Document, however, everything works for up to Step 16, when I do the command:

    # ping –c3 goneoweb.local

    I get the error

    ping: unknown host –c3

    Here is my /etc/network/interfaces and my /etc/resolv.conf.

    iface eth0 inet static
            dns-search              goneoweb.local
    search goneoweb.local

    I’m kind of at a standstill. I’m in the process of setting this up for use with my small business, 3 computers, and 6 users. So any help would be greatly appreciated! Again, great article! Thanks

    • Cezar Matei says:

      Add 127…. to resolv.conf file. why you use the second nameserver. Is that a dc also? If not, leave only 127…8n both files.

      • Juston O Griggs says:

        The machine Im setting all this up on has a static of, so I dont need to reference that in the resolv.conf?

      • FauxKalEl says:

        Very good guide but still have a problem with step 16. I tried many things, but when using Ubuntu Server 18.04.2 (with alternative installer that is probably same as with standard 16.04), and configuring netplan, etc., i can’t ping domain.

        ping -c3 jakisserwer
        PING JakisSerwer.Business ( 56(84) bytes of data.
        ping -c3 jakis.lan
        ping: jakis.lan: Name or service not known


                default_realm = SPBYCHLEW.LAN
                dns_lookup_realm = false
                dns_lookup_kdc = true

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


        search jakis jakis.lan office


        # This file describes the network interfaces available on your system
        # For more information, see netplan(5).
          version: 2
          renderer: networkd
              dhcp4: no
              addresses: []
                  search: [jakis, jakis.lan]
                  addresses: [,]
  8. Michael Weber says:

    It’s a very nice to read guide, thank you for that. Still i have one issue i can not figure out:

    The DNS.

    I can ping rowdyserver
    I can ping rowdyserver.lindelaan.lan

    but i dont get any anwer when i just ping lindelaan.lan

    my resolv.conf looks like this

    search feuer.lan

    and i have no idea where to look to fix that.

  9. Venkatesh says:

    Thanks for this interesting tutorial. I have configured samba server in my system. But after the setup, the internet is not working. I getting the below-mentioned error. Please guide me to resolve the issues.

    FYI The error which gets is “Failed to start Raise network interfaces.” when restarting networking service

  10. Mohan N says:

    I am a newbie on Ubuntu as AD Server. I was going through the steps on this article on osx-virtualbox-ubuntu16 (host-only + nat). The same VM also has DNS (bind9), will be adding DHCP here as well if all goes well. :)

    For the DNS to be able to work for “host -t A tecmint.lan” what kind of record should be there in the DNS?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

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