Sunteți pe pagina 1din 30

UNIVERSIDAD CENTRAL DEL ECUADOR

FACULTAD DE CIENCIAS FISICAS Y MATEMATICA


INGENIERIA INFORMATICA

LABORATORIO DE PROTOCOLOS DE COMUNICACIÓN 2H


ING. EDUARDO SUAREZ
ACOSTA RODRIGUEZ BRYAN XAVIER
31 DE JULIO DE 2016

DNS

Escenario

- Servidor Principal (Master)


o IP = 192.168.10.1/24
o Hostname = masterdns.informatica.local
- Servidor Secundario (Slave)
o IP = 192.168.10.2/24
o Hostname = secondarydns.informatica.local
- Cliente 1 (Client)
o IP = 192.168.10.3/24
o Hostname = client1.informatica.local
- Cliente 2 (Client)
o IP = 192.168.10.4/24
o Hostname = client2.informatica.local
o

Servidor Principal (Master):

1. Instalamos los paquetes de bind en el servidor:

[root@localhost bxav]# yum install bind.x86_64 bind-utils.x86_64 -y

2. Editar el archivo de configuración named.conf

[root@localhost bxav]# nano /etc/named.conf

3. Se agregan las partes que se encuentran en azul


//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
listen-on port 53 { 127.0.0.1; 192.168.10.1; };# IP Servidor Master
# listen-on-v6 port 53 { ::1; }; # Se comenta esta linea
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query{ localhost; 192.168.10.0/24; }; # Dominio de broadcast
allow-transfer{ localhost; 192.168.10.2; }; # IP del servidor
# secundario

/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable
recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to
enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable
access
control to limit queries to your legitimate users. Failing to do so
will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;

dnssec-enable yes;
dnssec-validation yes;

/* Path to ISC DLV key */


bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";

pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};

logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

zone "." IN {
type hint;
file "named.ca";
};

zone "informatica.local" IN {
type master;
file "forward.informatica";
allow-update { none; };
};

