Configurar Servidores Linux v.2.2

Elaborado por: Fecha actualización: Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011 PROCEDIMIENTO DE PREPARACION DE S

Views 223 Downloads 64 File size 357KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

PROCEDIMIENTO DE PREPARACION DE SERVIDOR LINUX 1.

Modificar en el BIOS del servidor para arranque primero desde el disco duro

2. Modificar en el BIOS en la opción Advanced Chipset Control fijando el parámetro como Sata Raid Enable, asi el disco duro será reconocido como SATA (/dev/sda) 3.

Instalar el servidor en la opción Server-GUI

4.

Fijar el huso horario en América La Paz, quitando la opcion UTC

5.

Fijar contraseña del usuario administrador root en utepsa

6.

Luego de la instalacion ingresar al servidor Linux mediante una consola

7.

Deshabilitar el firewall

# chkconfig iptables off # service iptables stop

8.

Deshabilitar el SELinux

# vi /etc/selinux/config # 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 - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted

9. Modificar el archivo /etc/modprobe.conf para deshabilitar el soporte para ipv6 adicionando parámetros # vi /etc/modprobe.conf alias eth0 tg3 alias scsi_hostadapter ahci alias scsi_hostadapter1 ata_piix alias net-pf-10 off alias ipv6 off

10.

Deshabilitar todos los servicios

LANG=C runlevel chkconfig --list | grep 5:on | awk '{ print $1 }' > servicios.txt for i in $(cat servicios.txt); do chkconfig $i off; done

11.

Habilitar los servicios básicos

chkconfig chkconfig chkconfig chkconfig chkconfig chkconfig chkconfig chkconfig chkconfig

network on iptables on dhcpd on squid on sshd on crond on syslog on haldaemon on messagebus on

Elaborado por: Fecha actualización: 12.

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

Listar servicios activos en el arranque

# chkconfig --list | grep 5:on crond 0:off 1:off haldaemon 0:off 1:off messagebus 0:off 1:off network 0:off 1:off sshd 0:off 1:off syslog 0:off 1:off

13.

2:on 2:on 2:on 2:on 2:on 2:on

3:on 3:on 3:on 3:on 3:on 3:on

4:on 4:on 4:on 4:on 4:on 4:on

5:on 5:on 5:on 5:on 5:on 5:on

6:off 6:off 6:off 6:off 6:off 6:off

Crear directorios de trabajo

# mkdir -p {bin,conf,targz,rpms}

14.

Crear los scripts de trabajo

# cd /root/bin # vi tailm tail -n 30 -f /var/log/messages # chmod +x /root/bin/tailm # vi visor tail -n 30 -f /var/log/squid/access.log # chmod +x visor

15.

Adicionar al final del archivo /etc/bashrc un alias del comando ls

# alias l='ls -lhF'

16.

Modificar los parámetros de arranque del sistema en el archive /etc/grub.conf

# vi /etc/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/VolGroup01/LogVol00 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=3 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.18-164.el5) root (hd0,0) kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/VolGroup01/LogVol00 initrd /initrd-2.6.18-164.el5.img

17.

Modificar el nombre de host del servidor Linux y el parámetro de ZEROCONF

# vi /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=alumno NOZEROCONF=yes VLAN=yes

18.

Modificar el archivo /etc/hosts para resolver el nombre del servidor Linux “lacancha.fassil.com.bo” vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost alumno

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

19. HABILITAR EL ACCESO VNC a. Fijar password para el acceso mediante vnc # vncpasswd Password: Verify: b. Habilitar el servicio vnc en el servicio vncserver :5 c. Para terminar el servicio vnc vncserver –kill :5 d. Editar archivo de configuración del vnc cd vi .vnc/xstartup #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic &

# xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & # twm & gnome-session &

20.

Sacar una imagen del DVD instalador del software CentOS Linux mkdir /media/CentOS mkdir /isos umount /dev/cdrom readcd f=/isos/CentOS-5.4-x86_64.iso Read speed: 22160 kB/s (CD 125x, DVD 16x). Write speed: 0 kB/s (CD 0x, DVD 0x). Capacity: 2255600 Blocks = 4511200 kBytes = 4405 MBytes = 4619 prMB Sectorsize: 2048 Bytes Copy from SCSI (4,0,0) disk to file '/isos/CentOS-5.4-x86_64.iso' end: 2255600 addr: 2255600 cnt: 48 Time total: 304.287sec Read 4511200.00 kB at 14825.5 kB/sec.

Elaborado por: Fecha actualización: 21.

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

Modificar el nivel de arranque del servidor Linux para que inicie en modo 3 Full multiuser texto vi /etc/inittab

# inittab # # # Author: # #

This file describes how the INIT process should set up the system in a certain run-level. Miquel van Smoorenburg, Modified for RHS Linux by Marc Ewing and Donnie Barnes

# Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc l1:1:wait:/etc/rc.d/rc l2:2:wait:/etc/rc.d/rc l3:3:wait:/etc/rc.d/rc l4:4:wait:/etc/rc.d/rc l5:5:wait:/etc/rc.d/rc l6:6:wait:/etc/rc.d/rc

0 1 2 3 4 5 6

# Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now # When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # UPS connected and working correctly. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down" # If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled" # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 # Run xdm in runlevel 5 x:5:respawn:/etc/X11/prefdm –nodaemon

Recargar el archive de configuracion /etc/inittab init q 22.

Reiniciar el servidor Linux reboot

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

CONFIGURAR LA RED PARA QUE TENGA ACCESO A INTERNET Utilice el comando setup

Seleccione la tarjeta que quiere configurar (usualmente es la eth0)

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

