Implementacao de servidores recursivos guia de praticas semcap ceptro br.pdf
Samba4+debian8
1. Implementando um Controlador de Domínio
com Debian e Samba 4
Um AD totalmente funcional com base no Linux Debian 8.7
usando Samba 4
O SAMBA, na versão 4, implementa um serviço de diretórios LDAP, com autenticação Kerberos,
oferece suporta a DNS dinâmico e atende muitos serviços para os quais, antes, só se pensava no
Active Directory. Hoje ele fornece tudo que é necessário para trabalhar como um Active Directory
Domain Controler, tendo compatibilidade total com o Sistema Operacional Microsoft Windows
atual. Sendo que podemos implementá-lo em ambientes de produção como Controlador de Domínio
primário ou secundário, em nível funcional de floresta compatível com Windows Server 2008 R2.
MÃO NA MASSA
INSTALAÇÃO DOS PACOTES:
apt-get update
apt-get install linux-source linux-headers-$(uname -r) build-essential ssh vim
ntp ntpdate samba winbind libnss-winbind acl attr ldb-tools
2. BACKUP/CONFIGURAÇÃO DO ARQUIVO DE SINCRONISMO DE TEMPO:
cp /etc/ntp.conf /etc/ntp.conf.orig
CONFIGURAÇÃO DO ARQUIVO DO TIME:
vim /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/
restrict default nomodify notrap noquery
restrict 127.0.0.1
restrict 192.168.0.254 mask 255.255.255.0 nomodify notrap
server a.st1.ntp.br
server b.st1.ntp.br
server c.st1.ntp.br
server d.st1.ntp.br
server a.ntp.br
server b.ntp.br
server c.ntp.br
server gps.ntp.br
SINCRONIZANDO TEMPO:
ntpdate -u a.ntp.br
SETANDO PERMISSÕES DO AD:
tune2fs -o acl,user_xattr /dev/sda2
vim /etc/fstab
/dev/sda2 /home ext4 user_xattr,acl,barrier=1 1 1
mount -o remount,rw /home
TESTE DE PERMISSÕES DO AD:
touch test.txt
setfattr -n user.test -v test test.txt
setfattr -n security.test -v test2 test.txt
getfattr -d test.txt
getfattr -n security.test -d test.txt
RETORNO DOS COMANDOS:
# file: test.txt
user.test="test"
# file: test.txt
security.test="test2"
SETANDO HOSTNAME:
vim /etc/hostname
ad
3. hostname ad
hostname -f
SETANDO RESOLVEDORES:
vim /etc/resolv.conf
domain eshark.info
search eshark.info.
nameserver 192.168.0.250 #PRÓPRIO AD
nameserver 192.168.0.254 #Firewall
SETANDO IP:
vim /etc/network/interfaces
iface eth0 inet static
address 192.168.0.250
netmask 255.255.255.0
gateway 192.168.0.254
dns-nameservers 192.168.0.250 192.168.0.254
dns-search eshark.info
SUBINDO CONFIGURAÇÕES DA PLACA DE REDE:
ifup eth0
SETANDO HOSTS:
vim /etc/hosts
.0.0.1 localhost
127.0.1.1 localhost.localdomain
192.168.0.250 ad.eshark.info ad
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
BACKUP DO smb.conf ORIGINAL ANTES DE PROVISIONAR:
mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
PROVISIONAMENTO:
samba-tool domain provision --interactive --use-rfc2307 --option="interfaces=lo
eth0" --option="bind interfaces only=yes"
COPIANDO O krb5.conf PARA O DIRETÓRIO /etc:
cp /var/lib/samba/private/krb5.conf /etc
OU USE UM EXEMPLO PARA /etc/krb5.conf:
default_realm = .eshark.info
dns_lookup_realm = false
dns_lookup_kdc = true
ticket_lifetime = 24h
4. renew_lifetime = 7d
forwardable = true
[realms]
.eshark.info = {
kdc = ad.eshark.info
admin_server = ad.eshark.info
}
[domain_realm]
.eshark.info = .eshark.info
eshark.info = eshark.info
SE OPTAR POR PERFIL MÓVEL:
mkdir /var/lib/samba/profiles
chmod -R 775 /var/lib/samba/profiles
chown -R root:users /var/lib/samba/profiles
APONTANDO O CAMINHO NO smb.conf:
vim /etc/samba/smb.conf
[profiles]
path = /var/lib/samba/profiles
comment = Perfil Movel
read only = No
Ao optar por Perfil móvel crie a pasta em /etc/samba/var/profiles, aponte no arquivo
/etc/samba/smb.conf e sete no perfil de usuário do AD através das ferramentas do RSAT, lá no
Windows, seguindo o caminho:
Usuário > Propriedades de usuário > Perfil > Caminho do perfil
adprofiles%USERNAME%
AUDITORIA NO AD:
vim /etc/samba/smb.conf
# AUDITORIA
vfs objects = full_audit
full_audit:sucess = open, opendir, write, rename, mkdir, rmdir, chmod,
chown
full_audit:prefix = %U|%I|%S
full_audit:failure = none
full_audit:facility = local5
full_audit:priority = notice
TESTES DE AUDITORIA EM TEMPO REAL:
smbcontrol all reload-config
tail -f /var/log/syslog | grep -E “open|unlink|rename”
cat /var/log/syslog | grep unlink
5. CRIANDO/SETANDO PERMISSÕES DA LIXEIRA:
mkdir /home/lixeira
chown root:users /home/lixeira
chmod 775 /home/lixeira -R
APONTANDO O CAMINHO NO AD:
vim /etc/samba/smb.conf
# LIXEIRA
vfs objects = recycle
recycle:keeptree = yes
recycle:versions = yes
recycle:repository = /home/lixeira/%U
recycle:exclude = *.tmp, *.log, *.obj, ~*.*, *.bak, *.iso
recycle:exclude_dir = tmp, cache
CRIANDO O DIRETÓRIO DE COMPARTILHAMENTOS:
mkdir /home/DADOS
chmod 775 /home/DADOS/ -R
chown root:users /home/DADOS/ -R
APONTANDO O CAMINHO NO smb.conf (seção global abaixo da lixeira):
vim /etc/samba/smb.conf
[DADOS]
path = /home/DADOS
comment = Compartilhamentos da Rede
read only = No
EXEMPLO DE smb.conf:
# Global parameters
[global]
bind interfaces only = Yes
interfaces = lo eth0
netbios name = AD
realm = ESHARK.INFO
workgroup = ESHARK
dns forwarder = 192.168.0.254 #FIREWALL
server role = active directory domain controller
server services = s3fs rpc nbt wrepl ldap cldap kcd drepl winbind
ntp_signd kcc dnsupdate dns
[netlogon]
path = /var/lib/samba/sysvol/eshark.info/scripts
read only = No
[sysvol]
path = /var/lib/samba/sysvol
read only = No
[profiles]
path = /var/lib/samba/profiles
6. read only = No
# AUDITORIA
vfs objects = full_audit
full_audit:sucess = open, opendir, write, rename, mkdir, rmdir, chmod,
chown
full_audit:prefix = %U|%I|%S
full_audit:failure = none
full_audit:facility = local5
full_audit:priority = notice
# LIXEIRA
vfs objects = recycle
recycle:keeptree = yes
recycle:versions = yes
recycle:repository = /home/lixeira/%U
recycle:exclude = *.tmp, *.log, *.obj, ~*.*, *.bak, *.iso
recycle:exclude_dir = tmp, cache
# COMPARTILHAMENTOS
[DADOS]
path = /home/DADOS
comment = COMPARTILHAMENTOS
read only = No
RESTARTANDO SERVIÇO DO SAMBA 4:
/etc/init.d/samba restart
VERIFICANDO SERVIÇO ATIVO:
ps aux | grep samba
testparm
DESABILITANDO COMPLEXIDADES DE SENHAS (OPCIONAL):
samba-tool domain passwordsettings show
samba-tool domain passwordsettings set --complexity=off --history-length=0
--min-pwd-length=0 --min-pwd-age=0
INSTALANDO PACOTE PARAAUTENTICAÇÃO NO KERBEROS:
apt-get install krb5-user
RELENDO CONFIGURAÇÕES DO SAMBA 4:
smbcontrol all reload-config
REVISANDO USUÁRIOS:
samba-tool user list
samba-tool group list
TESTANDO TROCA DE TIKETs:
kinit Administrator@ESHARK.INFO
7. klist
TESTANDO DOMÍNIO COM dig:
dig eshark.info
CONSULTANDO kerberos e ldap:
host -t srv _kerberos._tcp.eshark.info
host -t srv _ldap._tcp.eshark.inf
O restante das configurações poderão ser feitas agora no AD, através das Ferramentas de
administração do Windows Server 2008 R2 (RSAT), instaladas em uma versão de Windows 7, 8 ou
10.
Você pode gostar de ver este ambiente rodando em FreeBSD, para isso clique no botão abaixo:
Este é o meu modo de fazer a coisa neste momento, continuo estudando e aberto!
That’s all folks!
EDUARDO CHARQUERO
contato@esharktecnologia.com.br
(41)988065277