zone "10.168.192.in-addr.arpa" IN {
type master;
file "reverse.informatica";
allow-update { none; };
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
Creamos los archivos de configuración de las zonas

4. Creamos el archivo para la Forward zone

[root@localhost bxav]# nano /var/named/forward.informatica

5. Agregamos las siguientes líneas

$TTL 1d
@ IN SOA masterdns.informatica.local. root.informatica.local. (
2016070101 ;Serial
1h ;Refresh
30m ;Retry
1w ;Expire
1d ;Minimum TTL
)
@ IN NS masterdns.informatica.local.
@ IN NS secondarydns.informatica.local.
@ IN A 192.168.10.1
@ IN A 192.168.10.2
@ IN A 192.168.10.3
@ IN A 192.168.10.4
masterdns IN A 192.168.10.1
secondarydns IN A 192.168.10.2
client1 IN A 192.168.10.3
client2 IN A 192.168.10.4

6. Creamos el archivo para la Reverse zone

[root@localhost bxav]# nano /var/named/reverse.informatica

7. Agregamos las siguientes líneas


$TTL 1d
@ IN SOA masterdns.informatica.local. root.informatica.local. (
2016070101 ;Serial
1h ;Refresh
30m ;Retry
1w ;Expire
1d ;Minimum TTL
)
@ IN NS masterdns.informatica.local.
@ IN NS secondarydns.informatica.local.
@ IN PTR informatica.local.
masterdns IN A 192.168.10.1
secondarydns IN A 192.168.10.2
client1 IN A 192.168.10.3
client2 IN A 192.168.10.4
1 IN PTR masterdns.informatica.local.
2 IN PTR secondarydns.informatica.local.
3 IN PTR client1.informatica.local.
4 IN PTR client2.informatica.local.

8. Verificamos si está bien la configuración

[root@localhost bxav]# named-checkconf /etc/named.conf

[root@localhost bxav]# named-checkzone informatica.local


/var/named/forward.informatica

zone informatica.local/IN: loaded serial 2016070101


OK

[root@localhost bxav]# named-checkzone informatica.local


/var/named/reverse.informatica

zone informatica.local/IN: loaded serial 2016070101


OK

9. Iniciamos el servicio DNS

[root@localhost bxav]# systemctl enable named

Created symlink from /etc/systemd/system/multi-user.target.wants/named.service


to /usr/lib/systemd/system/named.service.

[root@localhost bxav]# systemctl start named

10. Añadimos la regla en firewall permitiendo el servicio a través del puerto 53 TCP/UDP

[root@localhost bxav]# firewall-cmd --permanent --add-port=53/tcp

Success

[root@localhost bxav]# firewall-cmd --permanent --add-port=53/udp

Success

11. Reiniciamos el firewall

[root@localhost bxav]# firewall-cmd --reload


Success

12. Asignamos la IP estática a la nic

13. Agregamos el servidor DNS de la red al archivo de configuración de la NIC.

[root@localhost bxav]# nano /etc/sysconfig/network-scripts/ifcfg-enp0s3

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=d2e18740-73cd-46e1-8fb4-190e8ad1ba60
DEVICE=enp0s3
ONBOOT=no
IPADDR=192.168.10.1
PREFIX=24
DNS1=192.168.10.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

14. Reiniciamos los servicios de red y conectamos de nuevo el adaptador.


[root@localhost bxav]# systemctl restart network
[root@localhost bxav]# ifup enp0s3

Connection successfully activated (D-Bus active path:


/org/freedesktop/NetworkManager/ActiveConnection/5)

15. Verificamos que el servidor está declarado en el archivo resolv.conf

[root@localhost bxav]# cat /etc/resolv.conf

# Generated by NetworkManager
nameserver 192.168.10.1

16. Configuración de permisos, la propiedad y SELinux

[root@localhost bxav]# chgrp named -R /var/named


[root@localhost bxav]# chown -v root:named /etc/named.conf

ownership of ‘/etc/named.conf’ retained as root:named

[root@localhost bxav]# restorecon -rv /var/named


[root@localhost bxav]# restorecon /etc/named.conf

17. Probar el servidor DNS


[root@localhost bxav]# nslookup informatica.local

Server: 192.168.10.1
Address: 192.168.10.1#53

Name: informatica.local
Address: 192.168.10.3
Name: informatica.local
Address: 192.168.10.2
Name: informatica.local
Address: 192.168.10.4
Name: informatica.local
Address: 192.168.10.1

Servidor Secundario (Slave)

1. Instalamos los paquetes de bind en el servidor:

[root@localhost bxav]# yum install bind.x86_64 bind-utils.x86_64 -y


2. Editar el archivo de configuración named.conf

[root@localhost bxav]# nano /etc/named.conf

3. Se agregan las partes que se encuentran en azul


//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
listen-on port 53 { 127.0.0.1; 192.168.10.2; };
# listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost; 192.168.10.0/24; };

/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable
recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to
enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable
access
control to limit queries to your legitimate users. Failing to do so
will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;

dnssec-enable yes;
dnssec-validation yes;

/* Path to ISC DLV key */


bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";

pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};

logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

zone "." IN {
type hint;
file "named.ca";
};

zone "informatica.local" IN {
type slave;
file "slaves/informatica.fwd";
masters { 192.168.10.1; };
};

