23 oct 2008

Instalando Packet Tracer 5 en Linux

La ultima versión de Packet Tracer trae una versión para linux, por lo que ya no es necesario instalar la versión de windows usando wine. Esta versión viene con un instalador especifico para ubuntu y fedora, así como el genérico que es el que vamos a usar.
Lo descargamos y descomprimimos:
#tar zxvf PacketTracer5_generic.tar.gz
#cd PacketTracer5
#./installer
Presionamos Enter para leer la licencia y Bajamos hasta el final para aceptarla escribiendo Y
Luego debemos especificar la ubicación en donde se instalara, presionamos enter para dejarlo en la ubicación predeterminada:

Enter location to install Packet Tracer 5 or press enter for default [/opt/pt]:

Nos pregunta si queremos que cree enlaces simbolicos a /usr/local/bin, escribirmos Y

Should we create a symbolic link "packettracer" in /usr/local/bin for easy Packet Tracer 5 startup? [Yn]Y

y listo !!!, ya tenemos packet tracer en Linux. Ahora solo debemos abrir un terminal ( xterm, kconsole, gnome-terminal, ... cualquiera), escribir el comando packettracer y ya lo tendremos el software ejecutándose en nuestra PC.

Nota: En caso de tener un sistema de 64 bits hay que instalar las librerías de compatibilidad de 32 bits.


Configurando emacs para autocompletado, resaltado de sintaxis y otras cosas

Actualmente estoy en la tarea de usar emacs, para programar.
Falta mejorar varias cosas, pero por el momento mi archivo de configuracion .emacs esta quedando asi:



