Samba Active Directory

1.5.1.1 Prepare the domain

1. the first step to install Samba Active Directory will be to set the domain

sudo apt update && sudo apt upgrade -y
sudo hostnamectl set-hostname dc1.yourdomain.local

Make sure your /etc/hosts file is configured correctly:

bash console

sudo nano /etc/hosts

127.0.0.1 localhost
127.0.1.1 dc1.yourdomain.local dc1
172.31.99.142 dc1.yourdomain.local dc1


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

1.1 in order to keep the DC always avaiable, it's advisable that DHCP should be disabled

make a backup copy of the current file 50-cloud-init.yaml :

sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak

sudo nano /etc/netplan/50-cloud-init.yaml

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 172.31.99.142/24
      routes:
        - to: default
          via: 172.31.99.1
      nameservers:
        addresses:
          - 127.0.0.1
          - 172.31.100.10
        search:
          - dc1.yourdomain.local

Apply the configuration

$sudo netplan apply

To avoid errors, the file must have correct indentation with white spaces respecting these rules:

# Indentation of 2 spaces per level
network: # 0 spaces
version: 2 # 2 spaces
ethernets: # 2 spaces
eth0: # 4 spaces
dhcp4: false # 6 spaces
addresses: # 6 spaces
- 172.31.98.200/24 # 8 spaces
routes: # 6 spazi
- to: default # 8 spaces
via: 172.31.99.1 # 10 spaces
nameservers: # 6 spazi (same livell of routes e addresses)
addresses: # 8 spaces
- 8.8.8.8 # 10 spaces
- 8.8.4.4 # 10 spaces


1.2 Configure DNS Resolution

Update /etc/resolv.conf to point to your DC:

bash console

sudo nano /etc/resolv.conf

nameserver 127.0.0.1
domain dc1.yourdomain.local
search dc1.yourdomain.local


for default configuration

bash console
sudo systemctl restart systemd-resolved


NOTE: To make this permanent on Ubuntu, you might need to configure netplan or systemd-resolved, depending on your setup. the nameserver choice will influence your connection, make sure the nameserver is a resolvable DNS (ex. google 8.8.8.8)

- Add or modify these lines in resolved.conf:

bash console

sudo nano /etc/systemd/resolved.conf

[Resolve]

DNS=172.31.99.142                 #place your dns IP
FallbackDNS=8.8.8.8                #place a dns that lets you navigate
Domains=yourdomain.local
DNSStubListener=no

Restart systemd-resolved:

bash console

sudo systemctl restart systemd-resolved