Samba: Difference between revisions
imported>Maximeborges Add Samba4 AC DC configuration steps |
imported>Maximeborges Fix AD DC instructions |
||
| Line 209: | Line 209: | ||
==== Active Directory Domain Controller ==== | ==== Active Directory Domain Controller ==== | ||
We will setup an AD DC just like the the [https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller Samba Wiki]. | |||
Let's add the following nix config, updating the <code>adDomain</code>, <code>adWorkgroup</code>, <code>adNetbiosName</code> and <code>staticIp</code> according to your needs. | |||
<syntaxhighlight lang=nix> | <syntaxhighlight lang=nix> | ||
{ | { config, lib, pkgs, ... }: | ||
with lib; | |||
let | let | ||
| Line 230: | Line 220: | ||
samba = cfg.package; | samba = cfg.package; | ||
nssModulesPath = config.system.nssModules.path; | nssModulesPath = config.system.nssModules.path; | ||
adDomain = 'samdom.example.com'; | |||
adWorkgroup = 'SAM'; | |||
adNetbiosName = 'SAMDOM'; | |||
staticIp = '10.42.129.160'; | |||
in { | in { | ||
# Disable resolveconf, we're using Samba internal DNS backend | |||
systemd.services.resolvconf.enable = false; | |||
environment.etc = { | |||
resolvconf = { | |||
text = '' | |||
search ${adDomain} | |||
nameserver ${staticIp} | |||
''; | |||
}; | |||
}; | |||
# Rebuild Samba with LDAP, MDNS and Domain Controller support | |||
nixpkgs.overlays = [ (self: super: { | |||
samba = super.samba.override { | |||
enableLDAP = true; | |||
enableMDNS = true; | |||
enableDomainController = true; | |||
}; | |||
} ) ]; | |||
# Disable default Samba `smbd` service, we will be using the `samba` server binary | |||
systemd.services.samba-smbd.enable = false; | systemd.services.samba-smbd.enable = false; | ||
systemd.services.samba = { | systemd.services.samba = { | ||
| Line 248: | Line 263: | ||
unitConfig.RequiresMountsFor = "/var/lib/samba"; | unitConfig.RequiresMountsFor = "/var/lib/samba"; | ||
}; | }; | ||
services.samba = { | services.samba = { | ||
enable = true; | enable = true; | ||
| Line 262: | Line 270: | ||
# Global parameters | # Global parameters | ||
[global] | [global] | ||
dns forwarder = | dns forwarder = ${staticIp} | ||
netbios name = | netbios name = ${adNetbiosName} | ||
realm = | realm = ${toUpper adDomain} | ||
server role = active directory domain controller | server role = active directory domain controller | ||
workgroup = | workgroup = ${adWorkgroup} | ||
idmap_ldb:use rfc2307 = yes | idmap_ldb:use rfc2307 = yes | ||
| Line 274: | Line 282: | ||
[netlogon] | [netlogon] | ||
path = /var/lib/samba/sysvol/ | path = /var/lib/samba/sysvol/${adDomain}/scripts | ||
read only = No | read only = No | ||
''; | ''; | ||
}; | }; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Evaluate}} | |||
After evaluating, you should see that the Samba service crashed because we haven't setup the database yet. | |||
To do that, let's run the following command, updated with your own configuration: | |||
<code> | |||
samba-tool domain provision --server-role=dc --use-rfc2307 --dns-backend=SAMBA_INTERNAL --realm=SAMDOM.EXAMPLE.COM --domain=SAMDOM --adminpass=Passw0rd | |||
</code> | |||
Then restart the samba service with <code>sudo systemctl restart samba</code>, and you're ready to go! | |||
==Troubleshooting== | ==Troubleshooting== | ||