zone "10.168.192.in-addr.arpa" IN {
type slave;
file "slaves/informatica.rev";
masters { 192.168.10.1; };
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

4. Verificamos si está bien la configuración

[root@localhost bxav]# named-checkconf /etc/named.conf

5. Iniciamos el servicio DNS


[root@localhost bxav]# systemctl enable named

Created symlink from /etc/systemd/system/multi-user.target.wants/named.service


to /usr/lib/systemd/system/named.service.

[root@localhost bxav]# systemctl start named

6. Verificamos que los archivos de configuración de las zonas se están replicando de


servidor DNS Master.

[root@localhost bxav]# ls /var/named/slaves/

informatica.fwd informatica.rev

7. Agregamos el servidor DNS de la red al archivo de configuración de la NIC

[root@localhost bxav]# nano /etc/sysconfig/network-scripts/ifcfg-enp0s3

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=d2e18740-73cd-46e1-8fb4-190e8ad1ba60
DEVICE=enp0s3
ONBOOT=no
IPADDR=192.168.10.2
PREFIX=24
DNS1=192.168.10.1
DNS2=192.168.10.2
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

8. Reiniciamos los servicios de red y conectamos de nuevo el adaptador.


[root@localhost bxav]# systemctl restart network
[root@localhost bxav]# ifup enp0s3
Connection successfully activated (D-Bus active path:
/org/freedesktop/NetworkManager/ActiveConnection/5)

9. Verificamos que el servidor está declarado en el archivo resolv.conf

[root@localhost bxav]# cat /etc/resolv.conf

# Generated by NetworkManager
nameserver 192.168.10.1
nameserver 192.168.10.2

10. Añadimos la regla en firewall permitiendo el servicio a través del puerto 53 TCP/UDP

[root@localhost bxav]# firewall-cmd --permanent --add-port=53/tcp


Success

[root@localhost bxav]# firewall-cmd --permanent --add-port=53/udp


Success

11. Reiniciamos el firewall

[root@localhost bxav]# firewall-cmd --reload


Success

12. Configuración de permisos, la propiedad y SELinux

[root@localhost bxav]# chgrp named -R /var/named


[root@localhost bxav]# chown -v root:named /etc/named.conf

chown -v root:named /etc/named.conf

[root@localhost bxav]# restorecon -rv /var/named


[root@localhost bxav]# restorecon /etc/named.conf

13. Probar el servidor DNS


[root@localhost bxav]# nslookup informatica.local

Server: 192.168.10.1
Address: 192.168.10.1#53

Name: informatica.local
Address: 192.168.10.2
Name: informatica.local
Address: 192.168.10.4
Name: informatica.local
Address: 192.168.10.3
Name: informatica.local
Address: 192.168.10.1

Cliente 1 (Client)

1. Agregamos los detalles de los servidores DNS en resolv.conf

[root@localhost bxav]# nano /etc/resolv.conf

# Generated by NetworkManager

search informática.local
nameserver 192.168.10.1
nameserver 192.168.10.2

2. Probamos los servidores DNS

[root@localhost bxav]# dig masterdns.informatica.local

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7 <<>> masterdns.informatica.local


;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61033
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;masterdns.informatica.local. IN A

;; ANSWER SECTION:
masterdns.informatica.local. 86400 IN A 192.168.10.1

;; AUTHORITY SECTION:
informatica.local. 86400 IN NS secondarydns.informatica.local.
informatica.local. 86400 IN NS masterdns.informatica.local.

;; ADDITIONAL SECTION:
secondarydns.informatica.local. 86400 IN A 192.168.10.2

;; Query time: 0 msec


;; SERVER: 192.168.10.1#53(192.168.10.1)
;; WHEN: sáb jul 02 00:47:39 ECT 2016
;; MSG SIZE rcvd: 129

[root@localhost bxav]# dig secondarydns.informatica.local

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7 <<>> secondarydns.informatica.local


;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5330
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;secondarydns.informatica.local. IN A

;; ANSWER SECTION:
secondarydns.informatica.local. 86400 IN A 192.168.10.2

;; AUTHORITY SECTION:
informatica.local. 86400 IN NS masterdns.informatica.local.
informatica.local. 86400 IN NS secondarydns.informatica.local.

;; ADDITIONAL SECTION:
masterdns.informatica.local. 86400 IN A 192.168.10.1

;; Query time: 0 msec


;; SERVER: 192.168.10.1#53(192.168.10.1)
;; WHEN: sáb jul 02 00:49:33 ECT 2016
;; MSG SIZE rcvd: 129

[root@localhost bxav]# dig client1.informatica.local

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7 <<>> client1.informatica.local


;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26506
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;client1.informatica.local. IN A

;; ANSWER SECTION:
client1.informatica.local. 86400 IN A 192.168.10.3

;; AUTHORITY SECTION:
informatica.local. 86400 IN NS masterdns.informatica.local.
informatica.local. 86400 IN NS secondarydns.informatica.local.

;; ADDITIONAL SECTION:
masterdns.informatica.local. 86400 IN A 192.168.10.1
secondarydns.informatica.local. 86400 IN A 192.168.10.2

;; Query time: 1 msec


;; SERVER: 192.168.10.1#53(192.168.10.1)
;; WHEN: sáb jul 02 00:50:53 ECT 2016
;; MSG SIZE rcvd: 153

[root@localhost bxav]# nslookup informatica.local

Server: 192.168.10.1
Address: 192.168.10.1#53

Name: informatica.local
Address: 192.168.10.3
Name: informatica.local
Address: 192.168.10.1
Name: informatica.local
Address: 192.168.10.2
Name: informatica.local
Address: 192.168.10.4

Cliente 2 (Client)

1. Agregamos los detalles de los servidores DNS en resolv.conf

[root@localhost bxav]# nano /etc/resolv.conf

# Generated by NetworkManager

search informática.local
nameserver 192.168.10.1
nameserver 192.168.10.2

MAIL

Escenario

- Servidor DNS (Master)


o IP = 192.168.10.1/24
o Hostname = masterdns.informatica.local
- Servidor (Mail)
o IP = 192.168.10.100/24
o Hostname = mail.informatica.local
- Cliente 1 (Client)
o IP = 192.168.10.10 /24

Servidor DNS (Master):

18. Agregamos el servidor de correo a la zona forward del DNS.

@ IN MX 10 mail.informatica.local.

@ IN A 192.168.10.100

mail IN A 192.168.10.100

Recordar incrementamos el registro de número de serie.

19. Agregamos el servidor de correo a la zona reverse del DNS.

@ IN MX 10 mail.informatica.local.

mail IN A 192.168.10.100

100 IN PTR mail.informatica.local.

Recordar incrementamos el registro de número de serie.

20. Verificamos que está bien las configuraciones de las zonas

[root@localhost bxav]# named-checkzone informatica.local


/var/named/forward.informatica

zone informatica.local/IN: loaded serial 2016072402


OK

[root@localhost bxav]# named-checkzone informatica.local


/var/named/forward.informatica

zone informatica.local/IN: loaded serial 2016072402


OK
Servidor (Mail):

1. Agregar el hostname en el archivo /etc/hosts

[root@localhost bxav]# nano /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4


:1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.100 mail.informatica.local mail

2. Deshabilitamos el SELinux para reducir la complejidad en la configuración del postfix

[root@localhost bxav]# nano /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.


# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are
pr$
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

3. Instalamos el servicio de telnet para cliente

[root@localhost bxav]# yum install telnet.x86_64 -y

4. Agregamos el puerto por defecto de SMTP el 25, POP 110 e IMAP 143 al Firewall

[root@localhost bxav]# firewall-cmd --permanent --add-port=25/tcp


Success
[root@localhost bxav]# firewall-cmd --permanent --add-port=110/tcp
Success
[root@localhost bxav]# firewall-cmd --permanent --add-port=143/tcp
Success
[root@localhost bxav]# firewall-cmd --reload
Success

Reiniciamos el servidor para que se apliquen los cambios

5. Instalamos Postfix

[root@localhost bxav]# yum install postfix.x86_64

En caso de estar instalado eliminarlo yum remove postfix

6. Editamos las siguientes líneas del archivo de configuración del postfix

[root@localhost bxav]# nano /etc/postfix/main.cf

## Línea 76 – Des comentar y agregar hostname del servidor


myhostname = mail.informatica.local

## Línea 83 – Des comentar y agregar el domino


mydomain = informatica.local
## Linea 99 – Des comentar
myorigin = $mydomain

## Linea 113 – Des comentar


inet_interfaces = all

## Linea 116 – Comentar


#inet_interfaces = localhost

## Linea 119 – Des comentar


inet_protocols = all

## Linea 164 – Comentar


#mydestination = $myhostname, localhost.$mydomain, localhost

## Linea 165 – Des comentar


mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

## Linea 264 – Des comentar y agregar el rango de IPs


mynetworks = 192.168.10.0/24, 127.0.0.0/8

## Linea 419 – Des comentar


home_mailbox = Maildir/

7. Habilitamos y reiniciamos el servicio de postfix

[root@localhost bxav]# systemctl enable postfix


[root@localhost bxav]# systemctl restart postfix

8. Creamos un usuario para probar el servidor de correo y le asignamos una


contraseña

[root@localhost bxav]# useradd user1


[root@localhost bxav]# passwd user1

9. Enviamos un correo de prueba

[root@localhost bxav]# echo Mensaje de prueba | mail -s "Prueba"


user1@informatica.local

Usando telnet

[root@localhost bxav]# telnet localhost smtp

Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.informatica.local ESMTP Postfix
ehlo localhost # Escribir esta linea
250-mail.informatica.local
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:<user1> # El usuario que envia el correo
250 2.1.0 Ok
rcpt to:<user1> # El usuario que recibe el correo
250 2.1.5 Ok
data # Para entrar a escribir el cuerpo del correo
354 End data with <CR><LF>.<CR><LF>
Mensaje de prueba # El cuerpo del correo
. # Para finalizer el correo
250 2.0.0 Ok: queued as E2B522032F93
quit # Para salir
221 2.0.0 Bye
Connection closed by foreign host.

10. Verificamos si el correo ha sido recibido

[root@localhost bxav]# ls /home/user1/Maildir/new/

1469380254.Vfd00I315cb1M394920.mail.informatica.local

11. Para leer el correo escribimos


[root@localhost bxav]# cat
/home/test/Maildir/new/1469380254.Vfd00I315cb1M394920.mail.informatica.local

Return-Path: <root@informatica.local>
X-Original-To: user1@informatica.local
Delivered-To: user1@informatica.local
Received: by mail.informatica.local (Postfix, from userid 0)
id 688F72420178; Sun, 24 Jul 2016 18:22:01 -0500 (ECT)
Date: Sun, 24 Jul 2016 18:22:01 -0500
To: user1@informatica.local
Subject: Prueba
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20160724232201.688F72420178@mail.informatica.local>
From: root@informatica.local (root)

Mensaje de prueba

Con esto finalizamos la configuración del postfix

12. Instalamos el repositorio de EPEL

[root@localhost bxav]# yum install epel-release -y

13. Instalamos el programa dovecot.

[root@localhost bxav]# yum install dovecot.x86_64 -y

Editamos el archivo de configuración de dovecot /etc/dovecot/dovecot.conf

[root@localhost bxav]# nano /etc/dovecot/dovecot.conf

## Línea 24 – Des comentar


protocols = imap pop3 lmtp

14. Editamos el archivo /etc/dovecot/conf.d/10-mail.conf

[root@localhost bxav]# nano /etc/dovecot/conf.d/10-mail.conf


## Línea 24 – Des comentar
mail_location = maildir:~/Maildir

15. Editamos el archivo /etc/dovecot/conf.d/10-auth.conf

[root@localhost bxav]# nano /etc/dovecot/conf.d/10-auth.conf

## Línea 10 – Des comentar


disable_plaintext_auth = no

## Línea 100 – Agregar “login”


auth_mechanisms = plain login

16. Editamos el archivo /etc/dovecot/conf.d/10-ssl.conf

[root@localhost bxav]# nano /etc/dovecot/conf.d/10-ssl.conf

## Línea 8 – Poner yes


ssl = yes

17. Editamos el archivo /etc/dovecot/conf.d/10-master.conf

[root@localhost bxav]# nano /etc/dovecot/conf.d/10-master.conf

## Línea 91 y 92 – Des comentar y agregar postfix


unix_listener auth-userdb {
#mode = 0666
user = postfix
group = postfix
}

18. Habilitamos y reiniciamos el servicio de dovecot

[root@localhost bxav]# systemctl enable dovecot

Created symlink from /etc/systemd/system/multi-


user.target.wants/dovecot.service to /usr/lib/systemd/system/dovecot.service.

[root@localhost bxav]# systemctl start dovecot

19. Probar dovecot

[root@localhost bxav]# telnet localhost pop3

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user user1 ## Ingrese el usuario al que se envió el correo
+OK
pass SO-xavier. ## La contraseña del usuario
+OK Logged in.
list ## Lista los mensaje que tiene el usuario
+OK 1 messages:
1 579
retr 1 ## Para ver el correo
+OK 579 octets
Return-Path: <root@informatica.local>
X-Original-To: test@informatica.local
Delivered-To: test@informatica.local
Received: by mail.informatica.local (Postfix, from userid 0)
id 51B8221E3FF8; Sun, 24 Jul 2016 13:51:43 -0500 (ECT)
Date: Sun, 24 Jul 2016 13:51:43 -0500
To: test@informatica.local
Subject: Prueba
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20160724185143.51B8221E3FF8@mail.informatica.local>
From: root@informatica.local (root)

Mensaje de prueba
.
quit ## Para salir
+OK Logging out.
Connection closed by foreign host.

20. Para finalizar verificamos que tenemos conexión con el servidor DNS

[root@localhost bxav]# ping -c4 192.168.10.1

Cliente 1 (Client)

3. Agregamos la dirección del servidor DNS en el archivo /etc/resolv.conf

[root@localhost bxav]# nano /etc/resolv.conf

search informática.local
nameserver 192.168.10.1

4. Verificamos que exista conexión con el servidor de correo

[root@localhost bxav]# ping -c4 192.168.10.100

PING 192.168.10.100 (192.168.10.100) 56(84) bytes of data.


64 bytes from 192.168.10.100: icmp_seq=1 ttl=64 time=0.347 ms
64 bytes from 192.168.10.100: icmp_seq=2 ttl=64 time=0.455 ms
64 bytes from 192.168.10.100: icmp_seq=3 ttl=64 time=0.761 ms
64 bytes from 192.168.10.100: icmp_seq=4 ttl=64 time=0.349 ms

--- 192.168.10.100 ping statistics ---


4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.347/0.478/0.761/0.169 ms

5. Verificamos que está funcionando el servidor DNS

[bxav @localhost bxav]# nslookup 192.168.10.100

Server: 192.168.10.1
Address: 192.168.10.1#53

100.10.168.192.in-addr.arpa name = mail.informatica.local.

6. Como usuario normal iniciamos y configuramos el cliente de correo Evolution

[bxav @localhost bxav]# evolution --force-online


Le damos en el botón de Enviar / Recibir
Esperamos a que aparezca una ventana para iniciar sección con el usuario user1
7. Creamos otro usuario en el servidor de correo

[bxav @localhost bxav]# useradd user2


[bxav @localhost bxav]# passwd user2

8. Enviamos un correo al user2 desde la opción de Nuevo de evolution

Agregamos el user2 al cliente de evolution


Repetimos lo mismo que para el user1
Iniciamos sección al igual que lo mismo con user1 para el user2
LDAP

Escenario

- Servidor LDAP
o IP = 10.3.0.40/16
o Hostname = ldap.informatica.local
- Cliente
o IP = 10.3.1.1 /16

Servidor LDAP:

1. Agregar el hostname en el archivo /etc/hosts

[root@localhost bxav]# nano /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4


::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.3.0.40 ldap.informatica.local ldap

2. Deshabilitamos el SELinux para reducir la complejidad en la configuración

[root@localhost bxav]# nano /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.


# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are
pr$
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
3. Instalar la aplicación de OpenLDAP

[root@localhost bxav]# yum install openldap openldap-clients openldap-servers


migrationtools -y

4. Habilitamos e iniciamos los servicios de OpenLDAP.

[root@localhost bxav]# systemctl enable slapd

Created symlink from /etc/systemd/system/multi-user.target.wants/slapd.service


to /usr/lib/systemd/system/slapd.service.

[root@localhost bxav]# systemctl start slapd

5. Copiamos la base de datos de ejemplo LDAP al siguiente directorio /var/lib/ldap.


y cambiamos de dueño a dicho directorio.

[bxav@localhost bxav]# cp /usr/share/openldap-servers/DB_CONFIG.example


/var/lib/ldap/DB_CONFIG

[bxav@localhost bxav]# chown -R ldap:ldap /var/lib/ldap

6. Asignamos una contraseña de administrador para el OpenLDAP lo copiamos y lo


guardamos.

[root@localhost bxav]# slappasswd

New password:
Re-enter new password:
{SSHA}eFLAVB+svk7HOjsLNwTs3czRrIvZx3JT

7. Creamos un archivo de configuración en el escritorio ldapadminpasswd.ldif con


la clave que nos generó el comando anterior y agregamos el siguiente contenido.

dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}eFLAVB+svk7HOjsLNwTs3czRrIvZx3JT

