
samba-tool , which is designed for automated preparation of the server to work, will help us with this, namely, it allows you to create the configuration file /etc/smb.conf . sudo apt install samba libpam-winbind samba-tool you need to check the /etc/hosts , namely, whether the FQDN and the IP address of the domain controller are correct. There you can find something like this: 127.0.0.1 localhost.localdomain IP_ADDRESS_OF_SERVER localhost IP_ADDRESS_OF_SERVER SAMBADOM.EXAMPLE.NET SAMBADOM IP_ADDRESS_OF_SERVER is the real address of the Samba server. Check that the file contains actual data./etc/hosts , in our case the node name is SAMBADOM . To configure it, open the /etc/hostname file and change it accordingly. Next, restart the server.smb.conf file, as well as any Samba database files (these are .tdb and .ldb files). In order to find the directories containing these files, run the following commands: mbd -b | grep "CONFIGFILE" smbd -b | egrep "LOCKDIR|STATEDIR|CACHEDIR|PRIVATE_DIR" 
samba-tool . We will run this tool interactively by running the following command: sudo samba-tool domain provision --use-rfc2307 --interactive --use-rfc2307 command with the key - --use-rfc2307 , we include the NIS extensions. Samba-tool offer to configure the following parameters:Realm . This is the full DNS domain name that is configured in the hosts . For example: SAMBADOM.EXAMPLE.NET .Domain . The domain name of the Samba NetBIOS server. Please note that it is recommended to use the first part of the DNS domain name here. For example, SAMBADOM .Server Role . This parameter is intended to indicate the type of server role. By default, the dc value is set here, it will suit us.DNS backend . This option allows you to configure a DNS server. Here we also leave the default parameter - SAMBA_INTERNAL .DNS forwarder IP address . This parameter allows you to specify the IP address of the DNS server to which requests will be redirected that the Samba server cannot allow. If you do not need to redirect DNS requests - do not enter anything in response to this question. Read more about it here .Administrator password . Here you must specify the domain administrator password.samba-tool configure Samba as a domain controller. You can view the /etc/samba/smb.conf file and, if necessary, make changes to it. smbpasswd -a USERNAME smbpasswd -e USERNAME USERNAME is the name of an existing user to add to Samba. You will need to enter the password only after entering the first command. The first command adds a new user and asks for a password for it; the second one activates the created account./etc/network/interfaces file, bringing it to this form: auto INTERFACE_NAME iface INTERFACE_NAME inet static address IP_ADDRESS_FOR_SERVER netmask NETMASK gateway GATEWAY dns-nameservers IP_ADDRESS_FOR_SERVER  sudo service networking restart /etc/resolv.conf file, making changes that are consistent with those mentioned above. Namely, here we are interested in the following line: nameserver IP_ADDRESS_FOR_SERVER IP_ADDRESS_FOR_SERVER , you need to enter the same address that was recorded in the dns-nameservers above.krb5.conf file generated during Samba preparation. To do this, run the following commands: sudo mv /etc/krb5.conf /etc/krb5.conf.orig sudo ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf /etc/krb5.conf file in the system. If this is true, it suffices to execute only the second of the above commands. smbclient -L localhost -U% 
smbclient , information about netlogon and sysvol as shared resources is sysvol . They are created by default and must exist on a domain controller. In addition, in /var/lib/samba/sysvol/REALM/scripts should place any login scripts that clients need. Here REALM corresponds to the REALM parameter that was specified during the work with the samba-tool command./etc/samba/smb.conf file and enter data into it that reflects your server requirements. This file, generated by the samba-tool , is very concise, although it is a good starting point for fine tuning your AD DC, built on the basis of Samba and Ubuntu Server.Source: https://habr.com/ru/post/323860/
All Articles