/tool user-manger database clear-log
Then rebuild the db with
/tool user-manager database rebuild
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/
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
$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
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
Descargar los paquetes
apt-get install libmailtools-perl libunix-syslog-perl libfile-tail-perl libproc-daemon-perl
Agregar los módulos a CPAN
for m in Mail::Mailer Proc::Daemon Unix::Syslog File::Tail;
do
perl -MCPAN -e "install $m";
done
Descargar el script de aquí http://unixlore.net/downloads/logmon.pl.txt
#!/usr/bin/perl -wT
#
# Parses given logfile, looking for specified pattern, sends alert or
# logs message.
#
# Copyright (c) 2012 Doug Maxwell <doug@unixlore.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# Sample syslog error we want to alert on and usage:
#
# Jul 17 08:02:49 kaylee mysqld[1532]: 110717 8:02:49 [ERROR] /usr/sbin/mysqld: Table './mysql/user' is marked as crashed and should be repaired
#
# logmon.pl -p 'mysqld.+?table.+?crashed' -m you@example.com -u nobody -g adm -f /var/log/syslog -i 120
#
# Needs Mail::Mailer, Proc::Daemon, Unix::Syslog and File::Tail
# installed - the others are core modules.
#
# On Debian/Ubuntu:
# apt-get install libmailtools-perl libunix-syslog-perl libfile-tail-perl libproc-daemon-perl
#
# On Fedora
# yum install perl-MailTools perl-Unix-Syslog perl-File-Tail perl-Proc-Daemon
#
# CPAN:
#
# for m in Mail::Mailer Proc::Daemon Unix::Syslog File::Tail; do perl -MCPAN -e "install $m"; done
#
use strict;
use File::Tail;
use Mail::Mailer;
use Proc::Daemon;
use Unix::Syslog qw(:subs);
use Unix::Syslog qw(:macros);
use Getopt::Std;
use Sys::Hostname;
use POSIX qw(setuid setgid);
use English;
our ($opt_m,$opt_f,$opt_p,$opt_u,$opt_g,$opt_i,$opt_h,$opt_d,$opt_v);
getopts('hdvm:f:p:u:g:i:');
usage() && exit if ( $opt_h || !$opt_p);
sub usage {
print "\n$0 synopsis: Daemon that periodically checks logfile for a pattern and send alerts\n";
print "Pattern is always required. If no other options are given, defaults to syslog alerts and monitors /var/log/messages for given pattern.\n";
print "Usage: $0 -p pattern [-m alerts\@example.com] [-f logfile] [-u run as user] [-g run as group] [-i max interval] [-v] [-d] [-h]\n";
print "-m: Email destination for alerts\n-f: logfile to monitor\n-p: Pattern to match against lines in logfile (Perl regexp, match is case-insensitive)\n-u: Run with permissions of user\n-g: Run with permissions of group\n-i: Max time to sleep between checks\n-d: Debug output to STDERR, do not daemonize\n-v: Verbose logging (use with caution or you may have endless alerts)\n-h: This help text\n\n";
}
my $DEBUG = 1 if ( $opt_d );
if ( !$DEBUG ) {
# Fork and detach
log_alert("Forking and detaching from controlling terminal...");
Proc::Daemon::Init;
}
# Drop privileges if needed.
if ( $opt_g && $UID == 0 ) {
setgid( scalar getgrnam $opt_g ) or log_alert($!);
log_alert("Now running with permissions of group $opt_g") if ( $GID );
}
if ( $opt_u && $UID == 0 ) {
setuid( scalar getpwnam $opt_u ) or log_alert($!);
log_alert("Now running with permissions of user $opt_u") if ( $UID );
}
# Clean up our environment for taint mode
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
$ENV{PATH} = "/bin:/usr/bin";
# Source of email alerts
my $from = 'root@example.com';
# The logfile we are monitoring. Make sure we can read it and that it
# exists.
my $logfile = "/var/log/messages";
if ( $opt_f ) {
if ( ! -r $opt_f ) {
log_alert("Logfile $opt_f does not exist or is not readable");
die;
} else {
$logfile = $opt_f;
}
}
# Pre-compile the regexp we are using
my $pattern = qr/$opt_p/io;
# Mail recipient for alerts
my $recipient = $opt_m if ( $opt_m );
# Max time to wait between checks. File::Tail uses an adaptive
# algorithm to vary the time between file checks, depending on the
# amount of data being written to the file. This is the maximum
# allowed interval.
my $maxinterval = 60;
$maxinterval = $opt_i if ( $opt_i );
my $file = File::Tail->new(name=>$logfile, maxinterval=> $opt_i, adjustafter=>3) or ( log_alert($!) && die );
( $opt_v ) ? log_alert("Running and monitoring $logfile for $pattern") : log_alert("Running and monitoring $logfile");
# Loop as long as we keep getting lines from the file
while (defined(my $line = $file->read)) {
if ( $line =~ /$pattern/ ) {
chomp($line);
if ( $opt_m ) {
send_mail_alert($from,$recipient,$line);
} else {
( $opt_v ) ? log_alert("Matched $pattern against '$line' in $logfile") : log_alert("$logfile matched!");
}
}
}
# Send an email alert using sendmail on the localhost
sub send_mail_alert {
my ($from,$recipient,$body) = @_;
my $hostname = hostname();
my $subject = "Alert from $0 on $hostname while monitoring $logfile for $pattern";
my $mailer = Mail::Mailer->new("sendmail");
$mailer->open({ From => $from,
To => $recipient,
Subject => $subject,
})
or log_alert($!);
print $mailer $body or log_alert($!);
$mailer->close( );
log_alert("Sent email alert to $recipient");
return;
}
# Log a message to this system's syslog. If debugging is enabled, we
# are not a daemon and we just print to STDERR.
sub log_alert {
my $text = shift;
if ( $DEBUG ) {
print STDERR "$0: $text\n";
return;
}
openlog ("$0", LOG_PERROR|LOG_CONS , LOG_LOCAL7);
syslog (LOG_INFO, "$text\n");
closelog();
return;
}
Chequear que la sintaxis es correcta con el comando:
perl -cwT ./logmon.pl
install -m 755 logmon.pl /usr/local/bin/
Para ejecutar el comando se puede hacer con:
logmon.pl -p 'pattern buscada' -m pepe@gmail.com -u nobody -g adm -f /var/log/kern.log -i 120
para ejecutarlo en modo debur -dv (debug + verbose)
para matar el demonio pkill logmon
Fuente: http://www.unixlore.net/articles/monitoring-alerting-patterns-linux-logfiles.html
auto lo eth0 eth1
iface lo inet loopback
#Configuracion para interfaz con red eth0 con internet
allow-hotplug eth0
iface eth0 inet static
address 172.16.2.111
netmask 255.255.255.0
gateway 172.16.2.1
network 172.16.2.0
broadcast 172.16.2.255
dns-nameservers 8.8.8.8 #esto también se puede configurar en /etc/resolv.conf
#Configuracion para interfaz eth1 con red lan interna privada
allow-hotplug eth1
iface eth1 inet static
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
Ahora instalamos y configuramos el servidor DHCP que nos servira para proporcionar ips automaticos a las pc’s de la red lan # aptitude install isc-dhcp-server
Configuramos el servicio de DHCP para que este disponible en la red
interna y acepte las conexiones en dicha red, en este caso es la
interfaz eth1, esto se configura en el archivo
/etc/default/isc-dhcp-serverINTERFACES="eth0"
Ahora tenemos que modificar algunas lineas el archivo /etc/dhcpd.conf
para especificar rango de ips y tiempo que se le proporcionara el ip a
la maquina clienteoption domain-name "example.org";
option domain-name-servers 8.8.8.8, 4.4.4.4;
default-lease-time 600;
max-lease-time 7200;
#SubNet red lan.
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.101 192.168.2.199;
#option domain-name-servers 8.8.8.8; #similar a la parte superior
#option domain-name "example.org"; #similar a la parte superior
option routers 192.168.2.1;
option broadcast-address 192.168.2.255;
#default-lease-time 86400; #similar a la parte superior
#max-lease-time 172800; #similar a la parte superior
}
Con el servidor DHCP se puede asignar un ip especifica a una
determinada mac-address, estas direcciones fijas no deben estar en la
gama de las direcciones reservadas para la distribución dinámica.host desktop {
hardware ethernet 01:23:45:67:89:10;
fixed-address 192.168.2.2;
}
host laptop {
hardware ethernet 01:23:45:67:89:11;
fixed-address 192.168.2.3;
}
Reiniciar el servicio de dhcp:# /etc/init.d/isc-dhcp-server restart
Ahora el ultimo paso instalación y configuración de squid, procedemos a la instalacion con el siguiente comando # aptitude install squid
Ahora vamos a hacer unos cambios en el fichero de configuración de
squid (/etc/squid/squid.conf). Primero localizamos la línea con el
puerto de entrada de squid (por defecto http_port 3128) y añadimos el
parámetro transparente. Debe de quedarnos algo así:http_port 3128 transparent
A continuación de esto, y en el mismo fichero, añadimos las siguientes líneas:acl redlan src 192.168.2.0/24
http_access allow redlan
Ahora sólo nos queda configurar la máquina como router y direccionar
el tráfico web (puerto 80) que recibe por el interfaz interno (eth1) al
puerto 3128 que es el que usa squid. Esto lo hacemos gracias a IPtables
(que vienen instaladas en Debian por defecto) el script que se detalla a
continuación, se debe configurar para que se ejecute de forma
automática.#!/bin/sh
# squid server IP
SQUID_SERVER="192.168.2.1"
# Interface connected to Internet
INTERNET="eth0"
# Interface connected to LAN
LAN_IN="eth1"
# Squid port
SQUID_PORT="3128"
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
#modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
Para guarde el anterior script nos creamos la carpeta
/etc/iptables-script y dentro de ahi colocamos el script con el nombre
de proxy.sh, de damos permisos de ejecución: # chmod +x /etc/iptables-script/proxy.sh
Y le indicamos al SO que ejecute dicho script al iniciar el sistema
para esto editamos el archivo /etc/rc.local, y antes de exit colocamos
la siguiente linea:sh /etc/iptables-script/proxy.sh
73 | 12H | Acct-Interim-Interval | := | 60 | |||||
74 | 12H | WISPr-Bandwidth-Max-Up | := | 32000 | |||||
75 | 12H | WISPr-Bandwidth-Max-Down | := | 512000 | |||||
76 | 12H | Idle-Timeout | := | 180 | |||||
77 | 12H | Session-Timeout | := | 43200 |
enable configure terminal aaa new model username example-user secret example-password ip domain name example-domain.com crypto key generate rsa general-keys modulus 1024 ip ssh version 2 line vty 0 X (X-last vty) transport input ssh end wr mem
enable configure terminal aaa new model username example_user secret example_password ip domain name example_domain.com generate rsa general-keys label ssh_key modulus 2048 ip ssh rsa keypair-name ssh_key line vty 0 255 transport input ssh end wr mem
<?php echo "hola mundo!n"; ?>Y ahora para ejecutarlo sólo tendríamos que llamar al binario php (php.exe en Windows) seguido del nombre del script. Supongamos que el ejemplo de arriba lo guardamos en un fichero que se llama test.php. Sería así:
$ php test.phpY en sistemas Windows:
> php.exe test.phpDe esta forma, los dos mostrarían en pantalla el texto “hola mundo!”. Fácil, verdad?
@echo OFF "C:phpphp.exe" test.phpEn sistemas Unix es más sencillo. Tenemos que añadir en la primera línea la ruta al binario que ejecuta el script, y posteriormente otorgamos permisos de ejecución al fichero. Y ya está, ya es ejecutable desde la consola y desde el entorno gráfico. El fichero quedaría así:
#!/usr/bin/php <?php echo "hola mundo!n"; ?>Y después damos permisos de ejecución, y ya podremos ejecutarlo:
$ chmod +x test.php $ ./test.php
@echo OFF "C:phpphp.exe" test.php %*Bien, ya sabemos cómo enviar parámetros al script. Sólo nos queda saber cómo manejarlos. Pues muy sencillo. Hay dos variables globales para manejarlos:
$ php -a Interactive shell php > echo 5+8; 13 php > function sumarDos($n) php > { php { return $n + 2; php { } php > var_dump(sumarDos(2)); int(4) php >Además, pulsando el botón tabulador, tendrás autocompletado de variables, funciones, clases, constantes, método estáticos y constantes de clases.
php -r 'echo md5(file_get_contents("fichero.txt"));'Lo que hacemos es ejecutar los comandos que hay entre las comillas simples:
echo "hola mundo" | wc -cEn este sencillo ejemplo lo que hemos hecho es en la salida estándar el texto “hola mundo”, que a su vez se envía a la entrada estándar del comando “wc -c”, que se encarga de contar el número de caracteres. ¿Cómo hacemos esto en PHP? Consultando la entrada estándar. En la versión CLI de PHP ponen a nuestra disposición 3 útiles constantes:
echo "hola mundo" | php -r 'echo strlen(fgets(STDIN));'
$ php -w fichero.php
$ php --rf md5 Function [ <internal:standard> function md5 ] { - Parameters [2] { Parameter #0 [ <required> $str ] Parameter #1 [ <optional> $raw_output ] } }Una opción estupenda cuando no tenemos acceso a internet, ni nos hemos descargado la documentación de PHP a nuestro equipo.
$ php -w fichero.phpAdemás, al estar disponible desde el propio binario de php, es muy fácil generar una versión HTML coloreada de cada fichero.
$ find . | php -B '$lineas=0;' -R '$lineas += count(@file($argn));' -E 'echo "Total de líneas: $lineasn";'Veámoslo paso a paso:
iwlist ath0 scan
iwlist ath0 peers/ap
iwlist ath0 txpower
iwlist ath0 frequency/channel
iwlist ath0 bitrate/rate
iwlist ath0 auth
iwlist ath0 genie
ifconfig
iwconfig
iwconfig ath0 txpower <XXdBm>
Potencia Linea Nanostation M:
10 dBm (10 mW)
16 dBm (39 mW)
18 dBm (63 mW)
20 dBm (100 mW)
22 dBm (158 mW)
24 dBm (251 mW)
26 dBm (398 mW)
28 dBm (630 mW)
ls
cd /bin/
ls
passwd
Nuevo password
Confirmar password
clear
ubntbox discover
discover
factorytest
setup
flash
rssi
throughput
ethernet
led
ping <IPv4>
ping <IPv6>