8. Agregamos los datos del archivo creado a la configuración de LDAP

[root@localhost bxav]# ldapadd -Y EXTERNAL -H ldapi:/// -f


ldapadminpasswd.ldif

SASL/EXTERNAL authentication started


SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={0}config,cn=config"

9. Agregamos otras shema’s básicas

[root@localhost bxav]# ldapadd -Y EXTERNAL -H ldapi:/// -f


/etc/openldap/schema/cosine.ldif

SASL/EXTERNAL authentication started


SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=cosine,cn=schema,cn=config"

[root@localhost bxav]# ldapadd -Y EXTERNAL -H ldapi:/// -f


/etc/openldap/schema/nis.ldif

SASL/EXTERNAL authentication started


SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=nis,cn=schema,cn=config"

[root@localhost bxav]# ldapadd -Y EXTERNAL -H ldapi:/// -f


/etc/openldap/schema/inetorgperson.ldif

SASL/EXTERNAL authentication started


SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=inetorgperson,cn=schema,cn=config"

10. Creamos otro archivo ldapdomain.ldif para agregar los datos de nuestro dominio

dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by
dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
read by dn.base="cn=Manager,dc=informatica,dc=local" read by * none

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=informatica,dc=local

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=informatica,dc=local

dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}eFLAVB+svk7HOjsLNwTs3czRrIvZx3JT

dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
dn="cn=Manager,dc=informatica,dc=local" write by anonymous auth by self write
by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=mydomain,dc=com" write by * read

11. Agregamos los datos del archivo creado a la configuración de LDAP

[root@localhost bxav]# ldapmodify -Y EXTERNAL -H ldapi:/// -f ldapdomain.ldif

SASL/EXTERNAL authentication started


SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}monitor,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"


modifying entry "olcDatabase={2}hdb,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"

12. Creamos otro archivo ldapdomain.ldif para crear el dominio base de LDAP

dn: dc=informatica,dc=local
objectClass: top
objectClass: dcObject
objectclass: organization
o: informatica local
dc: informatica

dn: cn=Manager,dc=informatica,dc=local
objectClass: organizationalRole
cn: Manager
description: Directory Manager

dn: ou=People,dc=informatica,dc=local
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=informatica,dc=local
objectClass: organizationalUnit
ou: Group

13. Agregamos los datos del archivo creado a la configuración de LDAP

[root@localhost bxav]# ldapadd -x -D cn=Manager,dc=informatica,dc=local -W -f


ldapbasedomain.ldif

Enter LDAP Password: ## Passwd del administrador del LDAP

adding new entry "dc=informatica,dc=local"

adding new entry "cn=Manager,dc=informatica,dc=local"