Configure estos datos de acuerdo a su red.

Salga guardando los cambios hasta que vuelva a esta pantalla

Configure los DNS de acuerdo a su conexión a internet (aquí se muestran los DNS de CotasNet)

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

Por ultimo guarde los cambios

Reinicie el servicio de red service network restart

Compruebe que tiene conexión a internet y continue 1. a.

Instalar el acceso a los repositorios de software Repositorio EPEL http://fedoraproject.org/wiki/EPEL

Descargar el paquete del repo EPEL # wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm Instalar paquete de definición de acceso al repo EPEL # rpm -ivh epel-release-5-4.noarch.rpm

b.

Repositorio RPMFORGE http://rpmrepo.org/RPMforge/Using

Descargar el paquete del repo RPMFORGE # wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm Instalar paquete de definición de acceso al repo RPMFORGE # rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

2. INSTALAR SOFTWARE DESDE LA IMAGEN ISO DEL DVD INSTALADOR Montar la imagen del instalador de Linux mount -o loop /isos/CentOS-5.4-x86_64.iso /media/CentOS/ Si usa una PC Virtual, primero introduzca el CD en la PC Virtual (o monte una ISO en el lector) mount -o loop /dev/cdrom /media/CentOS/ Instalar el software desde la imagen yum --disablerepo=* --enablerepo=c5-media install dhcp -y Desmontar imagen umount /media/CentOS 3. SERVICIO VPN yum install openvpn -y

SERVICIO FIREWALL Crear archivo vi /etc/rc.d/rc.firewall #!/bin/sh echo ## SCRIPT de IPTABLES ##Declaramos una variable $IPT para utlizarla mas adelante IPT="/sbin/iptables" echo -n Aplicando Reglas de Firewall... ## FLUSH de reglas $IPT -F $IPT -X $IPT -Z $IPT -t nat -F

echo -n Estableciendo politica por defecto.... ## Establecemos politica por defecto $IPT -P INPUT ACCEPT $IPT -P OUTPUT ACCEPT $IPT -P FORWARD ACCEPT $IPT -t nat -P PREROUTING ACCEPT $IPT -t nat -P POSTROUTING ACCEPT

############################################## ########### PREROUTUING ############## ##############################################

############################################## ########### INPUT ############## ##############################################

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

$IPT -A INPUT -i lo $IPT -A INPUT -m state --state RELATED,ESTABLISHED

-j ACCEPT -j ACCEPT

############################################## ########### OUTPUT ############## ##############################################

############################################## ########### FORWARD ############## ############################################## $IPT -A FORWARD -m state --state RELATED,ESTABLISHED ############################################## ########### POSTROUTUING ############## ##############################################

echo " OK" # Fin del script service iptables save echo

Dar permiso de ejecucion chmod +x /etc/rc.d/rc.firewall Ejecutar el firewall sh /etc/rc.d/rc.firewall Que el servicio se inicie al levantar el Servidor chkconfig iptables on

PROCEDIMIENTO PARA HABILITAR RE-ENVIO DE PAQUETES Editar el archivo vi /etc/sysctl.conf # Controls IP packet forwarding net.ipv4.ip_forward = 1

-j ACCEPT

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

PROCEDIMIENTO PARA HABILITAR EL SYSLOG PARA EQUIPAMIENTO CISCO Modificar vi /etc/sysconfig/syslog # Options to syslogd # -m 0 disables 'MARK' messages. # -r enables logging from remote machines # -x disables DNS lookups on messages recieved with -r # See syslogd(8) for more details SYSLOGD_OPTIONS="-m 0 -r" # Options to klogd Adicionar al final del archivo vi /etc/syslog.conf ####################Cisco syslog mensajes local1.* /var/log/cisco1 local2.* /var/log/cisco2 local3.* /var/log/cisco3 local4.* /var/log/cisco4 local5.* /var/log/cisco5 local6.* /var/log/cisco6 local7.* /var/log/cisco7 Reiniciar el servicio service syslog restart

PROCEDIMIENTO PARA SINCRONIZAR EL RELOJ DIARIAMENTE Crear el archivo vi /etc/cron.daily/ntp

#!/bin/bash /usr/sbin/ntpdate -u 0.south-america.pool.ntp.org Darle permiso de ejecucion

chmod +x /etc/cron.daily/ntp Ejecutar el archivo

sh /etc/cron.daily/ntp

Elaborado por: Fecha actualización:

Ing. Jose Miguel Cabrera Dalence 07/Octubre/2011

PROCEDIMIENTO PARA HABILITAR LLAVES COMPARTIDAS Generar llaves No debe colocar ninguna contraseña, simplemente ENTER a todo ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 32:cd:4f:cb:bc:ed:1e:4b:0c:ea:81:2b:c6:9f:cb:03 Copiar llave publica al destino (PC que quiere acceder sin contraseña) cd /root/.ssh scp id_rsa.pub [email protected]:/root/.ssh/MI_LLAVE [email protected]'s password: Si esto falla generalmente es porque no tiene la carpeta creada, entonces deberán conectarse primeramente por ssh, crear la carpeta, salirse y volver a intentar. ssh –l root 192.168.xx.10 mkdir /root/.ssh exit De regreso a mi servidor, vuelvo a intentar copiar mi llave publica cd /root/.ssh scp id_rsa.pub [email protected]:/root/.ssh/MI_LLAVE Una vez copiado debemos adicionar la llave a la lista de llaves autorizadas. ssh –l root 192.168.xx.10 cd /root/.ssh cat MI_LLAVE >> authorized_keys Listo, ya puedes conectarte por ssh o pasar archive mediante scp y no te pedira contraseña