Skip to content

Commit 1c58e9c

Browse files
author
root
committed
Samba4ad install instructions V1
0 parents  commit 1c58e9c

File tree

1 file changed

+272
-0
lines changed

1 file changed

+272
-0
lines changed
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
# SAMBA4AD
2+
### Prepping the server
3+
Install OS, assign static IP address
4+
5+
Edit host file and add an IP address entry with the hostname and FQDN
6+
```
7+
127.0.0.1 localhost localhost.tobias.local
8+
::1 localhost localhost.tobias.local
9+
10.0.2.201 tobiasdc01 tobiasdc01.tobias.local
10+
```
11+
12+
Run the following to update hostname
13+
```
14+
hostnamectl set-hostname tobiasdc01
15+
```
16+
17+
Reboot
18+
19+
### Installing packages
20+
We need to install the following packages to build Samba as an AD DC
21+
```
22+
yum -y install attr bind-utils docbook-style-xsl gcc gdb krb5-workstation \
23+
libsemanage-python libxslt perl perl-ExtUtils-MakeMaker \
24+
perl-Parse-Yapp perl-Test-Base pkgconfig policycoreutils-python \
25+
python2-crypto gnutls-devel libattr-devel keyutils-libs-devel \
26+
libacl-devel libaio-devel libblkid-devel libxml2-devel openldap-devel \
27+
pam-devel popt-devel python-devel readline-devel zlib-devel systemd-devel \
28+
lmdb-devel jansson-devel gpgme-devel pygpgme libarchive-devel wget ntp
29+
```
30+
31+
Unfortunately the Samba package provided from CentOS official repository does not provide the DC function yet, so we need to download and install from source.
32+
33+
Install the development tools so we can compile and install Samba
34+
```
35+
yum groups -y install "Development Tools"
36+
```
37+
38+
I'm adding the EPL7 repo to download and install the lmdb package to be sure (make sure wget installed)
39+
```
40+
yum install epel-release
41+
yum install lmdb
42+
```
43+
44+
Download the tar ball (double check the samba URL for latest version, [link](https://download.samba.org/pub/samba/stable/)) - I've had to use 4.3.3 as 4.9.3 has an lmdb dependency error
45+
```
46+
wget https://download.samba.org/pub/samba/stable/samba-4.3.3.tar.gz
47+
```
48+
49+
*----- 4.9.3 lmdb dependency fix -----*
50+
51+
Download the lmdb package from github
52+
```
53+
wget https://github.com/LMDB/lmdb/archive/LMDB_0.9.22.tar.gz
54+
```
55+
56+
Extract the tarball
57+
```
58+
tar -zxvf LMDB_0.9.22.tar.gz
59+
```
60+
61+
Change directory into "lmdb-LMDB_0.9.22/libraries/liblmdb/"
62+
```
63+
cd lmdb-LMDB_0.9.22/libraries/liblmdb
64+
```
65+
66+
Run the "make"
67+
```
68+
make
69+
```
70+
71+
Globally remove the "liblmdb.a" reference from the makefile
72+
```
73+
sed -i 's/liblmdb.a//' Makefile
74+
```
75+
76+
Install the lmdb library
77+
```
78+
make prefix=/usr install
79+
```
80+
81+
Now you can continue with the below
82+
83+
*----- 4.9.3 lmdb dependency fix -----*
84+
85+
86+
Extract the tar ball
87+
```
88+
tar -zxvf samba-4.3.3.tar.gz
89+
```
90+
91+
Navigate to the newly created directory
92+
```
93+
cd samba-4.3.3
94+
```
95+
96+
Time to configure the package, run the following (we don't want CUPS)
97+
```
98+
./configure --disable-cups
99+
```
100+
101+
Once the configure has completed we need to start the compilation
102+
```
103+
make
104+
```
105+
106+
Once this is complete we need to install it
107+
```
108+
make install
109+
```
110+
111+
Now it's installed lets add the dirs to the $PATH so we can easily use the tools. Create a "samba.sh" file in "/etc/profile.d/"
112+
```
113+
vi /etc/profile.d/samba.sh
114+
```
115+
116+
Paste the following
117+
```
118+
export PATH=$PATH:/usr/local/samba/bin/:/usr/local/samba/sbin/
119+
```
120+
121+
Save and quit, log off and log back on and make sure you can run "samba-tool".
122+
123+
### Configuring new domain controller
124+
Now Samba is installed we need to do the config side of things.
125+
126+
We probably have some old config in our krb5.conf file, backup this file just in case and link the samba one
127+
```
128+
mv /etc/krb5.conf /etc/krb5.conf.bak
129+
ln -sf /usr/local/samba/private/krb5.conf /etc/krb5.conf
130+
```
131+
132+
We want to now provision the domain, for this example we're using " --option="interfaces=lo enp0s3" --option="bind interfaces only=yes"" to bind to just the interfaces we want.
133+
```
134+
samba-tool domain provision --use-rfc2307 --interactive --option="interfaces=lo enp0s3" --option="bind interfaces only=yes"
135+
```
136+
137+
Once the domain has been configured we need to edit our "resolv.conf" file to point to the new DC like so
138+
```
139+
vi /etc/resolv.conf
140+
```
141+
```
142+
search tobias.local
143+
nameserver 10.0.2.201
144+
```
145+
146+
Create a new "/etc/systemd/system/samba-ad-dc.service" file so we can easily start and stop the service
147+
```
148+
vi /etc/systemd/system/samba-ad-dc.service
149+
```
150+
151+
Paste the following in
152+
```
153+
[Unit]
154+
Description=Samba Active Directory Domain Controller
155+
After=network.target remote-fs.target nss-lookup.target
156+
[Service]
157+
Type=forking
158+
ExecStart=/usr/local/samba/sbin/samba -D
159+
PIDFile=/usr/local/samba/var/run/samba.pid
160+
ExecReload=/bin/kill -HUP $MAINPID
161+
[Install]
162+
WantedBy=multi-user.target
163+
```
164+
165+
Reload "systemd" config
166+
```
167+
systemctl daemon-reload
168+
```
169+
170+
Enable / disable samba AD on startup
171+
```
172+
systemctl enable samba-ad-dc
173+
systemctl disable samba-ad-dc
174+
```
175+
176+
We can now restart samba-ad-dc with the following commands
177+
```
178+
systemctl start samba-ad-dc
179+
systemctl stop samba-ad-dc
180+
```
181+
182+
Start samba
183+
```
184+
systemctl start samba-ad-dc
185+
```
186+
187+
Create a reverse DNS record on the new domain controller (remember the password you used when setting up the domain!)
188+
```
189+
samba-tool dns zonecreate 10.0.2.201 2.0.10.in-addr.arpa -Uadministrator
190+
```
191+
192+
### Testing config
193+
Lets query some DNS records to make sure it's working correctly
194+
195+
The tcp-based _ldap SRV record in the domain
196+
```
197+
host -t SRV _ldap._tcp.tobias.local
198+
```
199+
200+
The udp-based _kerberos SRV resource record in the domain
201+
```
202+
host -t SRV _kerberos._udp.tobias.local
203+
```
204+
205+
The A record of the domain controller
206+
```
207+
host -t A tobiasdc01.tobias.local
208+
```
209+
210+
Request a Kerberos ticket for the domain administrator account
211+
```
212+
kinit administrator
213+
```
214+
215+
List the cached Kerberos tickets using "klist"
216+
```
217+
klist
218+
```
219+
220+
This is the initial testing completed
221+
222+
### Additional config
223+
We need to add a DNS forwarder if we didn't do so in the initial config so that we can talk externally, add the following to your "/usr/local/samba/etc/smb.conf" file:
224+
```
225+
dns forwarder = 8.8.8.8
226+
```
227+
228+
To get this fully working we need to configure NTP, this involves installing and configuring the package. Run the following:
229+
```
230+
yum install ntp
231+
```
232+
233+
Edit /etc/ntp.conf and replace everything with the following (for ease, setting different pool of NTP servers):
234+
```
235+
driftfile /var/lib/ntp/drift
236+
restrict default nomodify notrap nopeer noquery
237+
restrict 127.0.0.1
238+
restrict ::1
239+
server 0.uk.pool.ntp.org
240+
server 1.uk.pool.ntp.org
241+
server 2.uk.pool.ntp.org
242+
server 3.uk.pool.ntp.org
243+
includefile /etc/ntp/crypto/pw
244+
keys /etc/ntp/keys
245+
disable monitor
246+
```
247+
248+
Add the Samba AD ports to your firewalld config
249+
```
250+
firewall-cmd --add-port=53/tcp --permanent;firewall-cmd --add-port=53/udp --permanent;firewall-cmd --add-port=88/tcp --permanent;firewall-cmd --add-port=88/udp --permanent; \
251+
firewall-cmd --add-port=135/tcp --permanent;firewall-cmd --add-port=137-138/udp --permanent;firewall-cmd --add-port=139/tcp --permanent; \
252+
firewall-cmd --add-port=389/tcp --permanent;firewall-cmd --add-port=389/udp --permanent;firewall-cmd --add-port=445/tcp --permanent; \
253+
firewall-cmd --add-port=464/tcp --permanent;firewall-cmd --add-port=464/udp --permanent;firewall-cmd --add-port=636/tcp --permanent; \
254+
firewall-cmd --add-port=1024-5000/tcp --permanent;firewall-cmd --add-port=3268-3269/tcp --permanent
255+
```
256+
257+
*----- Optional -----*
258+
259+
Disable the firewalld service as this stops communication to your ADDC if you're having issues with firewall ports or firewalld
260+
```
261+
systemctl stop firewalld
262+
```
263+
264+
Check to make sure it's stopped with
265+
```
266+
systemctl status firewalld
267+
```
268+
*----- Optional -----*
269+
270+
This should now allow you to connect computers to the domain and create users along with talking externally. For more information on managing samba via the CLI check out the link [here](https://www.tecmint.com/manage-samba4-active-directory-linux-command-line/).
271+
272+
Join a second domain controller to the domain for redundancy

0 commit comments

Comments
 (0)