adding new entry "ou=People,dc=informatica,dc=local"

adding new entry "ou=Group,dc=informatica,dc=local"

14. Creamos un usuario y un archivo para la configuración ldapgroup.ldif del grupo


de LDAP

[root@localhost bxav]# adduser ldapuser1

[root@localhost bxav]# gedit ldapgroup.ldif

dn: cn=Manager,ou=Group,dc=informatica,dc=local
objectClass: top
objectClass: posixGroup
gidNumber: 1001

El gidNumber se encuentra en el archivo /etc/group generalmente al final

ldapuser1:x:1001:

15. Cargamos el archivo con el siguiente comando.

[root@localhost bxav]# ldapadd -x -W -D "cn=Manager,dc=informatica,dc=local" -


f ldapgroup.ldif
Enter LDAP Password:

adding new entry "cn=Manager,ou=Group,dc=informatica,dc=local"

16. Creamos el archivo de configuración LDIF para el usuario

[root@localhost bxav]# gedit ldapuser1.ldif

dn: uid=ldapuser1,ou=People,dc=informatica,dc=local
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: ldapuser1
uid: ldapuser1
uidNumber: 1001
gidNumber: 1001
homeDirectory: /home/ldapuser1
userPassword: {SSHA}O4aumDM8Bml0cvdhSkk9dS2/dVtywNcn
loginShell: /bin/bash
gecos: ldapuser1
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0