(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(current-language-environment "UTF-8")
'(display-time-mode t)
'(ecb-options-version "2.32")
'(global-font-lock-mode t nil (font-lock))
'(global-semantic-stickyfunc-mode nil nil (semantic-util-modes))
'(safe-local-variable-values (quote ((indent-tabs-mode . 1))))
'(semantic-idle-scheduler-idle-time 3)
'(tab-width 4))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

(require 'cc-mode)
(setq c-default-style "bsd"
c-basic-offset 4)
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/backups"))))
;; turn on paren matching
(show-paren-mode t)
(setq show-paren-style 'mixed)

;; Use "y or n" answers instead of full words "yes or no"
(fset 'yes-or-no-p 'y-or-n-p)
;; Display the time in the mode line
(setq display-time-24hr-format t)
(display-time)


(setq truncate-partial-width-windows nil)
(setq after-save-hook (quote (executable-make-buffer-file-executable-if-script-p)))
;; para asegurarte de que el fichero termina con línea vacía
(setq require-final-newline 'ask)
;;
;; eliminar espacios en blanco a final de línea y líneas vacias al final
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
(setq delete-trailing-whitespace-p t)


;;Auto-añadir paréntesis o llave de cierre
(setq skeleton-pair t)
(global-set-key "[" 'skeleton-pair-insert-maybe)
(global-set-key "(" 'skeleton-pair-insert-maybe)
(global-set-key "{" 'skeleton-pair-insert-maybe)
(global-set-key "'" 'skeleton-pair-insert-maybe)
(global-set-key "\"" 'skeleton-pair-insert-maybe)

(require 'semantic nil t)
(global-semantic-idle-scheduler-mode 1)
(global-semantic-idle-completions-mode 1)
(global-semantic-idle-summary-mode 1)
(require 'semantic-sb nil t)
(require 'semanticdb nil t)

(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)

;; Load CEDET
;; (load-file "~/cedet-VERSION/common/cedet.el")
;;
;; Enabling various SEMANTIC minor modes. See semantic/INSTALL for more ideas.
;; Select one of the following:

;; * This enables the database and idle reparse engines
(semantic-load-enable-minimum-features)

;; * This enables some tools useful for coding, such as summary mode
;; imenu support, and the semantic navigator
(semantic-load-enable-code-helpers)

;; * This enables even more coding tools such as the nascent intellisense mode
;; decoration mode, and stickyfunc mode (plus regular code helpers)
(semantic-load-enable-guady-code-helpers)

;; * This turns on which-func support (Plus all other code helpers)
(semantic-load-enable-excessive-code-helpers)

;; This turns on modes that aid in grammar writing and semantic tool
;; development. It does not enable any other features such as code
;; helpers above.
(semantic-load-enable-semantic-debugging-helpers)
(which-func-mode t)


(require 'semantic-ia nil t)
(global-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
(global-set-key [(control shift return)] 'semantic-ia-complete-symbol)

(setq semanticdb-default-save-directory "~/.emacs.d/semantic")

(setq semantic-load-turn-everything-on t)
(require 'semantic-load)
(global-semantic-show-unmatched-syntax-mode -1)

(require 'ctypes)
(turn-on-font-lock)
(ctypes-auto-parse-mode 1)


(require 'ecb)
(require 'ecb-autoloads)
(setq ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
;; Desactivamos el Tip of the Day de ECB...
(setq ecb-tip-of-the-day nil)
(ecb-activate)

(global-set-key [f12] 'ecb-toggle-ecb-windows)
(global-set-key [C-f12] 'ecb-activate)
(global-set-key [M-f12] 'ecb-deactivate)

(setq tex-dvi-view-command "xdvi")
;;(transient-mark-mode 1)
;;(add-hook 'text-mode-hook 'turn-on-auto-fill)




(setq-default TeX-master nil)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
(load "preview-latex.el" nil t t)


(defalias 'perl-mode 'cperl-mode)






11 sept 2008

Resolviendo nombres dns de manera independiente del protocolo

Este es un ejemplo del uso de la funcion getaddrinfo , la cual nos permite resolver nombres de host a ip, de forma independiente del protocolo( Ipv4 o IPv6).
No se porq no se muestra los includes.


#define
#define
#define
#define

#define MAXSOCK 20

int main(int argc, char **argv)
{
int error=0;
struct addrinfo hints, *res, *res0;

memset(&hints, 0, sizeof(hints));
hints.ai_socktype= 0;//SOCK_STREAM;

if(argc!=2)
fprintf(stderr,"modo de uso: dns_resolve fqdn\n");
else
{
error = getaddrinfo(argv[1],NULL,&hints,&res0);
if(error)//si es diferente de cero
{
fprintf(stderr,"dns_resolve %s: %s\n",argv[1],gai_strerror(error));
}
else
{
for(res=res0; res ; res=res->ai_next)
{
int error;
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
switch (res->ai_family) {
case AF_INET:
printf("Interfaz IPv4 %d\n", res->ai_family);
break;
case AF_INET6:
printf("Interfaz IPv6 %d\n", res->ai_family);
break;
default:
printf("interfaz desconocida \n");
return 1;
break;
}
error = getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if(error)//si es diferente de cero
{
fprintf(stderr,"error dns_resolve: %s\n",gai_strerror(error));
}
printf("addr: %s port: %s\n",hbuf,sbuf);
}
}
}
return 1;
}

8 sept 2008

Configurando LVS/DR para balanceo de carga

Topologia



Instalacion de paquetes
debian-ldirector
aptitude install ldirectord-2 heartbeat
debian-rs y debian-rs2
aptitude install apache2



Configuracion de red

debian-ldirector
auto eth0
iface eth0 inet static
address 192.168.1.35
netmask 255.255.255.0
gateway 192.168.1.1

auto eth0:0
iface eth0:0 inet static
address 192.168.1.34
netmask 255.255.255.0

debian-rs
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.36
netmask 255.255.255.0
gateway 192.168.1.1

auto lo:0
iface lo:0 inet static
address 192.168.1.34
netmask 255.255.255.255


debian-rs2
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.37
netmask 255.255.255.0
gateway 192.168.1.1

auto lo:0
iface lo:0 inet static
address 192.168.1.34
netmask 255.255.255.255




Modificando parametros del kernel para evitar el problema arp
debian-ldirector
#vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
#sysctl -p
debian-rs y debian-rs2
#vi /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
#sysctl -p

Configuracion de ldirectord
vi /etc/ha.d/ldirectord.cf
checktimeout=10
checkinterval=2
autoreload=no
logfile="/var/log/ldirectorlog.log"
quiescent=yes
# Virtual Server for HTTP
virtual=192.168.1.34:80
fallback=127.0.0.1:80
real=192.168.1.36:80 gate
real=192.168.1.37:80 gate
service=http
request="test.html"
receive="funciona"
scheduler=rr
protocol=tcp
checktype=negotiate