Acerca de Linux, Solaris, Mac OSX, BSD y notas personales

Archives for March, 2008

resize the virtual disk image?

Solution: 

This solution is to increase your virtual disk size: 

cd /var/lib/xen/images/vlinux1

#use dd to create a 1 GB file

dd if=/dev/zero of=Tempfile bs=1024 count=1000000

#append this file to virtual image file (in this case is hda)

cat Tmpfile >> hda 

resize2fs -f hda

 ——————  este es como vmware que te da espacio pero no lo utiliza hasta que se grabe ————————

BACKUP YOUR IMAGE FILE FIRST

dd if=/dev/zero of=<image file> count=1 seek=200G

Using seek in this way will cause a sparse file to be created and should give
you a virtual disk with an apparent size of around 200GB.  Because it’s
sparse, the extra space will only be allocated from the host disk as the
guest writes to it.  That can make things more space efficient but remember
that space *must* be available for the virtual disk to grow into.

If the host runs out of space for the guest’s disk to grow into then the guest
will experience filesystem corruption and data loss.

If you want to pre-allocate the file rather than making it sparse, then your
second solution with cat >> (having created a large non-sparse file of zeros
using dd to really write the data, instead of using seek) should work, I
think.

Remember that resizing the disk in this way will not work while the guest is
running (and you should *never ever* run any utilities against a FS from
outside the guest whilst it has that FS mounted - that would be guaranteed to
fry your filesystem).  Suspending the guest is not enough, it needs to have
the filesystems unmounted fully or be properly shut down.

You can use the -s flag to ls (e.g. do ls -sl) to view the real disk usage as
well as the logical size.  For a sparse file, the real disk usage may be
lower than the logical size; the logical size may be larger than the disk
actually has room for.

Cheers,
Mar

cisco 1841 password recovery

 Dear you find the detail password recovery procedue for Cisco 1841 router from the below link

http://www.cisco.com/en/US/customer/products/hw/routers/ps221/products_password_recovery09186a0080094773.shtml
 or else follow the below steps

Read more… »

vlans cisco 2950


Configuración básica de VLAN

Para crear VLANs, el switch debe estar en modo VTP “Server”, o “Transparent”. “Server” es el default.

 

show vtp status

show vlan

vlan database

vtp server

vlan 2 name admin (crear la VLAN)

vlan 3 name contabil

exit

show vlan

configure terminal

interface f0/1

switchport access vlan 2 (asigna el puerto a la VLAN 2)

interface f0/2

end

Ver también: interface range, para configurar varias interfaces a la vez.

Para borrar una vlan:

vlan database

no vlan 2 (borrar la VLAN especificada)

 

Para quitar la asignación de VLAN a un puerto:

configure terminal

interface f0/1

no switchport access vlan 2

 