17. Cargamos el archivo con el siguiente comando.

[root@localhost bxav]# ldapadd -x -D cn=Manager,dc=informatica,dc=local -W -f


ldapuser1.ldif

Enter LDAP Password:

adding new entry "uid=ldapuser1,ou=People,dc=informatica,dc=local"

Puede eliminar el usuario con la siguiente entrada


[root@localhost bxav]# ldapdelete -x -W -D cn=Manager,dc=informatica,dc=local
"uid=ldapuser1,ou=People,dc=informatica,dc=local"

18. Agregamos la excepción del servicio de LDAP al firewall junto con el puerto 389/tcp
y lo reiniciamos

[root@localhost bxav]# firewall-cmd --permanent --add-service=ldap

[root@localhost bxav]# firewall-cmd --permanent --add-port=389/tcp

[root@localhost bxav]# firewall-cmd --reload

19. Reiniciamos el servicio de LDAP

[root@localhost bxav]# firewall-cmd --permanent --add-service=ldap

Cliente:

1. Instalamos el servicio de LDAP

[root@localhost bxav]# yum install openldap openldap-clients nss-pam-ldapd -y


2. Verificamos que tenga conexión con el servidor LDAP

[root@localhost bxav]# ping -c4 10.3.0.40

3. Habilitamos la autentificación con LDAP

[root@localhost bxav]# authconfig --enableldap --enableldapauth --


ldapserver=ldap.informatica.local --ldapbasedn="dc=informatica,dc=local" --
enablemkhomedir --update

4. Reiniciamos he iniciamos con los usuarios creados.

Bibliografía:
- https://www.unixmen.com/setting-dns-server-centos-7/
- https://www.digitalocean.com/community/tutorials/how-to-
configure-bind-as-a-private-network-dns-server-on-centos-7

S-ar putea să vă placă și