lunes, 2 de noviembre de 2015

ESXi cron jobs

ESXi cron jobs

#Edit corn jobs
vi /var/spool/cron/crontabs/root


# Check crond pross id
cat /var/run/crond.pid


# Kill old crond
/bin/kill $(cat /var/run/crond.pid)


#  Restart cron jobs (for 5.0 or older)
/bin/busybox crond

#  Restart cron jobs (for 5.1)
/usr/lib/vmware/busybox/bin/busybox crond 


# Check again crond pross id (Should not be above id)
cat /var/run/crond.pid

jueves, 17 de julio de 2014

Fitros tcpdump para conocer web visitadas

fuente: http://stackoverflow.com/questions/4777042/can-i-use-tcpdump-to-get-http-requests-response-header-and-response-body

There are tcpdump filters for HTTP GET & HTTP POST (or for both plus message body):
  • Run man tcpdump | less -Ip examples to see some examples
  • Here’s a tcpdump filter for HTTP GET:
    sudo tcpdump -s 0 -A 'tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'
  • Here’s a tcpdump filter for HTTP POST:
    sudo tcpdump -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)'
  • Monitor HTTP traffic including request and response headers and message body (source):
    tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
    tcpdump -X -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
For more information on the bit-twiddling in the TCP header see: String-Matching Capture Filter Generator (link to Sake Blok's explanation).


lunes, 21 de abril de 2014

filtro de MAC sin reiniciar antena ubiquiti

/usr/bin/iwpriv ath0 maccmd 2
/usr/bin/iwpriv ath0 addmac $MAC
/usr/bin/iwpriv ath0 kickmac $MAC
/usr/bin/iwpriv ath0 delmac $MAC

lunes, 24 de marzo de 2014

script ubiquiti para probar diferentes frecuencias

#!/bin/sh
cp /tmp/system.cfg /tmp/config.cfg
freq=$(cat < /etc/persistent/frecuencia.txt)
freqfile=$(cat < /tmp/system.cfg | grep freq | cut -d'=' -f2)
newfreq=`expr $freqfile + 10`


echo frecuencia almacenada $freq
echo frecuencia system.cfg $freqfile
echo siguiente frecuencia $newfreq

echo "aumentando frecuencia"
newfreq=`expr $freqfile + 10`



if [ $newfreq -gt 6100 ]
then
echo "frecuencia maxima alcanzada $freqfile $newfreq"
`sed -i s/radio.1.freq=$freqfile/radio.1.freq=4920/g /tmp/config.cfg`
mv /tmp/config.cfg /tmp/system.cfg
cfgmtd -w -p /etc/
else
echo "cambiando freq en fichero system.cfg"
echo "cambiando frecuencias $freqfile $newfreq"
sed -i s/radio.1.freq=$freqfile/radio.1.freq=$newfreq/g /tmp/config.cfg
mv /tmp/config.cfg /tmp/system.cfg
cfgmtd -w -p /etc/
fi

martes, 21 de enero de 2014

descargar subtitulos subdivx.com desde consola

#/bin/bash

tmp=/tmp/salida
baseurl="www.subdivx.com"

wget "http://www.subdivx.com/feed.php?buscar=$1" -O $tmp ;

enlaces=$(cat $tmp | grep \ | tr '\n' ' ' | sed 's///g' | sed 's/<\/link>//g' | sed 's/http\:\/\/www.subdivx.com//g')
echo -e "$enlaces"

for i in $enlaces;
do
url="$baseurl$i"
echo -e "$url \n"
wget "$url" -O $tmp ;
download=$(cat $tmp | grep "Bajar subt" | awk -F"link1" '{print $2}'|cut -d'>' -f1 | sed 's/" href\=//g' )

echo -e "-------------->$download"

comando="wget -O /tmp/$i-out.rar --referer $baseurl $download "
eval $comando;
unrar x /tmp/$i-out.rar /media/disco/descargas/
exit
done

Descargar con wget un link oculto

wget -O output.rar --referer http://dominio.com/ 'http://dominio.com/your-link-here'

lunes, 20 de enero de 2014

busquedas de torrents para raspberry pi

#/bin/bash
# programado por Juanmol para http://rsppi.blogspot.com
# modificado por netmess
tmp=/tmp/salida
series="$1"

IFS=','; for n in $series;
do
serie=$n;

for i in 1 2 3 4 5 6 7 8
do
wget "http://thepiratebay.se/search/$serie/0/7/0" -O $tmp ;
magnet=$(cat $tmp | grep magnet | head -$i | tail -1 |cut -f2 -d\");
capitulo=$(echo $magnet | sed 's/\ /\n/g' | sed 's/\./\n/g' | sed 's/\+/\n/g' | grep S | grep E)
echo "Descargar torrent de $capitulo y or n"
echo $magnet | cut -f3 -d'='

read answer
if [ "$answer" == "y" ]; then
transmission-remote localhost:9091 -a "$magnet" --auth=transmission:transmission -l;
else
continue
fi

done
done

jueves, 2 de enero de 2014

Liberar espacio en linux - comandos útiles

En ocasiones es bueno tener a mano estas instrucciones por si se nos llena algún filesystem en Linux (o MacOS).
-Los 10 subdirectorios que más ocupan:
$ du -kx / | sort -rn -k1 | head -n 10
-Los ficheros más grandes desde el raiz:
$ find / -type f -xdev -print | xargs -e ll | sort -rn -k5 
otra forma:
$ find /filesystem -xdev -type f -size +100M
-Ficheros modificados recientemente:
$ find / -type f -xdev -mtime -1 -print | xargs ll | sort -rn -k5

lunes, 23 de diciembre de 2013

Borrar logs de mikrotik usermanager

Having that same proble on RB1200. I used this command to clear the user manager log and got 36% of my space back.

/tool user-manger database clear-log

Then rebuild the db with

/tool user-manager database rebuild

Ir a tu lista de blogs

martes, 5 de noviembre de 2013

como borrar cola de postfix

Como mostrar y vaciar la cola de postfix

10 Jul 2008
Tip rapidísimo de postfix.
Para mostrar que emails están en cola, osea, aun no se han enviado:
mailq
Para borrar un email de la cola:
postsuper -d queue_id
Para borrar todos esos emails de la cola:
postsuper -d ALL
 
 
 
http://pablasso.com/200807/como-mostrar-y-vaciar-la-cola-de-postfix/ 

jueves, 17 de octubre de 2013

Cambiar opciones en equipos airmax desde ssh



Para cambiar el listado de frecuencias a automático

sed -i s/`grep wireless.1.scan_list.channels /tmp/system.cfg`/wireless.1.scan_list.channels=0/g /tmp/system.cfg


Para cambiar el ancho de banda de una antena cliente, de lo que tenga a "10"

XM.v5.5.6# sed -i s/`grep radio.1.chanbw /tmp/system.cfg`/radio.1.chanbw=10/g /tmp/system.cfg | grep chanbw
radio.1.chanbw=10
XM.v5.5.6#




Luego se aplica la configuración con el comando "cfgmtd -w -f /tmp/system.cfg"

 XM.v5.5.6# cfgmtd -w -f /tmp/system.cfg
Found  Active on[1] ...
Found Backup1 on[2] ...
Storing Active[2] ... [%100]
Active->Backup[1] ... [%100]
XM.v5.5.6#


y tras guardar los cambios, hacer un reboot de la antena


Activar telnet

sed -i s/`grep telnetd.status  /tmp/system.cfg`/telnetd.status=enabled/g /tmp/system.cfg


De esta forma, podriamos cambiar por ejemplo el ancho de banda de 20mhz a 10mhz en varias antenas cliente de un plumazo. Por ejemplo, teniendo el telnet activo en las antenas o habiendo establecido relaciones de confianza por ssh se podrian ejecutar estos comandos de forma automática.
Otra opción, sería hacerlo desde el aircontrol, con la opcion de "ejecutar comando remoto"




sed -i s/`grep telnetd.status  /tmp/system.cfg`/telnetd.status=enabled/g /tmp/system.cfg &
cfgmtd -w -f /tmp/system.cfg & reboot



jueves, 3 de octubre de 2013

Backup y restore de todas las bases de datos en mysql

Para hacer el backup, el dump de todas las bases de datos:

mysqldump -h server -u root -p --all-databases > all_dbs.sql
Para hacer el restore del dump de todas las bases de datos:

mysql -u root -p < all_dbs.sql


Fuente: http://stackoverflow.com/questions/4749448/mysql-dump-all-databases-and-create-or-recreate-them-on-import

miércoles, 14 de agosto de 2013

asterisk voicemail multiple email addresses

Teniendo instalado postfix en el mismo servidor que está asterisk hay que modificar el fichero main.cf

virtual_alias_domains = pbxfulano.es
virtual_alias_maps = hash:/etc/postfix/virtual


Se crea el fichero /etc/postfix/virtual
lista@pbxfulano.es        pepe@fulano.es, pepa@fulano.es, juan@fulano.es, david@gmail.com

como email para enviar el mensaje del voicebox de asterisk se utiliza lista@pbxfulano.es, de esta forma este mensaje se reenvía a través de postfix a las demás direcciones


Para cargar la configuración
postmap /etc/postfix/virtual
service postfix reload

y para probar que funciona...

echo "prueba" | mail -s "prueba" lista@pbxfulano.es





jueves, 18 de julio de 2013

Configurar router edgemax lite con coovachilli hotspot

Pasos seguidos:

  1. Actualizar a la última versión de firmware
  2. Meter los repositorios de Debian
  3. Descargar hasrel
    1. Instalar  librería que tiene la dependencia de hasrel
  4. Descargar deb de coova-chilli 1.3.0 para mips
  5. Editar fichero de configuración de chilli
  6. Activar DNS cache en el router
  7. Activar NAT masquerading



1- En el siguiente enlace se puede descargar la última versión hasta el momento del firmware de ubiquiti
 
 Para actualizar el firmware, hay que acceder al router por ssh o desde el CLI.
 
$add system image fichero_de_imagen.tar
 
Mas info en este enlace:  actualizar firmware
 
2- Una vez actualizado el firmware, hay que meter los repositorios de Debian en el router
Se pueden seguir las instrucciones en el siguiente link: debian repos
 
Comandos a seguir:
 
configure
set system package repository squeeze components 'main contrib non-free'
set system package repository squeeze distribution squeeze
set system package repository squeeze url http://http.us.debian.org/debian

set system package repository squeeze-security components main
set system package repository squeeze-security distribution squeeze/updates
set system package repository squeeze-security url http://security.debian.org
commit
save
exit

para actualizar el arbol una vez metidos los repositorios:
sudo apt-get update
 
3- Antes de instalar coovachilli, este necesita una dependencia "hasrel", que se puede 
descargar de los repositorios de debian
aquí dejo un enlace  haserl_0.9.29-3_mips.deb
 
una vez descargado se instala con 
# dpkg -i haserl_0.9.29-3_mips.deb
 
este dará fallo.. ya que necesita la siguiente dependencia que se puede bajar directamente
del repositorio  "liblua5.1-0".
Con el siguiente comando se puede instalar la dependencia sin problema
 
#apt-get install liblua5.1-0 

4 - Decargar el paquete de coovachilli 
 foro
 
 coova-chilli_1.3.0_mips.deb
    


 coova-chilli_1.3.0_mips.deb
 
para instalarlo
#dpkg -i coova....
 
5- Edición del fichero /etc/chilli/default
 
HS_WANIF=eth1            # El eth1 esta por dhcp conectado a un router
HS_LANIF=eth2            # En eth2 conectarían los usuarios del portal cautivo 
HS_NETWORK=10.11.0.0       # HotSpot Network (must include HS_UAMLISTEN)
HS_NETMASK=255.255.255.0   # HotSpot Network Netmask
HS_UAMLISTEN=10.11.0.1     # HotSpot IP Address (on subscriber network)
HS_UAMPORT=3990            # HotSpot UAM Port (on subscriber network)
HS_UAMUIPORT=4990          # HotSpot UAM "UI" Port (on subscriber network, for embedded portal)
HS_DNS1=10.11.0.1    # he puesto esta DNS para hacer la cache
HS_DNS2=8.8.8.8
HS_NASID=nas01
HS_RADIUS=97.14X.XXX.XX
HS_RADIUS2=97.14X.XXX.XX
HS_UAMALLOW=www.coova.org
HS_RADSECRET=8U8W2CPTvVcD    # esta es mi clave de radius
HS_UAMSECRET=change-me     # Set to be your UAM secret
HS_UAMALIASNAME=chilli
HS_UAMSERVER=$HS_UAMLISTEN
HS_UAMFORMAT=http://\$HS_UAMLISTEN:\$HS_UAMUIPORT/www/login.chi
HS_UAMHOMEPAGE=http://\$HS_UAMLISTEN:\$HS_UAMPORT/www/coova.html
HS_MODE=hotspot
HS_TYPE=chillispot
HS_WWWDIR=/etc/chilli/www
HS_WWWBIN=/etc/chilli/wwwsh
HS_PROVIDER=Coova
HS_PROVIDER_LINK=http://www.coova.org/
HS_LOC_NAME="My HotSpot"           # WISPr Location Name and used in por
 
también hay que editar /etc/default/chilli para poner  start_chilli=1
  
root@ubnt:/home/ubnt# cat /etc/default/chilli 
START_CHILLI=1
CONFFILE="/etc/chilli.conf"
HS_USER="chilli"

6- Hacer que el rotuer tenga cache dns
he puesto que escucha en el eth2 para que los clientes de coovachilli sean los que tengan
acceso al cache de dns 
 
 
 
7- Activar masquerading NAT
 
 
 
 
Buenos pues con todo esto, ya debería ser una guía suficiente para empezar a probar 
el edgeos router con coovachilli 
 
 
 
8- Editar wwwsh, por algun motivo no funciona bien el fichero que viene por defecto

#!/bin/sh
# (c) 2007 David Bird; Released under GPL.
# This simple script dispatches the <file>.chi embedded CGI scripts.
# If <file>.chi exists, and we have haserl, then we run "haserl file.chi"
# Otherwise, we look for <file>.chi.sh files to run as shell scripts.

file=$(basename $1)
dir=$(dirname $1)
haserl=$(which haserl 2>/dev/null)
cd $dir

# should be make a bit safer!

if [ -z "$haserl" ]; then
    if [ -e "$file.sh" ]; then
        sh $file.sh
    else
        echo "<p>You need to install haserl to serve pages with this wwwsh script!</p>"
        echo "<p>see <a href='http://haserl.sourceforge.net/'>http://haserl.sourceforge.net/</a></p>"
    fi
    exit
fi

    $haserl $file