This tutorial provides a step-by-step method to create a Windows™ Active Directory Domain Controller (DC) using Linux, Samba 4 and a Raspberry Pi.
What you’ll need
You’ll need the following for this project:
- A Raspberry Pi (I’m testing this procedure on a Pi3 B) with a Network Port (RJ45 with Gigabit connectivity)
- A straight-through network cable to connect your switch
- A Micro SD or SD card of at least 8GB in size for the operating system
- A current version of Raspbian
- A Keyboard, Mouse and monitor combination to initially get you started, and
- This documentation
First you should prepare your SD-card according to the raspberry.org installation documentation. I’m using Raspbian as the OS for this project. Once you’ve completed the basic setup of the Pi you’ll need to plug the Pi into the network using the ethernet cable, and power it on. Once this is complete move on to the next section.
You’ve two options here:
- Connect a display, mouse and keyboard, or
- Use SSH to remote into the Raspberry Pi.
I use and recommend Putty to SSH into the Raspberry Pi. Firstly it builds your skills for working on the Linux (and thereby Raspbian) command line and you’ll get to learn a bucket load more than you do using a monitor and a mouse directly.
Finding the IP address
To find the assigned IP address assigned by the DHCP server on your router, or other device, you can to check which IP-address the Raspberry Pi receives. I used AngryIP to find the MAC and the IP address assigned to the Pi.
Using Putty to connect
- In the Host Name (or IP address) box, type in the IP address you found in the step above, then
- Click the OPEN button to create the connection
- Once you reach the ‘Login as:’ prompt use the following credentials:
- Username: pi
- Password: raspberry
The first step is to complete basic configuration of Raspberry Pi. The system should start ‘Raspi-Config’ automatically. If it does not start automatically you can start it manually by using the following command:
- Choose Option 1 – Expand the file system
- Press the ENTER key, allow the process to complete
- Press the ENTER key again to return to the Raspi-Config screen
- Choose Option 3 – Boot Options
- Choose the B1 Console – requiring the user to login
- Press the ENTER key to complete the configuration option
- Press the right arrow key ‘>’ twice and press the ENTER key to ‘Finish’
We’ll leave the Config application now and head back to the command line.
Next make sure to increase the security and change your password. You can do this using the command below:
sudo passwd pi
you should also at this point change the root password to something much more secure with the command shown below:
sudo passwd root
Finally you must update your Pi’s system with the two following commands:
sudo apt-get update sudo apt-get upgrade
You may be prompted by the system to ‘continue’. To do so type ‘Y’ for yes and hit the ENTER key to continue. The upgrade process for a Pi may take a few minutes. You must wait for the upgrade process to complete. While this is happening go eat breakfast, get a cup of tea, or grab a cup of coffee. Even on my fast broadband connection (100 Mb/s) it took around 25 minutes to complete. When you are back at the main prompt, the upgrade is done.
Once you are more comfortable at the command line, referred to in Linux speak as the ‘Terminal’, you can chain the commands together using the double ‘&&’ and this will run the commands in order. The second command will not run until the first is complete. To run both of the commands together type the following:
sudo apt-get update && sudo apt-get upgrade
Setting time, date and keyboard mapping
The Raspberry Pi 3 does not have a real-time clock although you can purchase one as an add-on. However, with access to the internet you can set the time every time the Pi reboots using remote NTP servers. The time zone initially will also not be correct for your location generally unless you are in the UK. I am installing mine in Australia and you need to reconfigure the Pi to get the correct time offset from UTC and to ensure that any daylight savings settings are applied.
Setting the NTP server
For Australia my preferred NTP servers are:
- server 0.au.pool.ntp.org
- server 1.au.pool.ntp.org
- server 2.au.pool.ntp.org
- server 3.au.pool.ntp.org
To update the servers in the config file follow the steps below. At the terminal type:
sudo nano /etc/ntp.conf
In the file change the list of servers to match the list above. Comment out (by adding a # in front of the line) the following two lines:
- restrict 127.0.0.1
- restrict ::1
Save the file and exit by using the following keyboard commands:
- CTRL-X (to exit)
- Y (to confirm the changes to be written to the file), and
- ENTER (to complete the save)
This applies to all text files in any Linux flavour. See I told you the terminal is a learning experience – if frustrating at the start.
Change location settings
Locale settings ensure that the system time offsets from UTC are correct. To set your Locale settings at the terminal type the following on the keyboard:
sudo dpkg-reconfigure locales
- Next press ENTER
- In the ‘Package Configuration’ application you need to scroll down to choose your location. For Australia choose:
- Next press the SPACEBAR to select or deselect your option
- Press the ENTER key, and
- Press the ENTER key again.
Set the Time Zone
Finally you need to set the local time zone. This ensures that location offsets, including daylight savings time settings are correct. From the terminal type:
sudo dpkg-reconfigure tzdata
- Press the ENTER key
- Choose your country and press ENTER
- Choose your City (or one in your time zone) and press ENTER
This will return you to the prompt in the terminal. To check that the Pi’s time is correct type the following at the prompt:
- Press the ENTER key
This will echo the date and time in the format shown below.
%DAY% %DD% %Month% %TIME% %TIMEZONE% %YEAR%
This is the time and date information I got when writing this document:
Thursday 15 December 18:12:01 AEDT 2016
Setting the keyboard mapping
Keyboard mapping is important if you use a keyboard attached to your Raspberry Pi. To map the correct keyboard do the following:
From the terminal type:
sudo nano /etc/default/keyboard
- Edit the line XKBLAYOUT=”gb” to XKBLAYOUT=”us”
- Save the file and exit.
This completes the section Setting time, date and keyboard mapping. You should now be setup for Australian time, locale and keyboard mapping.
The next page will complete the setup of Webmin and allow you to work with the Pi via a web interface. Use the menus above to go to the next page.