Para volver todo el switch al default de fábrica (ver http://www.cisco.com/warp/public/473/156.html):

erase startup-config (borra configuración, excepto VLAN)

delete flash:vlan.dat (borra la información de VLAN)

reload

 

Enrutamiento entre VLANs

Ejemplo: Configurar un solo switch con dos diferentes VLANs (con los comandos de arriba). Conmutar el tráfico entre las dos VLANs con un router.

Una troncal del switch se conectará a una interface FastEthernet del router, la cual se subdivide en dos sub-interfaces (una para cada VLAN).

Comandos para el switch:

vtp mode transparent

o también: vtp mode server

(El default es “server”, que sirve para este ejercicio.)

interface F0/5

switchport mode trunk

(comandos para encapsulación)

switchport trunk allow vlan all

El switch 2950 sólo soporta un encapsulamiento, y no soporta comandos para cambiar el encapsulamiento. Sin embargo, es importante recordar que en otros switches posiblemente se tenga que seleccionar el encapsulamiento correcto (dot1q, o isl).

Comandos para el router:

interface F0 (o: F0/0)

no shutdown

interface F0.2 (o: F0/0.2) (selecciona una sub-interface)

encapsulation dot1q 2

ip address …

interface F0.3

encapsulation dot1q 3

ip address …

(Repetir para cada VLAN.)

 

Comandos para los hosts:

Obviamente, aparte de configurar el router y el switch, también se deben configurar los hosts conectados. Específicamente, se tiene que asignar:

·      La dirección IP. Se debe recordar que (1) la dirección IP debe estar en la misma subred que la sub-interfaz correspondiente del router, y (2) para la configuración de VLANs en general, diferentes VLANs corresponden a diferentes subredes.

·      La máscara de subred.

·      La puerta de enlace, que debe apuntar a la sub-interfaz correspondiente de router.

 

Referencias:

VLANS en general: http://www.cisco.com/warp/public/793/lan_switching/3.html

Switching entre VLANs: http://www.cisco.com/en/US/tech/tk389/tk390/technologies_configuration_example09186a00800949fd.shtml

Para otros switches o routers, por favor buscar en la documentación de Cisco Systems. (Una búsqueda en Internet es muy útil en este caso.)

IP masquerading

http://linuxfocus.org/Castellano/May2000/article151.shtml

#!/usr/bin/python
# macgen.py script generates a MAC address for Xen guests
#
import random
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
print ‘:’.join(map(lambda x: “%02x” % x, mac))

Hide sendmail version

vim sendmail.cf

Cambiar lo siguiente:

# SMTP initial login message (old $e macro)
#O SmtpGreetingMessage=$j Sendmail $v/$Z; $b
O SmtpGreetingMessage=$j Sendmail ; $b

Hide apache and php version

http://nixcraft.com/server-configuration-tutorials/746-apache-php-web-server-security-hiding-version-information.html

How do I Hide Apache Version info?
Open httpd.conf file (located in /etc/httpd/ directory /etc/apache2/ )

 

Code:

vi httpd.conf

Set Apache ServerTokens to product only but don’t show version and other info:

 

Code:

ServerTokens Prod

This directive controls whether Server response header field which is sent back to clients includes a description of the generic OS-type of the server as well as information about compiled-in modules.

Setting this to Prod only displays Apache and nothing else.

Set Apache ServerSignature off

 

Code:

ServerSignature Off

The ServerSignature directive allows the configuration of a trailing footer line under server-generated documents.

How do I hide php info?
Open php.ini (located in /etc/php.ini or /etc/php5 or /etc/php4 directory)

 

Code:

vi php.ini

Make sure php does not display errors and other php information. Modify add setting as follows:

 

Code:

expose_php = Off

display_errors=Off

register_globals = Off

Also send all errors to /var/log/php-scripts-error.log and not on screen to end user. It can provide serious information to user.
error_log = /var/log/httpd/php-scripts-error.log

Restart Apache.

 

Code:

/etc/init.d/httpd restart

Now all php script errors are written to /var/log/httpd/php-scripts-error.log. Ask your website developers to use following commands to view log files

 

Code:

tail -f /var/log/httpd/php-scripts-error.log

vi /var/log/httpd/php-scripts-error.log.

For more info please read Apache 2 docs http://httpd.apache.org/docs/2.2/mod/core.html

mac bsd darwin ports

http://darwinports.com/ 

you need 2 bridge interfaces:
xenbr0 = eth0
xenbr1 = eth1

create a new script with the following lines: (ex: multiplebridge.sh) in /etc/xen/scripts/

#!/bin/sh
dir=$(dirname “$0″)
“$dir/network-bridge” “$@” vifnum=0 netdev=eth0 bridge=xenbr0
“$dir/network-bridge” “$@” vifnum=1 netdev=eth1 bridge=xenbr1

make the script executable (chmod +x /etc/xen/scripts/multiplebridge.sh)

modify /etc/xen/xend-config.sxp
change the line:
(network-script network-bridge)
to
(network-script multiplebridge.sh)

modify your virtual machine to use the new bridge interface:
ex:
vif = [ 'bridge=xenbr1', ]

Hope this helps.

another help Read more… »

SendMail

$ sudo vim /etc/mail/sendmail.mc

Sendmail slow to start

It was all about the hostname for some reason. I was using a
FQDN in the host file but for some reason sendmail couldn’t resolve
that name. I put it back to localhost and everything seems to have gone
back to normal.

“Open Mouth, Insert Foot and Chew!”