Una buena opción para la autenticación de usuarios en una red linux es la utilización de NIS. Aquí vemos detalles de la configuración del servidor y los clientes (Redhat / CentOS / Fedora).
Instalación y Configuración del Servidor NIS:
Instalamos los paquetes necesarios:
# yum install ypbind yp-tools ypserv
En el /etc/yp.conf agregamos la siguiente línea:
ypserver 127.0.0.1
En el /etc/ypserv.conf verificamos que exista la siguiente configuración:
dns: no
files: 30
xfr_check_port: yes
* : * : shadow.byname : port
* : * : passwd.adjunct.byname : port
En el /etc/sysconfig/network agregamos la siguiente línea:
NISDOMAIN=”dominio.net”
Editamos el /var/yp/securenets para definir la red con que trabajamos agregando las siguientes lineas:
host 127.0.0.1
255.255.255.0 192.168.0.0
Reiniciamos servicios portmap e ypserv:
# service portmap restart
# service ypserv restart
y verificamos que el ypserv se inicie al arranque del systema:
# chkconfig –level 2345 ypserv on
para verificar que el programa está funcionando podemos poner:
# rpcinfo -u localhost ypserv y si todo está ok, la respuesta será:
program 100004 version 1 ready and waiting
program 100004 version 2 ready and waiting
Procedemos ahora a crear los mapas NIS que almacenaran toda la información del servicio:
# /usr/lib/yp/ypinit -m
en plataformas de 64 bits será:
# /usr/lib64/yp/ypinit -m
Este comando solicitará el nombre del servidor NIS y luego regenerará la base de datos NIS de usuarios, grupos, etc. La salida será algo como esto:
At this point, we have to construct a list of the hosts which will run NIS
servers. server0 is in the list of NIS server hosts. Please continue to add
the names for the other hosts, one per line. When you are done with the
list, type a .
next host to add: server0
next host to add:
The current list of NIS servers looks like this:
server0
Is this correct? [y/n: y] y
We need a few minutes to build the databases…
Building /var/yp/dominio.net/ypservers…
Running /var/yp/Makefile…
gmake[1]: Entering directory `/var/yp/dominio.net’
Updating passwd.byname…
Updating passwd.byuid…
Updating group.byname…
Updating group.bygid…
Updating hosts.byname…
Updating hosts.byaddr…
Updating rpc.byname…
Updating rpc.bynumber…
Updating services.byname…
Updating services.byservicename…
Updating netid.byname…
Updating protocols.bynumber…
Updating protocols.byname…
Updating mail.aliases…
gmake[1]: Leaving directory `/var/yp/dominio.net’
server0 has been set up as a NIS master server.
Now you can run ypinit -s server0 on all slave server.
Ahora starteamos el resto de los servicios para arrancar el NIS:
# service ypbind start
# service yppasswd start
# service ypxfrd start
Y agregamos estos servicios al arranque:
# chkconfig –level 2345 ypbind on
# chkconfig –level 2345 yppasswdd on
# chkconfig –level 2345 ypxfrd on
Configuración de puertos estáticos para el servidor NIS:
Si tenemos iptables corriendo en el servidor NIS, debemos hacer que la apertura de puertos sea estática.
Agregamos la siguiente línea en el /etc/sysconfig/network:
YPSERV_ARGS=”-p 834″ YPXFRD_ARGS=”-p 835″
Y abrimos los puertos 834 y 835:
iptables -A INPUT -p ALL -s! 192.168.0.0/24 –dport 834 -j DROP iptables -A INPUT -p ALL -s! 192.168.0.0/24 –dport 835 -j DROP
Pruebas:
En el cliente, si hacemos un:
$ ypcat passwd
veremos la info de usuario que está siendo publicada por el servidor NIS.
Otro comando util es:
$ rpcinfo -p servidornis
que nos muestra todos los puertos y protocolos donde está escuchando:
program vers proto port service
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 970 status
100024 1 tcp 973 status
100004 2 udp 834 ypserv
100004 1 udp 834 ypserv
100004 2 tcp 834 ypserv
100004 1 tcp 834 ypserv
600100069 1 udp 835 fypxfrd
600100069 1 tcp 835 fypxfrd
100009 1 udp 944 yppasswdd
Configuración de los clientes:
Los clientes necesitan tener instalado el ypbind y el yp-tools:
# yum install ypbind yp-tools
Editamos el /etc/yp.conf agregando la siguiente linea:
domain dominio.net server 192.168.0.54
Debemos asegurarnos que en el archivo /etc/hosts, están definidos los datos del servidor NIS:
192.168.0.54 server0.dominio.net
Restarteamos el servicio y enlazamos con el servidor:
#service ypbind start
Pingback: Home’s Centralizados / Configuring Centralized Home Directories | hvivani's website