lunes, 17 de junio de 2013

Cliente LDAP - ldapclient Unix Solaris 10


1) Backup del nsswitch.conf porque lo modifica:

# cp -pf /etc/nsswitch.conf /etc/nsswitch.conf.17-06-2013
# diff /etc/nsswitch.conf /etc/nsswitch.conf.17-06-2013


2) Ver si algún servicio está caído:

# svcs -xv
#


3) Ver servicio del ldap client:

# svcs -l /network/ldap/client:default
fmri         svc:/network/ldap/client:default
name         LDAP client
enabled      true
state        online
next_state   none
state_time   Fri Apr 05 09:46:28 2013
logfile      /var/svc/log/network-ldap-client:default.log
restarter    svc:/system/svc/restarter:default
contract_id  36
dependency   require_all/none svc:/system/filesystem/minimal (online)
dependency   require_all/none svc:/network/initial (online)
#


4) Ver la config y las estadiscitas del ldap_cachemgr:

# /usr/lib/ldap/ldap_cachemgr -g
cachemgr configuration:
server debug level          0
server log file "/var/ldap/cachemgr.log"
number of calls to ldapcachemgr       1560
cachemgr cache data statistics:
Configuration refresh information:
  Configured to NO REFRESH.
Server information:
  Previous refresh time: 2013/06/17 06:10:46
  Next refresh time:     2013/06/17 17:33:26
  server: 192.168.0.1, status: UP
Cache data information:
  Maximum cache entries:          256
  Number of cache entries:          0
#


5) Vemos la config del cliente de ldap, no debemos modificar el archivo, ya que se reescribirá si se modifica:

# cat /var/ldap/ldap_client_file
#
# Do not edit this file manually; your changes will be lost.Please use ldapclient (1M) instead.
#
NS_LDAP_FILE_VERSION= 2.0
NS_LDAP_SERVERS= 172.16.72.1
NS_LDAP_SEARCH_BASEDN= dc=redes-seguridad,dc=com,dc=ar
NS_LDAP_CACHETTL= 0
NS_LDAP_CREDENTIAL_LEVEL= anonymous
NS_LDAP_SERVICE_SEARCH_DESC= passwd:ou=Users,dc=redes-seguridad,dc=com,dc=ar?one
NS_LDAP_SERVICE_SEARCH_DESC= shadow:ou=Users,dc=redes-seguridad,dc=com,dc=ar?one
NS_LDAP_SERVICE_SEARCH_DESC= group:ou=Groups,dc=redes-seguridad,dc=com,dc=ar?one
NS_LDAP_ATTRIBUTEMAP= shadow:userpassword=userPassword
NS_LDAP_SERVICE_AUTH_METHOD= pam_ldap:tls:simple


6) Modificamos el cliente con el ldapclient:

Con el man vemos los parametros que son necesarios:

# man ldapclient

Ejemplo:

example# ldapclient manual \
       -a credentialLevel=proxy \
       -a authenticationMethod=sasl/CRAM-MD5 \
       -a proxyPassword=secret \
       -a proxyDN=cn=proxyagent,ou=profile,dc=xyz,dc=mycompany,dc=com \
       -a defaultSearchBase=dc=xyz,dc=mycompany,dc=com \
       -a domainName=xyz.mycompany.com \
       -a followReferrals=false \
       -a defaultServerList=172.16.100.1:386


7) Yo para mi red utilicé los siguientes, tener en cuenta que este comando modifica el /etc/nsswitch.conf:

/# ldapclient manual \
-a defaultServerList=10.11.12.13 \
-a defaultSearchBase=dc=redes-seguridad,dc=com,dc=ar \
-a credentialLevel=anonymous \
-a serviceSearchDescriptor=passwd:ou=Users,dc=redes-seguridad,dc=com,dc=ar?one \
-a serviceSearchDescriptor=shadow:ou=Users,dc=redes-seguridad,dc=com,dc=ar?one \
-a serviceSearchDescriptor=group:ou=Groups,dc=redes-seguridad,dc=com,dc=ar?one \
-a attributeMap=shadow:userpassword=userPassword \
-a serviceAuthenticationMethod=pam_ldap:tls:simple
System successfully configured


8) Vemos que se modificó el /etc/nsswitch.conf:

