miércoles, 27 de noviembre de 2013

Ruta estática en Linux Centos

Si tenemos configurada la interface eth0, entonces tendremos que agregar el siguiente archivo, si quisieramos agregar una ruta a la eth1 usaríamos lo mismo pero llamarlo route-eth1 y así sucesivaente:

Editamos el archivo y colocamos también dentro de el los siguientes campos: direcciónN, netmaskN, gatewayN, donde N corresponde al número de interface como el siguiente ejemplo:

[root@server ~]# vi /etc/sysconfig/network-scripts/route-eth0
ADDRESS0=192.168.1.0
NETMASK0=255.255.255.0
GATEWAY0=110.120.130.140

Reiniciamos el servicio de red y listo:

[root@server ~]# /etc/init.d/network restart

Probamos la conectividad a la nueva red:

[root@server ~]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=254 time=13.3 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=254 time=9.94 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=254 time=10.4 ms


miércoles, 6 de noviembre de 2013

Remplazando Texto en Unix

Con el comando sed:

sed "s/hola/chau/g" morsa.txt > morsa.tmp; mv morsa.tmp morsa.txt


Con perl:

perl -pi -e 's/hola/chau/g' morsa.txt


miércoles, 25 de septiembre de 2013

Disk Storage IBM Storwize V3700 Monitoring with Nagios:


Descargué el plugin llamado check_ibm_v7000.sh de:

http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=3157&cf_id=24


Probé primero que funcione desde el bash ejecutando, lo siguiente, donde -M es la ip del storage, -U user (debe existir en el storage) y -Q la consulta:

# /ruta/del/plugins/check_ibm_v7000.sh -M 192.168.0.100 -U nagios -Q lsdrive
Password:


En este caso me devolvió que tengo el disco 9 dañado en el storage:

CRITICAL: Disk OFFLINE
 OK: Drive 0 is online
 OK: Drive 1 is online
 OK: Drive 2 is online
 OK: Drive 3 is online
 OK: Drive 4 is online
 OK: Drive 5 is online
 OK: Drive 6 is online
 OK: Drive 7 is online
 OK: Drive 8 is online
 ATTENTION: Disk 9
status:
role: failed
type: sas_hdd
capacity: 558.4GB
enclosure:
slot:   OK: Drive 10 is online
 OK: Drive 11 is online
 OK: Drive 12 is online
 OK: Drive 13 is online
 OK: Drive 14 is online
 OK: Drive 15 is online
 OK: Drive 16 is online
 OK: Drive 17 is online
 OK: Drive 18 is online
 OK: Drive 19 is online
 OK: Drive 20 is online
 OK: Drive 21 is online
 OK: Drive 22 is online
 OK: Drive 23 is online
 OK: Drive 24 is online
 OK: Drive 25 is online
 OK: Drive 26 is online
 OK: Drive 27 is online
 OK: Drive 28 is online
 OK: Drive 29 is online
 OK: Drive 30 is online
 OK: Drive 31 is online
 OK: Drive 32 is online
 OK: Drive 33 is online
 OK: Drive 34 is online
 OK: Drive 35 is online
 OK: Drive 36 is online
 OK: Drive 37 is online
 OK: Drive 38 is online
 OK: Drive 39 is online
 OK: Drive 40 is online
 OK: Drive 41 is online
 OK: Drive 42 is online
 OK: Drive 43 is online
 OK: Drive 44 is online
 OK: Drive 45 is online
 OK: Drive 46 is online
 OK: Drive 47 is online


Nos logueamos al server donde tenemos instalado nagios con el usuario nagios y generamos las keys para que no nos pida password:

# su - nagios
$ cd /home/nagios/.ssh/
$ ssh-keygen
$ ls
id_rsa  id_rsa.pub  known_hosts


Copiamos la llave pública por winscp a nuestro equipo: id_rsa.pub para luego importarla al storage por web, vamos a usuarios:



Creamos un nuevo usuario en el grupo monitor:


Le asignamos un nombre, en mi caso nagios, que use autenticación local:


Importamos la llave pública generada en el server de monitoreo para el usuario nagios:


Quedándonos así:



Agregamos el host al nagios:

# vim /ruta/del/nagios/hosts.cfg
define host{
        use                     linux-server
        host_name               STORAGE
        alias                   STORAGE
        address                 192.168.0.100
        }


Parametrizamos el comando:

# vim /ruta/del/nagios/commands.cfg
define command{
command_name check_storage
command_line $USER1$/check_ibm_v7000.sh -M $HOSTADDRESS$ -U $ARG1$ -Q $ARG2$
}


Configuramos el Servicio:

# vim /ruta/del/nagios/services.cfg
define service{
use                             generic-service
host_name                       STORAGE
service_description             STORAGE_DISKs
check_command                   check_storage!nagios!lsdrive
}

lunes, 12 de agosto de 2013

Clonar Máquina Virtual en VMware ESXi 5

Nos logueamos al vSphere Client y vamos a "Configuración"



Vamos a la solapa izquierda y seleccionamos "Storage", hacemos click derecho sobre datastore y "Browse Datastore..."



Creamos una nueva carpeta haciendo click en el cuadro rojo:



Elegimos el nombre que deseamos:



Copiamos desde la carpeta origen todos los archivos que terminen en .vmx y en .vmdk:



Seleccionamos la carpeta destino y luego "Pegar":



Esperamos que terminen de copiar los files:



Una vez copiada, boton derecho sobre el .vmx y "Add to Inventory":



Ingresamos el nombre de la Virtual y "Next":



Elegimos el ESXi server de la lista, "Next" nuevamente:



"Finish":



Tildamos sobre "I copied it" y "Ok":



jueves, 8 de agosto de 2013

Proxy Reverso para Glassfish con Apache

Ya he explicado como hacer un reverse proxy en el anterior post:

http://www.redes-seguridad.com.ar/2013/08/reverse-proxy-con-apache-2-en-debian.html


Pero con Glassfish no me funcionaba así que habilité el módulo  "rewrite":

# a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!


Reiniciamos apache:

# /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .


Editamos la config del apache:

# vim /etc/apache2/httpd.conf

 ProxyPreserveHost on
 RewriteEngine on
 ProxyPass /glassfish http://mi_glassfish.com.ar:8080/
 ProxyPassReverse /crp http://mi_glassfish.com.ar:8080/
 Redirect / http://mi_glassfish.com.ar:8080/
 RewriteRule ^/(.*) mi_glassfish.com.ar:8080/$1 [P,L]


Reiniciamos apache:

# /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .


Fuente: http://czetsuya-tech.blogspot.com.ar/2012/07/how-to-port-forward-apaches-80-to.html#.UfkTqvkyaN1


Reverse Proxy con Apache 2 en Debian

Instalamos modulo para apache:

# apt-get install libapache2-mod-proxy-html
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common file
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcap2
  libdb4.7 libexpat1 libgcrypt11 libgnutls26 libgpg-error0 libldap-2.4-2
  libmagic1 libpcre3 libsasl2-2 libsasl2-modules libtasn1-3 libxml2
  mime-support openssl perl perl-modules sgml-base ssl-cert xml-core
Suggested packages:
  www-browser apache2-doc apache2-suexec apache2-suexec-custom rng-tools
  gnutls-bin libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
  libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal ca-certificates
  perl-doc libterm-readline-gnu-perl libterm-readline-perl-perl make
  sgml-base-doc openssl-blacklist debhelper
The following NEW packages will be installed:
  apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common file
  libapache2-mod-proxy-html libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap libcap2 libdb4.7 libexpat1 libgcrypt11 libgnutls26
  libgpg-error0 libldap-2.4-2 libmagic1 libpcre3 libsasl2-2 libsasl2-modules
  libtasn1-3 libxml2 mime-support openssl perl perl-modules sgml-base ssl-cert
  xml-core
0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.9 MB of archives.
After this operation, 55.3 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y


Configuramos el httpd con lo siguiente:

# vim /etc/apache2/httpd.conf
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
LoadModule proxy_ftp_module /usr/lib/apache2/modules/mod_proxy_ftp.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
ProxyRequests Off

    Order deny,allow
    Allow from all

ProxyPass /web http://www.mi_web_server.com.ar/
ProxyPassReverse /web http://www.mi_web_server.com.ar/
ProxyPreserveHost On


Reiniciamos apache:


# /etc/init.d/apache2 restart
Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.1 for ServerName


Para solucionar el warning previo, editamos el archivo de configuración de apache:

# vim /etc/apache2/apache2.conf
ServerName nombre_server


Reiniciamos el apache y vemos que ahora no aparece el warning:

# /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .

Fuente: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html


domingo, 4 de agosto de 2013

Instalar Glassfish 3 en Debian Squeeze



Agregamos el usuario, grupo, el home y el shell:

# adduser --home /home/glassfish --system --shell /bin/bash glassfish

# groupadd glassfishadm

# usermod -a -G glassfishadm root


Instalamos los requerimientos:

# apt-get install python-software-properties


Agregamos los repositorios:

# vim /etc/apt/sources.list
deb http://ftp.ch.debian.org/debian/ squeeze main non-free

# apt-get update

# apt-get install sun-java6-jdk  sun-java6-jre

Damos OK:


Aceptamos la licencia:


# apt-get install unzip

# su glassfish

$ cd /home/glassfish

$ mkdir downloads

$ cd downloads

$ wget http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip

$ unzip glassfish-3.0.1.zip

# mkdir -p /usr/local/apps/SDK/glassfish

# mv /home/glassfish/downloads/glassfishv3/* /usr/local/apps/SDK/glassfish/

# chgrp -R glassfishadm /usr/local/apps/SDK/glassfish/

# chown -R glassfish /usr/local/apps/SDK/glassfish/

# chmod -R +x /usr/local/apps/SDK/glassfish/bin/

# chmod -R +x /usr/local/apps/SDK/glassfish/glassfish/bin/

# su glassfish


Iniciamos glassfish:

$ /usr/local/apps/SDK/glassfish/bin/asadmin start-domain domain1
Waiting for DAS to start ....
Started domain: domain1
Domain location: /usr/local/apps/SDK/glassfish/glassfish/domains/domain1
Log file: /usr/local/apps/SDK/glassfish/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.


Accedemos a la web de administración:

http://192.168.0.100:4848



Paramos el servicio:

$ /usr/local/apps/SDK/glassfish/bin/asadmin stop-domain domain1
Waiting for the domain to stop ...
Command stop-domain executed successfully.


Cambiamos el Master password:

$ /usr/local/apps/SDK/glassfish/bin/asadmin change-master-password --savemasterpassword=true
Enter New_Master_Password password> NuevoMasterPasswordEnter New_Master_Password password again> NuevoMasterPassword
Command change-master-password executed successfully.


Cambiamos el admin password:

Debe estar iniciado y ejecutar lo siguiente:

glassfish@glassfish:/root$ /usr/local/apps/SDK/glassfish/bin/asadmin change-admin-password
$ /usr/local/apps/SDK/glassfish/bin/asadmin change-admin-password
Enter admin user name [default: admin]>
Enter admin password>
Enter new admin password> NuevoPasswordAdminEnter new admin password again> NuevoPasswordAdmin
Command change-admin-password executed successfully.


Nos logueamos nuevamente al glassfish.


Instalamos sudo porque lo utilizaremos en el script:

# apt-get install sudo


Creamos el script para iniciarlo:
# vim /etc/init.d/glassfish

#! /bin/sh

#Agregar el path de java
export AS_JAVA=/usr/lib/jvm/java-6-sun

GLASSFISHPATH=/usr/local/apps/SDK/glassfish/bin/

case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1
#Reemplazar por la siguiente linea cuando habilite https:
#sudo -u glassfish $GLASSFISHPATH/asadmin --secure start-domain domain1
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1
#Reemplazar por la siguiente linea cuando habilite https:
#sudo -u glassfish $GLASSFISHPATH/asadmin --secure stop-domain domain1
;;
*)
echo $"usage: $0 {start|stop|restart}"
exit 3
;;
esac
:

# chmod a+x /etc/init.d/glassfish

# /etc/init.d/glassfish start
starting glassfish from /usr/local/apps/SDK/glassfish/bin/
Waiting for DAS to start ....
Started domain: domain1
Domain location: /usr/local/apps/SDK/glassfish/glassfish/domains/domain1
Log file: /usr/local/apps/SDK/glassfish/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.


Agregarlo al inicio:

# cd /etc/rc2.d/

# ln -s ../init.d/glassfish S99glassfish


FUENTES:
http://www.nabisoft.com/tutorials/glassfish/installing-glassfish-301-on-ubuntu
http://www.gurx.net/index.php?option=com_content&view=article&id=39:instalar-sun-java
http://packages.debian.org/es/squeeze/sun-java6-jre