martes, 24 de noviembre de 2009

Resize images linux / Reducir o redimensionar muchas imagenes jpg en linux

# apt-get install imagemagick
$ cd /directorio_de_fotos
$ mogrify -resize 400×300 *.jpg

Nota: Se sobreescriben los originales, se recomienda sacar copia del directorio antes.

viernes, 6 de noviembre de 2009

Instalación de tinydns y dnscache de djbDNS y OpenDNS sobre ubuntu Linux 9.04

Instalado en ubuntu 9.04 para servidores de 64 bits
Instalación de tinydns y dnscache de djbDNS y filtro de contenido usando OpenDNS sobre ubuntu Linux 9.04

Instalación en ubuntu de djbdns
Basado en: http://ectropic.com/wordpress/2008/05/28/tinydns-djbdns-on-ubuntu-hardy-heron/

Pero no todo funcionó como dice, ya que /etc/inittab en ubuntu hardy no existe por lo que se deben crear asi:

/etc/inittab
-------------
id:2:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# :::
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
-------------

Hay que crear en algun punto de las instalaciones el archivo
/etc/event.d/svscan con el siguiente contenido:
-------------
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on shutdown
respawn
exec /usr/bin/svscanboot
--------------


PRE-INSTALL:

#sudo apt-get install build-essential
* Add to /etc/apt/sources.list: deb http://ftp2.de.debian.org/debian/ etch main contrib non-free
#sudo apt-get update

INSTALL ALL THE PACKAGES:

* ucspi-tcp-src:
#sudo apt-get install ucspi-tcp-src
#sudo build-ucspi-tcp
+ Accept all the defaults

* daemontools
#sudo apt-get install daemontools-installer
#sudo build-daemontools
+ Accept all the defaults
#sudo ln -s /etc/inittab{new} /etc/inittab

* DJBDNS
#sudo apt-get install djbdns-installer
#sudo build-djbdns
+ Accept all the defaults

CONFIG PACKAGES:

* Create Users (if they aren’t created for you):
#sudo adduser –no-create-home –disabled-login -shell /bin/false dnscache
#sudo adduser –no-create-home –disabled-login -shell /bin/false dnslog
#sudo adduser –no-create-home –disabled-login -shell /bin/false tinydns

* Configure dnscache:
#sudo mkdir /var/lib/svscan
#sudo dnscache-conf dnscache dnslog /var/lib/svscan/dnscache
#sudo ln -sf /var/lib/svscan/dnscache /service
+ Check that “supervise” directory was create in /service/dnscache - If it wasn’t something is wrong… See: http://www.troubleshooters.com/linux/djbdns/index.htm

* Configure tinydns:
#sudo tinydns-conf tinydns dnslog /var/lib/svscan/tinydns 10.0.0.105
#sudo ln -sf /var/lib/svscan/tinydns /service
+ Check that “supervise” directory was create in /service/tinydns - If it wasn’t something is wrong. See: http://www.troubleshooters.com/linux/djbdns/index.htm

* Edit /etc/resolv.conf
domain dominio.com
nameserver 127.0.0.1

START-UP CONFIGURATION:

* INIT:
#touch /etc/event.d/svscan
* update contents to:
+ start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on shutdown
respawn
exec /usr/bin/svscanboot

#sudo /etc/init.d/djbdns restart

Test Install:

#dnsip www.google.com (dnscache)

---------------

Yo utilicé el ejemplo que puso solca en mis servers para que usara opendns y todas las redes, entonces los datos importantes son:

tinydns (/service/ns1/env)
root@ib:/service/ns1/env# ls
IP IPSEND ROOT
root@ib:/service/ns1/env# cat *
10.0.0.10
10.0.0.10
/var/lib/svscan/ns1/root

en /service/ns1/root/data se alojan todos los dominios internos.

dnscache (/service/dnscache/env)
root@ib:/service/dnscache/env# ls
CACHESIZE DATALIMIT FORWARDONLY IP IPSEND ROOT
root@ib:/service/dnscache/env# cat *
7000000
4000000
1
10.0.0.12
10.0.0.10
/var/lib/svscan/dnscache/root

root@ib:/service/dnscache# cd root/
root@ib:/service/dnscache/root# cd ip/
root@ib:/service/dnscache/root/ip# ls
10.0.0 10.0.1 10.0.2 10.0.3 10.0.4 10.0.6 10.1 10.2 10.3 10.4 127.0.0.1 172.16 216.230.138
root@ib:/service/dnscache/root/ip# cd ..
root@ib:/service/dnscache/root# cd servers/
root@ib:/service/dnscache/root/servers# ls
@ 1.10.in-addr.arpa 2.0.10.in-addr.arpa 3.10.in-addr.arpa 6.0.10.in-addr.arpa @.telgua
0.0.10.in-addr.arpa 138.230.216.in-addr.arpa 2.10.in-addr.arpa 4.0.10.in-addr.arpa @.opendns usac.edu.gt
1.0.10.in-addr.arpa 16.172.in-addr.arpa 3.0.10.in-addr.arpa 4.10.in-addr.arpa @.rootservers

en @ van los de opendns, 208.67.222.222 208.67.220.220
luego los del proveedor en este caso telgua y los rootservers que ya vienen, además hay un archivo que otros usan en /etc/dnsroots.global que contiene los servidores .

Hay que colocar un 1 en FORWARDONLY de la siguiente manera:

#echo 1 > /service/dnscache/env

con eso ya debería funcionar el cache y el interno tinydns y OpenDNS resolviendo para nuestro dominio, luego bastará hacerse una identidad en http://opendns.org para agregar nuestra ip publica del servidor que resuelve para la red o de todo el bloque público en el internet para categorizar y filtrar contenido.

Crear VLANs sobre linux 802.1q

Sobre ubuntu 9.04 versión para servidores de 64 bits.

# apt-get install vlan
# insmod 8021q
# vi /etc/network/interfaces

# formato eth{número de nic}.{vlan_id}
auto eth1.712
iface eth1.712 inet static
address 10.50.12.2
netmask 255.255.255.0

# ifup eth1.712

Si el último comando no funcionara, se puede probar ejecutar /etc/init.d/networking restart, aunque entiendase que esto afecta a todas las interfaz de red.

Ejemplo configuración djbdns (tinydns) para GoogleApps

Estoy configurando tinydns para usar googleapps en mi institución, así debe ir la configuración de los dominios para que jale.

Yo tengo los registros en /service/tinydns/root/data

@dominio.com::aspmx.l.google.com.:1:1800 @dominio.com::alt1.aspmx.l.google.com.:5:1800 @dominio.com::alt2.aspmx.l.google.com.:5:1800 @dominio.com::aspmx2.googlemail.com.:10:1800 @dominio.com::aspmx3.googlemail.com.:10:1800 @dominiocom::aspmx4.googlemail.com.:10:1800 @dominio.com::aspmx5.googlemail.com.:10:1800 'dominio:v=spf1 a mx include\072google.com, include\072googlemail.com ~all:3600

# Para que funcione el CNAME se coloca así
CgoogleCODIGOVERIFICACION.yourdomain.com:google.com Ccorreo.dominio.com:ghs.google.com

Luego ejecutar

svc -t /service/*

Esta última parte sirve para cambiar los url de acceso y que un usuario dentro de la red pueda colocar simplemente correo.dominio.com para que acceda a las aplicaciones en http://google.com/a/dominio.com al login de su correo con nuestro dominio.