# diff /etc/nsswitch.conf /etc/nsswitch.conf.17-06-2013
24c24
< hosts:      ldap [NOTFOUND=return] files
---
> hosts:      files dns ldap [NOTFOUND=return]
28c28
< ipnodes:    ldap [NOTFOUND=return] files
---
> ipnodes:    files dns ldap [NOTFOUND=return]
30,36c30,36
< networks:   ldap [NOTFOUND=return] files
< protocols:  ldap [NOTFOUND=return] files
< rpc:        ldap [NOTFOUND=return] files
< ethers:     ldap [NOTFOUND=return] files
< netmasks:   ldap [NOTFOUND=return] files
< bootparams: ldap [NOTFOUND=return] files
< publickey:  ldap [NOTFOUND=return] files
---
> networks:   files ldap [NOTFOUND=return]
> protocols:  files ldap [NOTFOUND=return]
> rpc:        files ldap [NOTFOUND=return]
> ethers:     files ldap [NOTFOUND=return]
> netmasks:   files ldap [NOTFOUND=return]
> bootparams: files ldap [NOTFOUND=return]
> publickey:  files ldap [NOTFOUND=return]
38c38
< netgroup:   ldap
---
> netgroup:   files ldap


9) Volvemos a restaurar el que habíamos backupeado previamente:

# cp -pf /etc/nsswitch.conf.17-06-2013 /etc/nsswitch.conf 


10) Reiniciamos el server porque queda algo cacheado y el ping no resuelve correctamente:

# reboot


12) Testeamos que el ldapclient tenga la config de la nueva ip:

# ldapclient list
NS_LDAP_FILE_VERSION= 2.0
NS_LDAP_SERVERS= 10.11.12.13
NS_LDAP_SEARCH_BASEDN= dc=redes-seguridad,dc=com,dc=ar
NS_LDAP_CACHETTL= 0
NS_LDAP_CREDENTIAL_LEVEL= anonymous
NS_LDAP_SERVICE_SEARCH_DESC= passwd:ou=Users,dc=redes-seguridad,dc=com,dc=ar?one
NS_LDAP_SERVICE_SEARCH_DESC= shadow:ou=Users,dc=redes-seguridad,dc=com,dc=ar?one
NS_LDAP_SERVICE_SEARCH_DESC= group:ou=Groups,dc=redes-seguridad,dc=com,dc=ar?one
NS_LDAP_ATTRIBUTEMAP= shadow:userpassword=userPassword
NS_LDAP_SERVICE_AUTH_METHOD= pam_ldap:tls:simple


13) Si queremos ver el log:

# tail -f /var/svc/log/network-ldap-client:default.log

viernes, 7 de junio de 2013

Agregar Nuevo disco a Solaris 10 en XenServer Citrix

1) Comentar en /etc/vfstab

# vim /etc/vfstab

/dev/dsk/c1d0s0 /dev/rdsk/c1d0s0 /punto/de/montaje ufs 1 yes

2) Utilizamos el comando format, si no lo vemos con format primero utilizamos el devfsam con los siguientes parámetros para que refresque los devices:

# devfsadm -Cc disk

# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c0d0
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c0d1
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0
       2. c1d0
          /pci@0,0/pci-ide@1,1/ide@1/cmdk@0,0
Specify disk (enter its number): 2

selecting c1d0
Controller working list found
[disk formatted, defect list found]

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        show       - translate a disk address
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        volname    - set 8-character volume name
        !     - execute , then return
        quit

format> part
WARNING - This disk may be in use by an application that has
          modified the fdisk table. Ensure that this disk is
          not currently in use before proceeding to use fdisk.

format> fdisk
No fdisk table exists. The default partition for the disk is:

  a 100% "SOLARIS System" partition

Type "y" to accept the default partition,  otherwise type "n" to edit the
 partition table.
y

format> part

PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        ! - execute , then return
        quit


partition> print
Current partition table (original):
Total disk cylinders available: 14356 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0 unassigned    wm       0                0         (0/0/0)             0
  1 unassigned    wm       0                0         (0/0/0)             0
  2     backup    wu       0 - 14355      109.97GB    (14356/0/0) 230629140
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0
  8       boot    wu       0 -     0        7.84MB    (1/0/0)         16065
  9 alternates    wm       1 -     2       15.69MB    (2/0/0)         32130


partition> 0
Part      Tag    Flag     Cylinders         Size            Blocks
  0 unassigned    wm       0                0         (0/0/0)             0

