Samba AD on CentOS7
This page describe Samba4 Active Directory installation on CentOS. The environment is composed of 2 DCs with replication, and one fileserver.
dc1.domain.com.br dc2.domain.com.br fileserver.domain.com.br
The installation is based on CentOS7 Minimal ISO, you should update the system, and install basic tools.
yum update yum install -y vim wget
This pre-setup can be done in all 3 servers, basically it will setup the Sernet Samba Repository and install samba from repo.
wget https://raw.githubusercontent.com/hflautert/lotus7/master/samba4/pre_install_samba4.sh chmod +x pre_install_samba4.sh ./pre_install_samba4.sh
First of all we need a domain, so lets provision it.
samba-tool domain provision --use-rfc2307 --interactive
Setup kerberos, you can use the as dc1.
scp firstname.lastname@example.org:/etc/krb5.conf /etc/krb5.conf
Join as DC.
samba-tool domain join domain.com.br DC -Uadministrator --realm=domain.com.br
Fix DNS if it was not created automatically:
samba-tool dns add dc1 domain.com.br dc2 A <IP-OF-DC2> -Uadministrator
After couple minutes, we can see the replication:
samba-tool drs showrepl
- You can safely ignore it: Warning: No NC replicated for Connection!
This post setup will configure the services to startup and disable Selinux and Firewall, during my tests firewalld did not save the allowed ports, even with permanent flag, so I´v decided to disable to avoid problems.
wget https://raw.githubusercontent.com/hflautert/lotus7/master/samba4/post_install_samba4.sh chmod +x post_install_samba4.sh ./post_install_samba4.
The pre-setup is the same, but we are not going provision neither join, the fileserver will be just a member of domain. CentOS bring us a useful tool to do it, actually we are going to setup authentication and join the domain in one shot. Lets start testing our DNS:
host -t SRV _ldap._tcp.domain.com.br. _ldap._tcp.domain.com.br has SRV record 0 100 389 dc1.domain.com.br.
Here there is a TODO, you can map what you need to set on Selinux, or disable it:
setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
Setup auth and join the domain:
sed -i 's/SAMBA_START_MODE="none"/SAMBA_START_MODE="classic"/g' /etc/default/sernet-samba
systemctl restart sernet-samba-smbd systemctl restart sernet-samba-nmbd systemctl restart sernet-samba-winbindd
chkconfig sernet-samba-nmbd on chkconfig sernet-samba-smbd on chkconfig sernet-samba-winbindd on