Enter partition id tag[unassigned]: ENTER
Enter partition permission flags[wm]: ENTER
Enter new starting cyl[0]: ENTER
Enter partition size[0b, 0c, 0e, 0.00mb, 0.00gb]: 109.97gb
partition>



partition> print
Current partition table (unnamed):
Total disk cylinders available: 14356 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0 unassigned    wm       0 - 14355      109.97GB    (14356/0/0) 230629140
  1 unassigned    wm       0                0         (0/0/0)             0
  2     backup    wu       0 - 14355      109.97GB    (14356/0/0) 230629140
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0
  8       boot    wu       0 -     0        7.84MB    (1/0/0)         16065
  9 alternates    wm       1 -     2       15.69MB    (2/0/0)         32130


partition> label
Ready to label disk, continue? y

partition> quit

format> label
Ready to label disk, continue? y


# mount /usr/local/apps/SDK
mount: /dev/dsk/c1d0s0 is not this fstype


# newfs /dev/dsk/c1d0s0
newfs: construct a new file system /dev/rdsk/c1d0s0: (y/n)? y
Warning: 4332 sector(s) in last cylinder unallocated
/dev/rdsk/c1d0s0:       230629140 sectors in 37538 cylinders of 48 tracks, 128 sectors
        112611.9MB in 2347 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
Initializing cylinder groups:
..............................................
super-block backups for last 10 cylinder groups at:
 229740704, 229839136, 229937568, 230036000, 230134432, 230232864, 230331296,
 230429728, 230528160, 230626592


# vim /etc/vfstab
Descomentar:

/dev/dsk/c1d0s0        /dev/rdsk/c1d0s0        /punto/de/montaje     ufs     1       yes     -


# mount /punto/de/montaje


# ls -l /punto/de/montaje
total 16
drwx------   2 root     root        8192 Jun  7 21:50 lost+found


# df -h | grep c1d0s0
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1d0s0        108G    64M   107G     1%    /punto/de/montaje


jueves, 6 de junio de 2013

Whitelist squid without authentication


Editamos la configuración del squid (squid.conf) y agregamos el archivo donde pondremos las webs de las lista blanca:


# vim /etc/squid/squid.conf
acl whitelist dstdomain "/etc/squid/sites.whitelist.txt"
acl all src all
acl password proxy_auth REQUIRED
http_access allow whitelist
http_access allow password http_access deny all

Editamos el archivo de listas sin autenticacion de proxy:

# vim /etc/squid/sites.whitelist.txt
www.redes-seguridad.com.ar

Chequeamos la config del squid:

# squid -k check

Si no tenemos ningun error reiniciamos el squid:

# /etc/init.d/squid reload

Por ejemplo si queremos activar office sin que autentique:

# vim /etc/squid/sites.whitelist.txt
#Activacion de Office:
go.microsoft.com
activation.sls.microsoft.com

miércoles, 1 de mayo de 2013

Autenticar Squid 2.7 con OpenLdap

Editamos el squid.conf, donde 172.16.72.1 es la ip del servidor donde tenemos instalado el openldap, el -v 2 es la versión del ldap y con el -b le damos la ruta del árbol del contenedor de usuarios del openldap:


# vim /etc/squid/squid.conf 
#Autenticacion con LDAP
auth_param basic program /usr/lib/squid/ldap_auth -h 172.16.72.1 -v 2 -b "ou=Users,dc=redes-seguridad,dc=com,dc=ar" ldap
auth_param basic children 30
auth_param basic realm Redes Seguridad - Acceso a Internet
auth_param basic credentialsttl 1 hours 
# Habilitamos la autenticación
acl all src all
acl password proxy_auth REQUIRED
http_access allow password
http_access deny all


Verificamos la configuración del squid:

# squid -k check


Reiniciamos el squid:

# /etc/init.d/squid restart


Inicialmente antes de encontrar el comando para poner en el squid.conf probaba desde bash lo siguiente. (Tener en cuenta que usuario y passoword hay que reemplazarlo por uno de dominio)

# /usr/lib/squid/ldap_auth -ZZ -b "ou=Users,dc=redes-seguridad,dc=com,dc=ar" ldap
usuario password
Could not Activate TLS connection


Aparecía el TLS connections, hasta que descubrí que el -ZZ utilizaba la versión 3, finalmente cambié por la siguiente línea indicandole la version 2 y especifiandole con el parámetro -h la ip del server del ldap, especificamos user y pass de dominio y obtenemos "OK", con eso verificamos que funcionará correctamente en el squid:

# /usr/lib/squid/ldap_auth -h 172.16.72.1 -v 2 -b "ou=Users,dc=redes-seguridad,dc=com,dc=ar" ldap
usuario password
OK

Mover el /var a otro disco

Levanté un template de una virtual que había creado hace tiempo, pero tenía sólo 5Gb en el / y todo en la partición, como tenía que instalar un squid tenía que crear una nueva partición en /var donde iba a ir el cache y los logs.

Agregué un nuevo disco en XenServer con la virtual apagada, como tengo la versión free, no me dejaba agregarlo en caliente, en realidad me dejaba pero no lo reconocía el S.O.

Luego de agregarlo utilizamos el fdisk para ver el device del disco:

# fdisk -l


Vemos que el nuevo que aparece es el /dev/xvde, ahora lo seleccionamos para crear la partición, presionamos la "n", la "p" para indicarle que es primaria y el "1" para indicar el número. Finalmente presionamos la letra "w" para guardarla:


# fdisk /dev/xvde
Command (m for help): n
   e   extended
   p   primary partition (1-4)p
Partition number (1-4): 1
First cylinder (1-6527, default 1): ENTER
Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): ENTER
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#


Formateamos la partcición en ext3:

# mkfs.ext3 /dev/xvde1


Buscamos el UUID de la partición para posteriormente agregarlo al fstab:

#blkid /dev/xvde1
/dev/xvde1: UUID="a24ea09d-c1c4-4288-bd45-475d6e782d00" SEC_TYPE="ext2" TYPE="ext3"


Creamos el /var1 y editamos el fstab:


# mkdir /var1/

# vim /etc/fstab
UUID=a24ea09d-c1c4-4288-bd45-475d6e782d00       /var1   ext3    defaults        1       2


Montamos el /var1:

# mount /var1

 # ls -l /|grep var
drwxr-xr-x 14 root root  142 Mar 20  2012 var
drwxr-xr-x  3 root root 4096 Apr 29 11:05 var1


Copiamos todo el contenido del /var a /var1:

# cp -Rpf /var/* /var1/

# umount /var1

# mv /var /var2


Modificar en el fstab el /var1 por /var:


# vim /etc/fstab
UUID=a24ea09d-c1c4-4288-bd45-475d6e782d00       /var    ext3    defaults        1       2

# mkdir /var

# mount /var


Verificamos que el /var está ahora con 50Gb:

#df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2            4.9G  910M  4.0G  19% /
tmpfs                 121M     0  121M   0% /lib/init/rw
udev                  116M  128K  116M   1% /dev
tmpfs                 121M     0  121M   0% /dev/shm
/dev/xvda1            184M   21M  155M  12% /boot
/dev/xvde1             50G  557M   47G   2% /var


Borramos el /var1 y el /var2 que quedaron:

#rm -rf /var1 /var2/



martes, 26 de marzo de 2013

XenCenter Error: The ballooning daemon is not running

Hoy se llenó la partición del / de un XenServer e intentaba reiniciarlo o apagarlo desde el XenCenter y no me lo permitia, también probe por linea de comandos desde la consola y nada.


En los logs aparecía el siguiente mensaje:

The ballooning daemon is not running


Consultando la documentación de xen encontré lo siguiente y luego me dejo reiniciarla:

# xe-toolstack-restart

viernes, 22 de marzo de 2013

Monitoreo espacio DBspaces en Informix

Aclaración:

Tener en cuenta que este script fue creado particularmente para el DBspace datadb de un especifico server para el chunk: 1ec9a2038


Creamos un archivo para el script y colocamos lo siguiente:

vim check_informix_dbspace_morsa
#!/bin/bash
SIZE_DATADB_DBSPACE=`onstat -d | grep 1ec9a2038 | awk '{print $6}'`
if test $SIZE_DATADB_DBSPACE -lt 206431
then
  echo CRITICAL - DBspace is $SIZE_DATADB_DBSPACE
  exit 2
else
  if test $SIZE_DATADB_DBSPACE -lt 306431
  then
    echo WARNING - DBspace is $SIZE_DATADB_DBSPACE
    exit 1
  else
    echo OK - DBspace is $SIZE_DATADB_DBSPACE
    exit 0
  fi
fi


Agregarlo al Nagios con NRPE:

Si queremos agregar el monitoreo al nagios con NRPE nos basamos en este enlace que ya fue explicado: