tag:blogger.com,1999:blog-24019747942511070962024-03-14T10:38:16.315-06:00rukiaEnixrukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-2401974794251107096.post-5324486458547409512021-01-26T12:03:00.002-06:002021-01-26T12:07:34.015-06:00Compile and Execute C# on Ubuntu Linux<p>To explain how to compile and execute C# code on Ubuntu, we will create a hello world method for adding two numbers and show the result after the hello world message.</p><ul style="text-align: left;"><li><b>We create the file hello.cs with the following content:</b></li></ul><p> <br />
<textarea style="height: 509px; width: 619px;">using System;
//Declare namespace
namespace HelloWorldApp {
//Declare HelloWorld class
class HelloWorld {
//Add method for adding two numbers
public int Add(int a, int b)
{
return (a + b);
}
//Main method
static void Main(string[] args) {
//Print Hello World! message
Console.WriteLine("Hello World!");
//Create HelloWorld class object
HelloWorld hw = new HelloWorld();
//Calling Add method from the HelloWorld(hw) object, adding 1 + 2
int adding = hw.Add(1,2);
//Prints the adding variable
Console.WriteLine(adding);
}
}
}
</textarea> </p><ol style="text-align: left;"><li><b> Install mono-complete package:</b><p> <textarea style="height: 44px; width: 302px;">$ sudo apt install mono-complete
</textarea></p></li>
<br />
<li><b>Compile the hello.cs script, in order to generate the hello.exe file</b><p><b>
</b><textarea style="height: 36px; width: 255px;">$ mcs -out:hello.exe hello.cs
</textarea>
</p></li>
<br />
<li><b>Execute the hello.exe file with the mono command</b><p>
<b><textarea style="height: 40px; width: 177px;">$ mono hello.exe
</textarea></b></p></li>
</ol>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-69701638367135400252021-01-26T11:44:00.003-06:002021-01-26T12:07:55.527-06:00Compilar y Ejecutar C# en Ubuntu Linux<p>Para explicar como compilar y ejecutar código C# en Ubuntu, haremos un hello world y un método para sumar dos números y mostrar el resultado de esa sumatoria después del mensaje de hello world.</p><ul style="text-align: left;"><li><b>Creamos el archivo hello.cs con el siguiente contenido:</b></li></ul><p> <br />
<textarea style="height: 509px; width: 619px;">using System;
//Se declara el namespace
namespace HelloWorldApp {
//Se declara la clase
class HelloWorld {
//Método Add para sumar dos números
public int Add(int a, int b)
{
return (a + b);
}
//Método Main o Principal
static void Main(string[] args) {
//Se imprime mensaje Hello World!
Console.WriteLine("Hello World!");
//Se crea objeto de la clase HelloWorld
HelloWorld hw = new HelloWorld();
//Se invoca al método Add de la clase Hello World(hw), para sumar 1 + 2
int adding = hw.Add(1,2);
//Se imprime la variable adding, que es el resultado de la sumatoria.
Console.WriteLine(adding);
}
}
}
</textarea> </p><ol style="text-align: left;"><li><b> Instalamos el paquete mono-complete:</b><p> <textarea style="height: 44px; width: 302px;">$ sudo apt install mono-complete
</textarea></p></li>
<br />
<li><b>Compilamos el script hello.cs, generando el archivo hello.exe</b><p><b>
</b><textarea style="height: 36px; width: 255px;">$ mcs -out:hello.exe hello.cs
</textarea>
</p></li>
<br />
<li><b>Ejecutamos el archivo hello.exe con el comando mono</b><p>
<b><textarea style="height: 40px; width: 177px;">$ mono hello.exe
</textarea></b></p></li>
</ol>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-15678491022702558852012-12-11T21:14:00.000-06:002012-12-11T21:14:00.768-06:00Script for downloading chapters from mangareader.netToday I write to share you a script for downloading manga chapters from the site: <a href="http://www.mangareader.net/">mangareader.net</a><br />
<br />
I made this script for personal use but I've decide to share it.<br />
<br />
I chose the name getMangaReader for the script, but if there's already a script that works for the same purpose and has the same name please notify me to change it.<br />
<br />
It is only for Linux systems and it needs to be run with sh.<br />
<br />
The previous requirement you need to run the script is to have installed:<br />
<br />
<ul>
<li>wget</li>
</ul>
<br />
The URL for downloading is: <a href="http://sourceforge.net/projects/getmangareader/files/getMangaReaderEN.zip/download">getMangaReader</a><br />
<br />
For spanish version <a href="http://sourceforge.net/projects/getmangareader/files/getMangaReaderES.zip/download">here</a><br />
<br />
The user instructions are inside the downloaded .zip file. <br />
<br />
The script is under the <a href="http://www.gnu.org/licenses/">GNU</a> license. <br />
<br />
If you have any doubt about the use or modification that you want me to do to the script or you want to do by yourself please write a comment.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-61746312692374831132012-12-11T20:56:00.001-06:002012-12-11T21:15:04.776-06:00Script para descargar capítulos de mangareader.netHoy escribo para compartirles un script para descargar capítulos de manga desde el sitio: <a href="http://www.mangareader.com/">mangareader.net</a><br />
<br />
Este script lo hice para uso personal pero he decidido compartirlo.<br />
<br />
Le puse de nombre <b>getMangaReader</b>, pero si ya existe un script que funcione para lo mismo y tenga ya este nombre porfavor díganme para cambiarlo. <br />
<br />
Es sólo para sistemas Linux ya que necesita correrse con sh.<br />
<br />
Los requisitos son tener instalado:<br />
<br />
<ul>
<li>wget</li>
</ul>
<br />
URL de descarga: <a href="http://sourceforge.net/projects/getmangareader/files/getMangaReaderES.zip/download">getMangaReader</a> <br />
<br />
Versión en inglés <a href="http://sourceforge.net/projects/getmangareader/files/getMangaReaderEN.zip/download">aquí</a><br />
<br />
Las instrucciones de uso vienen dentro del .zip que se descarga.<br />
<br />
El programa se encuentra licenciado bajo <a href="http://www.gnu.org/licenses/">GNU</a>.<br />
<br />
Si tienen alguna duda sobre uso o modificación que quieran que le haga o que ustedes mismos quieran hacerle comenten porfavor.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-36623439758458995322012-08-10T11:56:00.000-05:002012-08-10T11:56:23.918-05:00Configuración de un DNS IPv6 local en Linux con BindHoy escribiré sobre como crear un DNS dentro de nuestra LAN utilizando IPv6.<br />
<br />
Como en un tema anterior ya escribí sobre algo de teoría del DNS y Bind9 y su respectiva instalación pasaremos directamente a la configuración de los archivos para un DNS IPv6. Si tienen dudas de teoría consulten el post anterior <a href="http://rukiaenix.blogspot.mx/2012/07/instalar-un-dns-local-en-linux-con-bind.html" target="_blank">aquí</a>.<br />
<br />
<b>Para Ubuntu y similares</b><br />
<br />
Utilizaremos las siguientes IPv6 de sitio de ejemplo:<br />
<br />
<ul>
<li>Servidor DNS - fec0::a987:200:27ff:fe59:bfd6</li>
<li>Cliente - fec0::a987:21f:d0ff:fe45:4e76 para el cliente </li>
<li>Con una máscara de red de 64 bits </li>
<li>Por lo que nuestra dirección IPv6 de red es fec0:0:0:a987::/64</li>
</ul>
<br />
Y los siguientes dominios de ejemplo:<br />
<br />
<ul>
<li>Servidor - rukia.com y también responderá por www.rukia.com</li>
<li>Cliente - goku.rukia.com</li>
</ul>
<br />
Los archivos a configurar se encuentran en el directorio <b>/etc/bind</b><br />
<br />
Primero editamos este archivo:<br />
<br />
<center>
<textarea cols="40">/etc/bind/named.conf.default-zones</textarea></center>
<div style="text-align: left;">
</div>
<br />
Por default el archivo contiene lo siguiente:<br />
<br />
<center>
<textarea cols="40" rows="25">zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
En este archivo se declaran las zonas.<br />
<br />
Para agregar nuestra zona agregamos estas líneas:<br />
<br />
<center>
<textarea cols="40" rows="5">zone "rukia.com" {
type master;
file "/etc/bind/db.rukiav6";
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Ahora agregamos la zona inversa de nuestra red:<br />
<br />
<center>
<textarea cols="60" rows="5">zone "7.8.9.a.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa" {
type master;
file "/etc/bind/db.rukiaRevv6";
};
</textarea></center>
<div style="text-align: left;">
</div>
<br />
Noten que la dirección de red se escribe de derecha a izquierda.<br />
Nuestra dirección de red IPv6 escrita completamente es:<br />
<br />
<div style="text-align: center;">
f.e.c.0.0.0.0.0.0.0.0.0.a.9.8.7 (fec0:0:0:a987)</div>
<br />
Recuerden que el nombre de los archivos de zona puede ser el que quieran, en este ejemplo para el archivo de zona se está utilizando db.rukiav6 y para la zona inversa db.rukiaRevv6.<br />
<br />
Al final nuestro archivo named.conf.default-zones se ve de esta forma:<br />
<br />
<center>
<textarea cols="50" rows="35">zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "rukia.com" {
type master;
file "/etc/bind/db.rukiav6";
};
zone "7.8.9.a.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa" {
type master;
file "/etc/bind/db.rukiaRevv6";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Ahora antes de continuar revisemos que nuestro archivo de zonas y el de las opciones está incluido dentro de named.conf, entonces revisemos este archivo:<br />
<br />
<center>
<textarea>/etc/bind/named.conf</textarea></center>
<div style="text-align: left;">
</div>
<br />
Debe de conener lo siguiente:<br />
<br />
<center>
<textarea cols="45" rows="5">include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones"; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Ahora editemos nuestro archivo de zona (/etc/bind/db.rukiav6):<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. root.rukia.com. (
2 ; Serial
120 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS @
@ IN AAAA fec0::a987:200:27ff:fe59:bfd6
www IN CNAME @
goku IN AAAA fec0::a987:21f:d0ff:fe45:4e76 </textarea></center>
<div style="text-align: left;">
</div>
<br />
Recuerden que para IPv6 se utiliza el registro AAAA.<br />
<br />
Ahora a editar el archivo de zona inversa (/etc/bind/db.rukiaRevv6):<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. root.rukia.com. (
1 ; Serial
120 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS rukia.com.
6.d.f.b.9.5.e.f.f.f.7.2.0.0.2.0 IN PTR rukia.com.
6.7.e.4.5.4.e.f.f.f.0.d.f.1.2.0 IN PTR goku.rukia.com. </textarea></center>
<div style="text-align: left;">
</div>
<br />
Noten que las direcciones de host se escriben de derecha a izquierda.<br />
<br />
Nuestra dirección de host IPv6 escrita completamente para el servidor es:<br />
<br />
<div style="text-align: center;">
0.2.0.0.2.7.f.f.f.e.5.9.b.f.d.6 (0200:27ff:fe59:bfd6)</div>
<br />
Y la dirección de host IPv6 escrita completamente para el cliente es: <br />
<br />
<div style="text-align: center;">
0.2.1.f.d.0.f.f.f.e.4.5.4.e.7.6 (021f:d0ff:fe45:4e76)</div>
<br />
Ahora sólo falta el archivo named.conf.options, pero la configuración que viene de default para Ubuntu es suficiente. Sólo si tenemos un error que dice que el servidor rechaza las conexiones al tratar de resolver dominios desde el cliente debemos revisar que el archivo incluya estas líneas:<br />
<br />
<center>
<textarea cols="30" rows="5">options {
allow-query { any; };
recursion yes;
listen-on-v6 { any; };
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Para iniciar el servicio ejecutamos este comando:<br />
<br />
<center>
<textarea cols="30">/etc/init.d/bind9 start</textarea></center>
<div style="text-align: left;">
</div>
<br />
Y listo, ya tenemos un DNS IPv6.<br />
<br />
<br />
<b>Configuración para Fedora y similares</b><br />
<br />
Utilizaremos las siguientes IPv6 de sitio de ejemplo:<br />
<br />
<ul>
<li>Servidor DNS - fec0::a987:200:27ff:fe59:bfd6</li>
<li>Cliente - fec0::a987:21f:d0ff:fe45:4e76 para el cliente </li>
<li>Con una máscara de red de 64 bits </li>
<li>Por lo que nuestra dirección IPv6 de red es fec0:0:0:a987::/64</li>
</ul>
<br />
Y los siguientes dominios de ejemplo:<br />
<br />
<ul>
<li>Servidor - rukia.com y también responderá por www.rukia.com</li>
<li>Cliente - goku.rukia.com </li>
</ul>
<br />
El primer archivo a editar es:<br />
<br />
<center>
<textarea>/etc/named.conf</textarea></center>
<div style="text-align: left;">
</div>
<br />
En este archivo se declaran las opciones y archivos de zona, por default el archivo contiene lo siguiente:<br />
<br />
<center>
<textarea cols="70" rows="35">options {
listen-on port 53 { 127.0.0.1;10.9.8.50 };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost;10.9.8.0/24 };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; </textarea></center>
<div style="text-align: left;">
</div>
<br />
<br />
Primero editemos las opciones, las que nos interesan son:<br />
<br />
<ul>
<li>listen-on-v6</li>
<li>directory</li>
<li>allow-query</li>
<li>recursion</li>
</ul>
<br />
Así que la sección de opciones debe tener lo siguiente:<br />
<br />
<center>
<textarea cols="70" rows="6">options {
listen-on-v6 port 53 { ::1;fec0::a987:200:27ff:fe59:bfd6; };
directory "/var/named";
allow-query { any; };
recursion yes;
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Ahora pasemos a agregar la zona y zona inversa al archivo.<br />
<br />
<b> </b><br />
<br />
Como agregar la zona:<br />
<br />
<center>
<textarea cols="40" rows="5">zone "rukia.com" {
type master;
file "named.rukiav6";
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Como agregar la zona inversa:<br />
<br />
<center>
<textarea cols="50" rows="5">zone "7.8.9.a.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa" {
type master;
file "named.rukiaRevv6";
}; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Noten que la dirección de red se escribe de derecha a izquierda.<br />
Nuestra dirección de red IPv6 escrita completamente es:<br />
<br />
<div style="text-align: center;">
f.e.c.0.0.0.0.0.0.0.0.0.a.9.8.7 (fec0:0:0:a987)</div>
<br />
Recuerden
que el nombre de los archivos de zona puede ser el que quieran, en este
ejemplo para el archivo de zona se está utilizando named.rukiav6 y para la
zona inversa named.rukiaRevv6.<br />
<br />
Al final nuestro archivo named.conf se ve de esta forma:<br />
<br />
<center>
<textarea cols="70" rows="45">options {
listen-on-v6 port 53 { ::1;fec0::a987:200:27ff:fe59:bfd6; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "rukia.com" {
type master;
file "named.rukiav6";
};
zone "7.8.9.a.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa" {
type master;
file "named.rukiaRevv6";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; </textarea></center>
<div style="text-align: left;">
</div>
<br />
Ahora escribamos los archivos de zona. Por default y para el ejemplo se encuentran en el directorio <b>/var/named</b>.<br />
<br />
Archivo de zona (named.rukiav6):<br />
<br />
<center>
<textarea cols="60" rows="13">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
0 ; serial
120 ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
AAAA fec0::a987:200:27ff:fe59:bfd6
www CNAME rukia.com.
goku AAAA fec0::a987:21f:d0ff:fe45:4e76 </textarea></center>
<div style="text-align: left;">
</div>
<br />
Archivo de zona inversa (named.rukiaRevv6):<br />
<br />
<center>
<textarea cols="60" rows="13">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
0 ; serial
120 ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS rukia.com.
6.d.f.b.9.5.e.f.f.f.7.2.0.0.2.0 PTR rukia.com.
6.7.e.4.5.4.e.f.f.f.0.d.f.1.2.0 PTR goku.rukia.com. </textarea></center>
<div style="text-align: left;">
</div>
<br />
Noten que las direcciones de host se escriben de derecha a izquierda.<br />
<br />
Nuestra dirección de host IPv6 escrita completamente para el servidor es:<br />
<br />
<div style="text-align: center;">
0.2.0.0.2.7.f.f.f.e.5.9.b.f.d.6 (0200:27ff:fe59:bfd6)</div>
<br />
Y la dirección de host IPv6 escrita completamente para el cliente es: <br />
<br />
<br />
<div style="text-align: center;">
0.2.1.f.d.0.f.f.f.e.4.5.4.e.7.6 (021f:d0ff:fe45:4e76)</div>
<div style="text-align: center;">
</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<br />
Esta es toda la configuración.</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<br />
Para iniciar el servicio ejecutamos lo siguiente: </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<center>
<textarea cols="30">/etc/init.d/named start</textarea></center>
<div style="text-align: left;">
</div>
<br />
Y listo ya tenemos un DNS IPv6.<br />
<br />
<br />
<b>Configuración del DNS en los clientes</b><br />
<br />
Para establecer el DNS en los clientes sólo hay que agregar la IP del servidor de nombres de dominio o DNS a nuestra configuración de red. Voy a explicar como se haría en modo consola, en modo gráfico es con el editor de conexiones de red en configuración manual para IPv6.<br />
<br />
En consola sólo hay que editar el archivo:<br />
<br />
<center>
<textarea>/etc/resolv.conf</textarea></center>
<div style="text-align: left;">
</div>
<br />
Con esto los clientes ya podrán consultar nuestro DNS.<br />
<br />
<br />
<b>Como comprobar la resolución de nombres de dominio</b><br />
<br />
Se pueden utilizar los comandos nslookup y dig, la diferencia es que dig nos manda un poco más de información.<br />
<br />
Sólo que para que funcionen con IPv6, hay que mandar un parámetro extra a estos comandos.<br />
<br />
Comprobar con nslookup:<br />
<br />
<center>
<textarea cols="30">nslookup -type=AAAA rukia.com</textarea></center>
<div style="text-align: left;">
</div>
<br />
Comprobar con dig:<br />
<br />
<center>
<textarea>dig -t AAAA rukia.com</textarea></center>
<div style="text-align: left;">
</div>
<br />
<br />
Y bueno esto es todo para tener un DNS IPv6 rápido dentro de una LAN. Saludos!rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com3tag:blogger.com,1999:blog-2401974794251107096.post-12229973588210619462012-08-09T12:35:00.000-05:002012-08-09T12:37:49.658-05:00Basic IPv6 network configuration for LinuxToday I'll write on how to configure Linux with IPv6. Today we'll go directly to the practice since in an older post I wrote about IPv6 addresses.<br />
<br />
<br />
<b>Verify if the system has IPv6 enabled</b><br />
<br />
The IPv6 module is integrated since kernel 2.4.x even though it's not always enable.<br />
<br />
With this command we can verify if it is or not enable:<br />
<br />
<center>
<textarea cols="60">test -f /proc/net/if_inet6 && echo "Enable"</textarea></center>
<div style="text-align: left;">
</div>
<br />
If it returns the message "Enable" this means that it's enable (obvious). If not we activate it with the next commands.<br />
<br />
<br />
<b>For Ubuntu or similars:</b><br />
<br />
<center>
<textarea>modprobe ipv6</textarea></center>
<div style="text-align: left;">
</div>
<br />
And if we want the IPv6 module to be loaded at boot time we add the word ipv6 to the end of this file:<br />
<br />
<center>
<textarea>/etc/modules</textarea></center>
<div style="text-align: left;">
</div>
<br />
<br />
<b>For Fedora or similars</b><br />
<br />
We edit this file:<br />
<br />
<center>
<textarea>/etc/sysconfig/network</textarea></center>
<div style="text-align: left;">
</div>
<br />
And we add this line to the file:<br />
<br />
<center>
<textarea>NETWORKING_IPV6=yes</textarea></center>
<div style="text-align: left;">
</div>
<br />
Now that we added it we restart the network service.<br />
<br />
Also if we want to allow the forwarding of IPv6 packages in our computer we apply these commands and settings.<br />
<br />
<br />
<b>Enable IPv6 package forwarding</b><br />
<br />
<b>In Ubuntu and similars</b><br />
<br />
We activate the forwarding with this command:<br />
<br />
<center>
<textarea cols="40">sysctl -w net.ipv6.conf.all.forwarding=1</textarea></center>
<div style="text-align: left;">
</div>
<br />
And for enabling forwarding since boot time, we edit this file:<br />
<br />
<center>
<textarea cols="40">/usr/share/doc/procps/examples/sysctl.conf</textarea></center>
<div style="text-align: left;">
</div>
<br />
Adding this line:<br />
<br />
<center>
<textarea cols="40">net.ipv6.conf.all.forwarding=1</textarea></center>
<div style="text-align: left;">
</div>
<br />
Then we copy this file to /etc.<br />
And finally we edit this file:<br />
<br />
<center>
<textarea>/etc/rc.local</textarea></center>
<div style="text-align: left;">
</div>
<br />
Adding this line:<br />
<br />
<center>
<textarea>sysctl -p</textarea></center>
<div style="text-align: left;">
</div>
<br />
<br />
<b>How to activate it in Fedora and similars</b><br />
<br />
We edit the file:<br />
<br />
<center>
<textarea>/etc/sysctl.conf</textarea></center>
<div style="text-align: left;">
</div>
<br />
Adding this line:<br />
<br />
<center>
<textarea cols="40">net.ipv6.conf.all.forwarding=1</textarea></center>
<div style="text-align: left;">
</div>
<br />
Now let's go to configure our interfaces.<br />
<br />
<br />
<b>Configure IPv6 network on Ubuntu and similars</b><br />
<br />
We'll use as example the IPv6 local-site address FECO::A987:211:22FF:FE33:4455 with a netmask of 64 bits.<br />
<br />
We edit the file:<br />
<br />
<center>
<textarea cols="40">/etc/network/interfaces</textarea></center>
<div style="text-align: left;">
</div>
<br />
With these lines (using as example the interface eth0):<br />
<br />
<center>
<textarea cols="40" rows="6">auto eth0
iface eth0 inet6 static
address FEC0::A987:211:22FF:FE33:4455
netmask 64 </textarea></center>
<div style="text-align: left;">
</div>
<br />
In this configuration we didn't set a gateway but we can do it writing this setting: gateway6 <i>address</i>.<br />
<br />
<br />
<b>Configure IPv6 network on Fedora and similars</b><br />
<br />
We edit the file:<br />
<br />
<center>
<textarea cols="40">/etc/sysconfig/network-scripts/ifcfg-eth0</textarea></center>
<div style="text-align: left;">
</div>
<br />
Were we substitute eth0 with the interface that we are planning to use.<br />
<br />
We edit it with these lines:<br />
<br />
<center>
<textarea cols="40" rows="6">DEVICE=eth0
BOOTPROTO=static
IPV6INIT=yes
IPV6ADDR=FEC0::A987:211:22FF:FE33:4455/64
ONBOOT=yes </textarea></center>
<div style="text-align: left;">
</div>
<br />
We can also add a gateway like this: IPV6_DEFAULTGW=address<br />
Now we have and IPv6 network configuration in our computer.<br />
<br />
<br />
<b>How to test the connectivity</b><br />
<br />
To test connectivity between computers using IPv6 we use the command ping6:<br />
<br />
<center>
<textarea cols="40">ping6 FEC0::A987:211:22FF:FE33:4455</textarea></center>
<div style="text-align: left;">
</div>
<br />
And ready, now we have a basic IPv6 network configuration. Hope it has helped to the ones that doesn't know and for the ones that already know and needed a refreshment of info.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-83733394728112346372012-07-20T20:43:00.001-05:002012-07-20T20:50:51.918-05:00Configuración básica de red IPv6 en LinuxHoy escribiré sobre como configurar Linux con IPv6. Ya en un tema anterior hable sobre como formar las direcciones IPv6 y los tipos de dirección que existen. Así que hoy iremos directo sobre la práctica.<br />
<br />
El tema es corto pero es que es así de sencillo configurar un equipo con IPv6, a lo mejor muchos ya saben pero también Linux siempre tiene gente nueva que busca estas cosas que para muchos ya son muy "sencillas". <br />
<br />
<br />
<b>Verificar que el sistema tiene activado IPv6</b><br />
<br />
El módulo de IPv6 ya viene integrado en todos los kernel 2.4.x aunque no siempre se encuentra activado.<br />
<br />
<br />
Con este comando podemos verificar si lo está o no:<br />
<br />
<br />
<br />
<br />
<br />
<center><textarea cols="60">test -f /proc/net/if_inet6 && echo "Si activado"</textarea></center><br />
<div style="text-align: left;">
</div>
<br />
Si nos devuelve el mensaje "Si activado" quiere decir que ya se encuentra activado IPv6. De lo contrario lo activamos con estos comandos.<br />
<br />
<b>Para Ubuntu o similares: </b><br />
<br />
<br />
<br />
<br />
<center><textarea>modprobe ipv6</textarea></center><br />
<div style="text-align: left;">
</div>
<br />
Para que el módulo IPv6 cargue automáticamente cuando inicia el sistema se agrega la palabra ipv6 al final del archivo:<br />
<br />
<br />
<br />
<center><textarea>/etc/modules</textarea></center><br />
<div style="text-align: left;">
</div>
<br />
<br />
<b>Para Fedora o similares:</b><br />
<br />
Se edita este archivo:<br />
<br />
<br />
<br />
<br />
<center><textarea>/etc/sysconfig/network</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Y agregamos esta línea al archivo:</div>
<br />
<br />
<br />
<br />
<center><textarea>NETWORKING_IPV6=yes</textarea></center>
<br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Ya que la agregamos reiniciamos el servicio de red.</div>
<br />
También para permitir el reenvío de paquetes IPv6 en nuestro equipo por si se llega a necesitar esta función en el futuro, aplicamos lo siguiente.<br />
<br />
<br />
<br />
<b>Habilitar reenvío de paquetes IPv6</b><br />
<br />
<b>En Ubuntu y similares </b><br />
<br />
Con el siguiente comando se puede activar el reenvío:<br />
<br />
<br />
<center><br /></center><center><textarea cols="40">sysctl -w net.ipv6.conf.all.forwarding=1</textarea></center><br />
<div style="text-align: left;">
</div>
<br />
Y para activar el reenvío desde el inicio del sistema se edita este archivo:<br />
<br />
<br />
<br />
<br />
<center><textarea cols="40">/usr/share/doc/procps/examples/sysctl.conf</textarea></center><br />
<div style="text-align: left;">
</div>
<br />
Agregando la siguiente línea:<br />
<br />
<br />
<br />
<br />
<center><textarea cols="40">net.ipv6.conf.all.forwarding=1</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Después este archivo se copia a /etc.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Y finalmente se edita este archivo:</div>
<br />
<br />
<br />
<br />
<center><textarea>/etc/rc.local</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Agregando esta línea:</div>
<div style="text-align: left;">
<br /></div>
<br />
<br />
<br />
<center><textarea>sysctl -p</textarea></center><center><br /></center><br />
<div style="text-align: left;">
<br />
<b>Para activarlo en Fedora y similares:</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Se edita el archivo:</div>
<br />
<br />
<br />
<center><textarea>/etc/sysctl.conf</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Agregando esta línea:</div>
<div style="text-align: left;">
<br /></div>
<br />
<br />
<br />
<center><textarea cols="40">net.ipv6.conf.all.forwarding=1</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Ahora si pasemos a configurar nuestras interfaces.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br />
<br />
<b>Configurar red en Ubuntu y similares</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Utilizaremos de ejemplo la IPv6 local de sitio FEC0::A987:211:22FF:FE33:4455 con máscara de subred de 64 bits. <br />
<br />
Se edita el archivo:</div>
<br />
<br />
<br />
<br />
<center><textarea cols="40">/etc/network/interfaces</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Con las siguientes líneas:</div>
<br />
<br />
<br />
<br />
<center><textarea cols="40" rows="5">auto eth0
iface eth0 inet6 static
address FEC0::A987:211:22FF:FE33:4455
netmask 64 </textarea></center><center><br /></center><br />
<div style="text-align: left;">
En esta configuración no establecimos gateway pero también se puede escribiendo así: gateway6 <i>dirección</i>.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br />
<b>Configurar red en Fedora y similares</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Se edita el archivo:</div>
<br />
<br />
<br />
<br />
<center><textarea cols="40">/etc/sysconfig/network-scripts/ifcfg-eth0</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Donde eth0 se sustituye por la interfaz que estén utilizando.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Se edita con estas líneas:</div>
<br />
<br />
<br />
<br />
<br />
<center><textarea cols="40" rows="5">DEVICE=eth0
BOOTPROTO=static
IPV6INIT=yes
IPV6ADDR=FEC0::A987:211:22FF:FE33:4455/64
ONBOOT=yes </textarea></center><center><br /></center><br />
<div style="text-align: left;">
También se le puede agregar un gateway de esta forma: IPV6_DEFAULTGW=<i>dirección</i></div>
<div style="text-align: left;">
<i><br /></i></div>
<div style="text-align: left;">
Con esto ya tenemos una dirección IPv6 en nuestro equipo.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br />
<br />
<b>Como comprobar la conectividad</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Para comprobar la conectividad entre equipos que utilizan IPv6 se utiliza el ping6:</div>
<div style="text-align: left;">
</div>
<br />
<br />
<br />
<center><textarea cols="40">ping6 FEC0::A987:211:22FF:FE33:4455</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Y listo ya tenemos una configuración IPv6 básica. Espero que les sirva a los que no saben y a los que no saben por si querían recordarlo.</div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com1tag:blogger.com,1999:blog-2401974794251107096.post-62486680683052942852012-07-17T20:03:00.000-05:002012-08-10T10:43:37.204-05:00Install a local DNS in Linux with BindHow to mount a quick and basic DNS in a local network.<br />
<br />
First let's see the types of DNS and DNS records.<br />
<br />
<br />
<b>Types of DNS</b><br />
<br />
<b>Master:</b> Owns the authoritative records of a zone, answers the requests of name resolution as an authoritative server and delegates copies to the slave servers.<br />
<br />
<b>Slave:</b> Answers to the name resolution requests as an authority server, but the information is distributed by the master servers.<br />
<br />
<b>Cachingonly:</b> Answers to name resoution requests but it is not an authority server, it saves the answers in memory by a determined period of time.<br />
<br />
<b>Forwarding:</b> Forwards the requests to a list of name servers.<br />
<br />
<br />
<b>DNS Records</b><br />
<br />
<b>A (Address):</b> Defines an IP address and the name assigned to the host.<br />
<br />
<b>AAAA:</b> It's the replacement of the A records when the traduction is from name to IPv6 address. <br />
<br />
<b>MX (Mail eXchanger):</b> It's used to identify mail servers.<br />
<br />
<b>CNAME (Canonical Name):</b> Is an alias that is assigned to a host that has an IP address and answers to different names. You can declare various for a host.<br />
<br />
<b>NS (Name Server):</b> Defines the principal name servers of a domain. It most have one at least.<br />
<br />
<b>SOA (Start Of Authority):</b> This is the first record of the zone and it can only be one for each zone file and it's only present if the server is authority of the domian.<br />
Specifies the primary DNS of the domain, the administrator mail account and the times of refresh.<br />
<br />
<b>PTR (Domain Name Pointer):</b> Indicates to which IP address corresponds a name.<br />
<br />
<br />
<b>Parameters of the SOA record</b><br />
<br />
<b>Serial:</b> The serial number is used to synchronize the zones between the primary and secondary DNS. If when the secondary DNS consults the primary DNS finds that the serial number is bigger than the one it has it means that the zone file has been updated, so it will ask for a copy of the updated version. <br />
<br />
<b>Refresh:</b> Is the time that a secondary DNS has to wait to verify again the record values of a primary DNS.<br />
<br />
<b>Retry:</b> Is the time that a secondary DNS has to wait after a failed attempt to retrieve data from a primary DNS.<br />
<br />
<b>Expire:</b> Is the time that data will remain in a secondary DNS before they expire.<br />
<br />
<b>Negative Cache TTL:</b> Is the time that a DNS cache will remember the negative consults (NXDOMAIN).<br />
<br />
Ok now that we saw some theory let's start with the installation and configuration for the Ubuntu and Fedora distros.<br />
<br />
<br />
<b>Installation and configuration for Ubuntu and similars</b><br />
<br />
Versions in example: Ubuntu 10.04, Bind 9.7.0-P1<br />
If the versions are different to these ones they might be some variations, but if it is a Bind version 9 you shouldn't have problems.<br />
<br />
Installation:<br />
<br />
<br />
<center>
<textarea>apt-get install bind9</textarea></center>
<br />
<div style="text-align: left;">
<br />
Now we have to go to the directory /etc/bind there we'll find our configuration files.<br />
<br />
Well, for the example we'll use the rukia.com domain, that will also be our DNS, in the example the server has the IP of 10.9.8.50 (rukia.com) and our client has the IP of 10.9.8.1 to which we'll set the domain name of goku.rukia.com.<br />
<br />
The first file we have to edit is where the zones are declared:<br />
<br />
<br />
<br />
<center>
<textarea cols="40">/etc/bind/named.conf.default-zones</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
For default the file contains this:<br />
<br />
<br />
<br />
<center>
<textarea cols="40" rows="25">zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
</div>
In this content the next zones are declared: the root public primary DNS, localhost, reverse localhost, broadcast and reverse broadcast.<br />
<br />
For our own zone using as example that we want to add the domain rukia.com and that the name of the zone file is db.rukia, we add the zone like this:<br />
<br />
<br />
<br />
<center>
<textarea cols="90" rows="5">zone "rukia.com" {
type master; //type of DNS
file "/etc/bind/db.rukia"; //path of the zone file for rukia.com
};</textarea></center>
<br />
<br />
Now we add the reverse zone file. The reverse zone is to resolved from an IP address to a domain name. For the example we'll add the reverse zone to the network 10.9.8.0, that is the network to which our example IPs belong (10.9.8.1 and 10.9.8.50) and with the name of the reverse zone file as db.rukiaRev:<br />
<div style="text-align: left;">
</div>
</div>
</div>
<br />
<br />
<br />
<center>
<textarea cols="40" rows="5">zone "8.9.10.in-addr.arpa" {
type master;
file "/etc/bind/db.rukiaRev";
};</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Note that the network address is written backwards, our network is 10.9.8.0, so it was written 8.9.10.<br />
The names for the zone files can be any name we want.<br />
In the end the named.conf.default-zones file has to look like this:<br />
<div style="text-align: left;">
</div>
</div>
<br />
<br />
<br />
<center>
<textarea cols="40" rows="35">zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "rukia.com" {
type master;
file "/etc/bind/db.rukia";
};
zone "8.9.10.in-addr.arpa" {
type master;
file "/etc/bind/db.rukiaRev";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};</textarea></center>
<br />
<br />
Before we continue with the zones, let's check that the named.conf file includes the file named.conf.default-zones, for this we just have to read the next file:<br />
<div style="text-align: left;">
</div>
<br />
<center>
<textarea>/etc/bind/named.conf</textarea></center>
<br />
<br />
The file must contain this:<br />
<div style="text-align: left;">
</div>
<br />
<br />
<br />
<center>
<textarea cols="50" rows="4">include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";</textarea></center>
<br />
<div style="text-align: left;">
</div>
<br />
Now let's write our zone file for rukia.com (/etc/bind/db.rukia), we'll also add in it the name goku.rukia.com for the client 10.9.8.1 and also that if we search for the name www.rukia.com it will give us the IP 10.9.8.50.<br />
So the file must look like this:<br />
<br />
<br />
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
2 ; Serial
120 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS rukia.com.
@ IN A 10.9.8.50
www IN CNAME rukia.com.
goku IN A 10.9.8.1</textarea></center>
<br />
<div style="text-align: left;">
</div>
<br />
I'll explain the file line by line (from line 0 to 10, without counting spaces)<br />
<br />
0 - The TTL is set, the TTL is the Time To Live that the consults to the cache will persist instead of consulting the server, this means that if a domain has already been consulted, and another consult is done inside the TTL time, the consult will be made to the cache, but if this time has expired the consult will be made to the server. In the example I put 120 seconds, thinking in critic situations where the domain name has to be updated instantly. The default time is 6054800 seconds.<br />
<br />
1 - The SOA is set and the email account of the domain administrator. The email is written like this: rukia.rukia.com, the @ is changed for a period, but the real email is rukia@rukia.com.<br />
<br />
2 to 6 - The SOA parameters.<br />
<br />
7 - The NameServer is set for the domain, in this case is the same server (rukia.com). The @ makes reference to the domain name to which the zone belongs, in this case is rukia.com. This means that for this zone @=rukia.com.<br />
<br />
8 - The rukia.com domain is pointed to the IP 10.9.8.50.<br />
<br />
9 - The canonical name www.rukia.com is set. This means that if rukia.com or www.rukia.com is resolved the answer will always be 10.9.8.50.<br />
<br />
10 - The domain name goku.rukia.com is set to the IP 10.9.8.1.<br />
<br />
Now let's create the reverse zone file for our network (/etc/bind/db.rukiaRev):<br />
<br />
<br />
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
1 ; Serial
120 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS rukia.com.
50 IN PTR rukia.com.
1 IN PTR goku.rukia.com.</textarea></center>
<br />
<div style="text-align: left;">
<br />
Again I'll explain the file line by line (0 to 9, without counting spaces)<br />
<br />
0 - TTL.<br />
<br />
1 - The SOA and the administrator email is set.<br />
<br />
2 to 6 - SOA parameters.<br />
<br />
7 - The NameServer is set, in this case is the same server.<br />
<br />
8 - The IP 10.9.8.50 is pointed to the domain rukia.com. Note that is only written the host address from theIP. The network address is 10.9.8.0, so the host address is 0.0.0.50.<br />
<br />
9 - The IP 10.9.8.1 is pointed to the domain goku.rukia.com.<br />
<br />
Now we're only missing the named.conf.options file, but for Ubuntu there's no need to edit it, only in case of having problems with the reverse resolution or if we see and error that says that the DNS refuses the connections when we are trying to resolve the domain names from a client. If this happens we have to verify that the next options are added to the /etc/bind/named.conf.options file to avoid this errors:</div>
<br />
<br />
<br />
<center>
<textarea cols="40" rows="5">options {
allow-query { any; };
recursion yes;
};</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
<br />
To start the service we have to execute this command:</div>
<br />
<br />
<center>
<textarea cols="40">/etc/init.d/bind9 start</textarea></center>
<br />
<div style="text-align: left;">
<br />
And ready, we have a functional and quick DNS for our LAN.<br />
<br />
<br />
<br />
<b>Installation and configuration for Fedora and similars</b><br />
<br />
Versions in the example: Fedora 16 Security Spin, Bind 9.8.3-P1-RedHat-9.8.3-2.P1.fc16<br />
If the versions are different to these ones they might be some variations, but as long as it is a Bind 9 there should not be any problem.<br />
<br />
Installation:</div>
<br />
<center>
<textarea>yum install bind</textarea></center>
<br />
<div style="text-align: left;">
<br />
Well, for the example we'll use the domain rukia.com, that will also be our DNS, in this example the server has the IP address of 10.9.8.50 (rukia.com) and our client has the IP 10.9.8.1 to which we'll set the domain name of goku.rukia.com.<br />
<br />
The first file to edit is named.conf:</div>
<br />
<br />
<br />
<center>
<textarea>/etc/named.conf</textarea></center>
<br />
<div style="text-align: left;">
<br />
In this file the options for our DNS and the zones will be declared, for default the file already has this:</div>
<br />
<br />
<br />
<center>
<textarea cols="80" rows="35">options {
listen-on port 53 { 127.0.0.1;10.9.8.50 };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost;10.9.8.0/24 };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; </textarea></center>
<br />
<div style="text-align: left;">
<br />
In this file the options we are interested in editing are:<br />
<br />
<b>listen-on-port 53 {127.0.0.1; };</b> - Here is set that the server will be listening in the port 53 for the localhost IP. Here we have to add the IP of our local computer so it can attend requests from the client in the LAN, in this case we'll add the example IP that is 10.9.8.50.<br />
<br />
<b>directory "/var/named";</b> - The directory where the zone files will be stored, it can be other directory as long as the named service has the rights to read. For the example we'll leave the default directory.<br />
<br />
<b>allow-query {localhost; };</b> - Sets who'll be permited to consult the DNS, for default it is only allow to localhost. For the example we just need to allow the localhost and our LAN, so we'll add 10.9.8.0/24. If we want to any client to request our DNS we only have to add the word any in place of localhost or an IP address.<br />
<br />
<b>recursion yes;</b> - Allow the reverse request. This means that if we make a request to obtain the domain name from an IP it will be allowed.<br />
<br />
The file also has the public primary root DNS declared for default.<br />
<br />
Now we'll see how does the option section has to look, in which the IP 127.0.0.1 and the local IP assigned to the server (10.9.8.50) will listen to port 53, the directory /var/named will be set as the file zone directory, the server will allow requests from localhost and the LAN, and will allow reverse requests:</div>
<br />
<br />
<br />
<center>
<textarea cols="60" rows="6">options {
listen-on port 53 { 127.0.0.1;10.9.8.50 };
directory "/var/named";
allow-query { localhost;10.9.8.0/24 };
recursion yes;
}; </textarea></center>
<br />
<div style="text-align: left;">
<br />
For our own zone using as an example that we want to add the domain rukia.com and that our zone file name is named.rukia, we add the zone like this:</div>
<br />
<br />
<br />
<center>
<textarea cols="70" rows="5">zone "rukia.com" {
type master; //type of DNS
file "named.rukia"; //name of the file zone for rukia.com
};</textarea></center>
<br />
<div style="text-align: left;">
<br />
Now we add the reverse zone file. The reverse zone file is to resolve the domain name from an IP. For the example we'll add the reverse zone of the network 10.9.8.0, which is the network where our example IPs belong (10.9.8.1 and 10.9.8.50) and the name of our reverse zone file is named.rukiaRev:</div>
<br />
<br />
<br />
<center>
<textarea cols="40" rows="5">zone "8.9.10.in-addr.arpa" {
type master;
file "named.rukiaRev";
};</textarea></center>
<br />
<div style="text-align: left;">
<br />
Note that the network address is written backwards, our network is 10.9.8.0, so it was written 8.9.10.<br />
The names for the zone files can be any name we want.<br />
At the end the named.conf file must be like this:</div>
<br />
<br />
<br />
<center>
<textarea cols="80" rows="45">options {
listen-on port 53 { 127.0.0.1;10.9.8.50 };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost;10.9.8.0/24 };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "rukia.com" {
type master;
file "named.rukia";
};
zone "8.9.10.in-addr.arpa" {
type master;
file "named.rukiaRev";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; </textarea></center>
<br />
<div style="text-align: left;">
<br />
Now let's write our zone file for rukia.com (/var/named/named.rukia),
we'll also add in it the name goku.rukia.com for the client 10.9.8.1 and
also that if we search for the name www.rukia.com it will give us the
IP 10.9.8.50.<br />
So the file must look like this:</div>
<br />
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
0 ; serial
120 ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 10.9.8.50
www CNAME rukia.com.
goku A 10.9.8.1</textarea></center>
<br />
<div style="text-align: left;">
<br />
I'll explain the file line by line (from line 0 to 10, without counting spaces)<br />
<br />
0
- The TTL is set, the TTL is the Time To Live that the consults to the
cache will persist instead of consulting the server, this means that if a
domain has already been consulted, and another consult is done inside
the TTL time, the consult will be made to the cache, but if this time
has expired the consult will be made to the server. In the example I put
120 seconds, thinking in critic situations where the domain name has to
be updated instantly. The default time is 6054800 seconds.<br />
<br />
1
- The SOA is set and the email account of the domain administrator. The
email is written like this: rukia.rukia.com, the @ is changed for a
period, but the real email is rukia@rukia.com.<br />
<br />
2 to 6 - The SOA parameters.<br />
<br />
7
- The NameServer is set for the domain, in this case is the same server
(rukia.com). The @ makes reference to the domain name to which the zone
belongs, in this case is rukia.com. This means that for this zone
@=rukia.com.<br />
<br />
8 - The rukia.com domain is pointed to the IP 10.9.8.50.<br />
<br />
9
- The canonical name www.rukia.com is set. This means that if rukia.com
or www.rukia.com is resolved the answer will always be 10.9.8.50.<br />
<br />
10 - The domain name goku.rukia.com is set to the IP 10.9.8.1.<br />
<br />
Now let's create the reverse zone file for our network (/var/named/named.rukiaRev):</div>
<br />
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
0 ; serial
120 ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS rukia.com.
50 PTR rukia.com.
1 PTR goku.rukia.com.</textarea></center>
<br />
<div style="text-align: left;">
<br />
Again I'll explain the file line by line (0 to 9, without counting spaces)<br />
<br />
0 - TTL.<br />
<br />
1 - The SOA and the administrator email is set.<br />
<br />
2 to 6 - SOA parameters.<br />
<br />
7 - The NameServer is set, in this case is the same server.<br />
<br />
8
- The IP 10.9.8.50 is pointed to the domain rukia.com. Note that is
only written the host address from theIP. The network address is
10.9.8.0, so the host address is 0.0.0.50.<br />
<br />
9 - The IP 10.9.8.1 is pointed to the domain goku.rukia.com.<br />
<br />
To start the service we execute this command:</div>
<br />
<br />
<br />
<center>
<textarea cols="40">/etc/init.d/named start</textarea></center>
<br />
<div style="text-align: left;">
<br />
And ready we have a simple local DNS.<br />
<br />
<br />
<br />
<b>Configuration of the DNS for the clients</b><br />
<br />
To set the DNS in the clients we just have to add the DNS IP to our network configuration. I'll explain how to do it with the console, in graphic mode is with the network manager in the manual configuration section for IPv4.<br />
<br />
In console we just have to edit the file:</div>
<br />
<br />
<br />
<center>
<textarea>/etc/resolv.conf</textarea></center>
<br />
<div style="text-align: left;">
<br />
In it we add the next line where we set that our DNS is the server with the IP 10.9.8.50:</div>
<br />
<br />
<center>
<textarea>nameserver 10.9.8.50</textarea></center>
<br />
<div style="text-align: left;">
<br />
With this our clients can now make requests to our server.<br />
<br />
<br />
<br />
<b>How to check the domain names resolution</b><br />
<br />
We can use the commands nslookup and dig, the difference is that dig sends a bit more information.<br />
<br />
Check with nslookup:</div>
<br />
<br />
<br />
<center>
<textarea>nslookup rukia.com</textarea></center>
<br />
<div style="text-align: left;">
<br />
Check with dig:</div>
<br />
<br />
<br />
<center>
<textarea>dig rukia.com</textarea></center>
<br />
<div style="text-align: left;">
<br />
And well that is like you can configure a DNS for a LAN really simple and quick.<br />
<br />
Any doubt comment please.</div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-7223794698728497872012-07-13T18:30:00.000-05:002012-08-09T17:32:24.173-05:00Instalar un DNS local en Linux con BindHola hoy voy a escribir sobre como montar un servidor DNS rápido y básico en una red local.<br />
<br />
Primero veremos los tipos que existen de DNS y los registros DNS.<br />
<br />
<b>Tipos de DNS</b><br />
<br />
<b>Master (Maestro o Primario):</b> Aloja los registros autoritarios de una zona, responde las peticiones de resolución de nombres como servidor de autoridad y delega copias a los servidores<b> </b>esclavo.<b> </b><br />
<br />
<b>Slave (Esclavo o Secundario):</b> Responde a las peticiones de resolución de nombres como servidor de autoridad, pero la información es distribuida por los servidores primarios. <br />
<br />
<b>Cachingonly (Sólo de cache):</b> Responde a las peticiones de resolución de nombres pero no es servidor de autoridad, las respuestas las guarda en memoria por un período determinado. <br />
<br />
<b>Forwarding (de reenvío):</b> Reenvía las peticiones a una lista de servidores de nombres.<br />
<br />
<br />
<br />
<b>Registros DNS</b><br />
<br />
<b>A (Address):</b> Define una dirección IP y el nombre asignado al host. <br />
<br />
<b>AAAA:</b> Son el reemplazo de los registros A cuando la traducción que se lleva acabo es de nombre a dirección IPv6.<br />
<br />
<b>MX (Mail eXchanger):</b> Se usa para identificar servidores de correo.<br />
<br />
<b>CNAME (Canonical Name):</b> Es un alias que se asigna a un host que tiene una dirección IP valida y que responde a diversos nombres. Pueden declararse varios para un host. <br />
<br />
<b>NS (Name Server):</b> Define los servidores de nombre principales de un dominio. Debe haber al menos uno.<br />
<br />
<b>SOA (Start Of Authority):</b> Este es el primer registro de la zona y sólo puede haber uno en cada archivo de la zona y sólo está presente si el servidor es autoritario del dominio. Especifica el servidor DNS primario del dominio, la cuenta de correo del administrador y tiempos de refresco.<br />
<br />
<b>PTR (Domain Name Pointer):</b> Indica a que dirección IP corresponde un nombre.<br />
<br />
<br />
<br />
<b>Parámetros del registro SOA</b><br />
<br />
<b>Serial:</b> El número serial se utiliza para sincronizar las zonas entre los DNS primarios y secundarios. Si el DNS secundario al consultar el primario encuentra que el número serial es mayor al que tiene actualmente quiere decir que se ha actualizado el archivo de zona, por lo que solicitará una copia de la versión actualizada. <br />
<br />
<b>Refresh:</b> Es el tiempo que un DNS secundario debe esperar para comprobar nuevamente los valores de registro de un DNS primario.<br />
<br />
<b>Retry:</b> Es el tiempo que un DNS secundario debe esperar después de un intento fallido en recuperar datos de un DNS primario.<br />
<br />
<b>Expire:</b> Es el tiempo que durarán los datos en un DNS secundario antes de que expiren.<br />
<br />
<b>Negative Cache TTL:</b> Es el tiempo que el caché del DNS recordará las consultas negativas (NXDOMAIN)<br />
<br />
Bueno ya que vimos algo de teoría empezemos con la instalación y configuración para distribuciones Ubuntu y Fedora.<br />
<br />
<br />
<br />
<b>Instalación y configuración para Ubuntu y similares</b><br />
<br />
Versiones en el ejemplo: Ubuntu 10.04, Bind 9.7.0-P1<br />
Si las versiones son distintas a estas puede haber algunas variaciones, pero siempre y cuando sea un Bind 9 no debe haber problema.<br />
<br />
Instalación:<br />
<br />
<br />
<br />
<br />
<center>
<textarea>apt-get install bind9</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Ahora hay que ir a la carpeta /etc/bind ahí encontraremos nuestros archivos de configuración.<br />
<br />
Bueno, para el ejemplo utilizaremos el dominio rukia.com, que será también nuestro DNS, en el ejemplo el servidor tiene la IP 10.9.8.50 (rukia.com) y nuestro cliente de ejemplo es la IP 10.9.8.1 a la cual le pondremos de nombre de dominio goku.rukia.com.<br />
<br />
El primer archivo a editar es donde se declaran las zonas:</div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="40">/etc/bind/named.conf.default-zones</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
El archivo por default tiene el siguiente contenido:<br />
<br /></div>
<br />
<br />
<center>
<textarea cols="40" rows="25">zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
}; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
En este contenido se declaran las siguientes zonas: los DNS raíz principales públicos, localhost, inversa de localhost, broadcast e inversa de broadcast<br />
<br />
Para nuestra propia zona utilizando de ejemplo que queremos agregar el dominio rukia.com y que el nombre de arhivo de zona es db.rukia, agregamos la zona de la siguiente forma:<br />
<br /></div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="90" rows="5">zone "rukia.com" {
type master; //tipo de DNS
file "/etc/bind/db.rukia"; //ubicación del archivo de zona para rukia.com
}; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Ahora agregamos el archivo de zona inversa. La zona inversa es para resolver a partir de una IP para que devuelva el nombre de dominio. Para el ejemplo agregamos la zona inversa de la red 10.9.8.0, que es la red a la cual pertenecen nuestras IP de ejemplo (10.9.8.1 y 10.9.8.50) y de nombre para el archivo de zona inversa como db.rukiaRev:</div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="40" rows="5">zone "8.9.10.in-addr.arpa" {
type master;
file "/etc/bind/db.rukiaRev";
}; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Noten que la dirección de red se escribe al revés, nuestra red es 10.9.8.0, así que se escribió 8.9.10. <br />
Los nombres para los archivo de zona pueden ser los que queramos. <br />
Al final el archivo named.conf.default-zones debe quedar de la siguiente forma:<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea cols="40" rows="35">zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "rukia.com" {
type master;
file "/etc/bind/db.rukia";
};
zone "8.9.10.in-addr.arpa" {
type master;
file "/etc/bind/db.rukiaRev";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
}; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Antes de seguir con las zonas revisemos que el archivo named.conf incluya al archivo named.conf.default-zones, para esto sólo hay que leer el siguiente archivo para ver que incluya lo que necesitamos:<br />
<br /></div>
<br />
<br />
<br />
<br />
<center>
<textarea>/etc/bind/named.conf</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
El archivo debe contener lo siguiente:<br />
<br /></div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="50" rows="4">include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones"; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Ahora hagamos nuestro archivo de zona para rukia.com (/etc/bind/db.rukia), en el también agregaremos el nombre goku.rukia.com para el cliente 10.9.8.1 y también que si buscamos el nombre www.rukia.com pueda responder a la IP 10.9.8.50.<br />
Entonces el archivo debe verse así:<br />
<br /></div>
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
2 ; Serial
120 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS rukia.com.
@ IN A 10.9.8.50
www IN CNAME rukia.com.
goku IN A 10.9.8.1 </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Explicaré el archivo por líneas (de la 0 hasta la 10, sin contar espacios)<br />
<br />
0 - Se establece el tiempo del TTL, el TTL es el tiempo de vida que durarán las consultas a caché en lugar del servidor , esto quiere decir que si ya se hizo una consulta a un dominio, y se hace otra consulta dentro del tiempo de TTL, la consulta se realizará al caché, de lo contrario si ya expiró el tiempo se hará nuevamente al servidor. En el ejemplo puse solamente 120 segundos, pensando en situaciones critícas en que se necesita actualizar un nombre de dominio y el cambio debe verse al instante. El tiempo de default es 604800 segundos.<br />
<br />
1 - Se establece el SOA y la cuenta de correo del administrador del dominio. El correo se escribió de esta forma: rukia.rukia.com, se sustituye el @ por un punto, en realidad el correo es rukia@rukia.com.<br />
<br />
2 al 6 - Parámetros del SOA.<br />
<br />
7 - Se establece el NameServer para el dominio, en este caso es el mismo servidor (rukia.com). La @ hace referencia al nombre de dominio al que pertenece la zona, en este caso es rukia.com. Esto quiere decir que para esta zona @=rukia.com.<br />
<br />
8 - Se apunta el dominio rukia.com a la IP 10.9.8.50.<br />
<br />
9 - Se establece el nombre canonico www rukia.com. Esto quiere decir que si se resuelve rukia.com o www.rukia.com la respuesta siempre será 10.9.8.50.<br />
<br />
10 - Se le establece el nombre de dominio goku.rukia.com a la IP 10.9.8.1.<br />
<br />
Ahora vamos a crear el archivo de zona inversa para nuestra red (/etc/bind/db.rukiaRev):<br />
<br /></div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
1 ; Serial
120 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS rukia.com.
50 IN PTR rukia.com.
1 IN PTR goku.rukia.com. </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Nuevamente explicaré el archivo por líneas (0 a 9, sin contar espacios)<br />
<br />
0 - TTL.<br />
<br />
1 - Establece SOA y cuenta de correo del administrador .<br />
<br />
2 al 6 - Parámetros del SOA.<br />
<br />
7 - Se establece el NameServer, en este caso es el mismo servidor.<br />
<br />
8 - Se apunta la IP 10.9.8.50 al dominio rukia.com. Noten que sólo se escribe la dirección de host de la IP. La dirección de red es 10.9.8.0, así que la de host es 0.0.0.50.<br />
<br />
9 - se apunta la IP 10.9.8.1 al dominio goku.rukia.com.<br />
<br />
Ahora sólo falta el archivo named.conf.options, pero para Ubuntu no se necesita editar, sólo en caso de presentar problemas en la resolución inversa o que se muestre un error que diga que el DNS rechaza las conexiones al momento de intentar resolver los nombres de dominio desde un cliente, verifiquen que se agreguen las siguientes opciones al archivo /etc/bind/named.conf.options para evitar esos errores:<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea cols="40" rows="5">options {
allow-query { any; };
recursion yes;
}; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Para iniciar el servicio ejecutamos el siguiente comando:<br />
<br />
<br />
<br />
<br />
<center>
<textarea cols="40">/etc/init.d/bind9 start</textarea></center>
</div>
<div style="text-align: left;">
Y listo ya tenemos un DNS rápido y funcional para nuestra LAN.<br />
<br />
<br />
<br />
<b>Instalación y configuración para Fedora y similares</b><br />
<br />
Versiones en el ejemplo: Fedora 16 Security Spin, Bind 9.8.3-P1-RedHat-9.8.3-2.P1.fc16<br />
Si las
versiones son distintas a estas puede haber algunas variaciones, pero
siempre y cuando sea un Bind 9 no debe haber problema.<br />
<br />
<br />
Instalación:</div>
<br />
<br />
<br />
<center>
<textarea>yum install bind</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
<div style="text-align: left;">
Bueno,
para el ejemplo utilizaremos el dominio rukia.com, que será también
nuestro DNS, en el ejemplo el servidor tiene la IP 10.9.8.50 (rukia.com)
y nuestro cliente de ejemplo es la IP 10.9.8.1 a la cual le pondremos
de nombre de dominio goku.rukia.com.<br />
<br />
El primer archivo a editar es el archivo named.conf:<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea>/etc/named.conf</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
</div>
En este archivo se declarán las opciones para nuestro DNS y las zonas, por default el archivo ya contiene lo siguiente:<br />
<br /></div>
<br />
<br />
<center>
<textarea cols="80" rows="35">options {
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
En este archivo, las opciones que nos interesan editar son:<br />
<br />
<b>listen-on-port 53 { 127.0.0.1; };</b> - Aquí se establece que el servidor estará escuchando en el puerto 53 para la IP del localhost. Aquí hay que agregar la IP local de nuestro equipo para que pueda atender peticiones de los clientes en la LAN, en este caso agregaremos la IP del ejemplo que es 10.9.8.50.<br />
<br />
<b>directory "/var/named";</b> - Se establece el directorio donde se van a encontrar los archivos de zona, puede ser otro directorio siempre y cuando el servicio named tenga permisos para leer. Para el ejemplo dejaremos este directorio default.<br />
<br />
<b>allow-query { localhost; };</b> - Se establece a quienes se les va a permitir hacer consultas nuestro DNS, por default sólo se le permite a localhost como se puede observar. Para el ejemplo sólo permitiremos a localhost y nuestra red local, por lo que agregaremos 10.9.8.0/24. Si queremos que cualquier cliente haga consultas a nuestro DNS sólo agregamos la palabra any en lugar de localhost o una dirección de red.<br />
<br />
<b>recursion yes;</b> - Permitir la consulta inversa. Quiere decir que si hacemos una consulta para obtener el nombre de dominio a través de una IP sea permitido.<br />
<br />
También viene ya declarado por default los DNS raíz principales públicos.<br />
<br />
A continuación se ve como debe quedar nuestra sección de opciones, en la que además de escuchar el puerto 53 en la IP 127.0.0.1, también lo hará en la IP local asignada al servidor (10.9.8.50), se establecerá el directorio /var/named como el directorio de archivos de zona, que tambíen permitirá consultas a localhost y la red de la LAN y permitirá consultas inversas:<br />
<br />
<br />
<br />
<br />
<center>
<textarea cols="60" rows="6">options {
listen-on port 53 { 127.0.0.1;10.9.8.50 };
directory "/var/named";
allow-query { localhost;10.9.8.0/24 };
recursion yes;
};
</textarea></center>
</div>
<div style="text-align: left;">
Para nuestra propia zona utilizando de ejemplo que queremos agregar el
dominio rukia.com y que el nombre de arhivo de zona es named.rukia,
agregamos la zona de la siguiente forma: <br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea cols="70" rows="5">zone "rukia.com" {
type master; //tipo de DNS
file "named.rukia"; //nombre del archivo de zona para rukia.com
}; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Ahora agregamos el archivo de zona inversa. La zona inversa es para
resolver a partir de una IP para que devuelva el nombre de dominio. Para
el ejemplo agregamos la zona inversa de la red 10.9.8.0, que es la red a
la cual pertenecen nuestras IP de ejemplo (10.9.8.1 y 10.9.8.50) y de
nombre para el archivo de zona inversa como named.rukiaRev:</div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="40" rows="5">zone "8.9.10.in-addr.arpa" {
type master;
file "named.rukiaRev";
}; </textarea></center>
<center>
</center>
<center>
</center>
<br />
<div style="text-align: left;">
Noten que la dirección de red se escribe al revés, nuestra red es 10.9.8.0, así que se escribió 8.9.10. <br />
Los nombres para los archivo de zona pueden ser los que queramos. <br />
Al final el archivo named.conf debe quedar de la siguiente forma:<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea cols="80" rows="45">options {
listen-on port 53 { 127.0.0.1;10.9.8.50 };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost;10.9.8.0/24 };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "rukia.com" {
type master;
file "named.rukia";
};
zone "8.9.10.in-addr.arpa" {
type master;
file "named.rukiaRev";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Ahora hagamos nuestro archivo de zona
para rukia.com (/var/named/named.rukia), en el también agregaremos el nombre
goku.rukia.com para el cliente 10.9.8.1 y también que si buscamos el
nombre www.rukia.com pueda responder a la IP 10.9.8.50.<br />
Entonces el archivo debe verse así:<br />
<br /></div>
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
0 ; serial
120 ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 10.9.8.50
www CNAME rukia.com.
goku A 10.9.8.1</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Explicaré el archivo por líneas (de la 0 hasta la 10, sin contar espacios)<br />
<br />
0
- Se establece el tiempo del TTL, el TTL es el tiempo de vida que
durarán las consultas a caché en lugar del servidor , esto quiere decir
que si ya se hizo una consulta a un dominio, y se hace otra consulta
dentro del tiempo de TTL, la consulta se realizará al caché, de lo
contrario si ya expiró el tiempo se hará nuevamente al servidor. En el
ejemplo puse solamente 120 segundos, pensando en situaciones critícas en
que se necesita actualizar un nombre de dominio y el cambio debe verse
al instante. El tiempo de default es 604800 segundos.<br />
<br />
1 - Se
establece el SOA y la cuenta de correo del administrador del dominio. El
correo se escribió de esta forma: rukia.rukia.com, se sustituye el @
por un punto, en realidad el correo es rukia@rukia.com.<br />
<br />
2 al 6 - Parámetros del SOA.<br />
<br />
7
- Se establece el NameServer para el dominio, en este caso es el mismo
servidor (rukia.com). La @ hace referencia al nombre de dominio al que
pertenece la zona, en este caso es rukia.com. Esto quiere decir que para
esta zona @=rukia.com.<br />
<br />
8 - Se apunta el dominio rukia.com a la IP 10.9.8.50.<br />
<br />
9
- Se establece el nombre canonico www rukia.com. Esto quiere decir que
si se resuelve rukia.com o www.rukia.com la respuesta siempre será
10.9.8.50.<br />
<br />
10 - Se le establece el nombre de dominio goku.rukia.com a la IP 10.9.8.1.<br />
<br />
Ahora vamos a crear el archivo de zona inversa para nuestra red (/var/named/named.rukiaRev):<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea cols="60" rows="15">$TTL 120
@ IN SOA rukia.com. rukia.rukia.com. (
0 ; serial
120 ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS rukia.com.
50 PTR rukia.com.
1 PTR goku.rukia.com. </textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Nuevamente explicaré el archivo por líneas (0 a 9, sin contar espacios)<br />
<br />
0 - TTL.<br />
<br />
1 - Establece SOA y cuenta de correo del administrador .<br />
<br />
2 al 6 - Parámetros del SOA.<br />
<br />
7 - Se establece el NameServer, en este caso es el mismo servidor.<br />
<br />
8
- Se apunta la IP 10.9.8.50 al dominio rukia.com. Noten que sólo se
escribe la dirección de host de la IP. La dirección de red es 10.9.8.0,
así que la de host es 0.0.0.50.<br />
<br />
9 - se apunta la IP 10.9.8.1 al dominio goku.rukia.com.<br />
<br />
<br />
Para iniciar el servicio ejecutamos el siguiente comando:</div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="40">/etc/init.d/named start</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Y listo ya tenemos un DNS sencillo para nuestra LAN.<br />
<br />
<br />
<br />
<b>Configuración del DNS en los clientes</b><br />
<br />
Para establecer el DNS en los clientes sólo hay que agregar la IP del servidor de nombres de dominio o DNS a nuestra configuración de red. Voy a explicar como se haría en modo consola, en modo gráfico es con el editor de conexiones de red en configuración manual para IPv4.<br />
<br />
En consola sólo hay que editar el archivo:<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea>/etc/resolv.conf</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
En el agregamos la siguiente línea en donde establecemos que nuestro DNS es el servidor con la IP 10.9.8.50:<br />
<br /></div>
<br />
<br />
<center>
<textarea>nameserver 10.9.8.50</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Ya con esto nuestroa clientes podrán consultar a nuestro DNS.<br />
<br />
<br />
<br />
<b>Como comprobar la resolución de nombres de dominio</b><br />
<br />
Se pueden utilizar los comandos nslookup y dig, la diferencia es que dig nos manda un poco más de información.<br />
<br />
Comprobar con nslookup:</div>
<br />
<br />
<br />
<br />
<center>
<textarea>nslookup rukia.com</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Comprobar con dig:<br />
<br /></div>
<br />
<br />
<br />
<center>
<textarea>dig rukia.com</textarea></center>
<center>
<br /></center>
<br />
<div style="text-align: left;">
Y bueno así es como se puede configurar un DNS para una LAN de forma rápida y sencilla.<br />
<br />
Cualquier duda comenten. Saludos!</div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com4tag:blogger.com,1999:blog-2401974794251107096.post-28914559320042850552012-07-09T13:06:00.000-05:002012-08-02T17:00:24.294-05:00Synchronize network directories with LinuxToday I'll write about how to have a network synchronized folder using SSHFS.<br />
<br />
SSHFS is a filesystem that is mounted as a client of a remote folder. It uses the SFTP protocol.<br />
With SSHFS if you make a change in a file it will be reflected immediately in the other computer. If we edit a file in the client that has mounted the remote folder, the change will be reflected in the remote computer and the same if we do it the other way.<br />
<br />
You only need to install SSHFS in the client, you don't need it in the server, the only service you need at the server is the SSH service installed and running.<br />
<br />
<b>Installation</b><br />
<br />
For Fedora and similars:<br />
<br />
<br />
<br />
<center>
<textarea>yum install sshfs</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
For Ubuntu and similars:<br />
<br /></div>
<br />
<br />
<center>
<textarea>apt-get install sshfs</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
<br />
<b>Configuration</b><br />
<br />
The first thing we have to do is choose the folder we want to synchronize, so the computer where that folder is would be the server. <br />
In the example I'll use the directory /home/rukia/foo in which the owner and group is rukia.<br />
<br />
In the client we create a folder. In the example I'll use the directory /home/goku/fooG in which the owner and group is goku and the UID and GID is 1000. I put a different name to the folder to avoid confussions but it can have the same name.<br />
<br />
Let's create the folder /home/goku/fooG:<br />
<br /></div>
<br />
<br />
<center>
<textarea>mkdir /home/goku/fooG</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Now we mount the remote folder in fooG.<br />
Before doing this I'll explain an option that we can apply to the SSHFS command. <br />
With this option we established if we want the directory and files of the client to have the same owner of the folder at the server or if we want that each folder has it's own owner and group.<br />
<br />
<br />
<br />
<b>User and group options for SSHFS</b><br />
<br />
The option for establishing the user and group is idmap=Type<br />
<br />
Where type can be:<br />
<br />
none: The UID and GID won't be changed, SSHFS will use the owner and group of the remote directory (default option).<br />
user: It only changes the server UID for the client UID at the client.<br />
file: Takes the UID and GID written at a file (I still don't know how is the format of this file).<br />
<br />
For our examples will use the user type but we will also specify the GID.<br />
<br />
Mount the remote directory establishing the UID an GID of the client:</div>
<br />
<br />
<br />
<center>
<textarea cols="90">sshfs -o idmap=user -o gid=1000 rukia@servidor.com:/home/rukia/foo /home/goku/fooG</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
And now we have a synchronized folder. If we make a ls in the client directory we'll see that the owner and group is our user, while in the server it still has it's own user and group.<br />
And the best part is that if rukia or goku write, the permissions won't change, in the client goku will still be the owner and in the server will still be rukia.<br />
<br />
But if we had chosen none in the idmap option then the owner and group for both parts will be the owner and group of the server. But even though the client can still write in the directory and the permissions won't change.<br />
<br />
<br />
<b>How to synchronized the folder at startup</b><br />
<br />
Now we just have to make our folder available from the startup, fot this we add the next line at /etc/rc.local on top of exit 0:</div>
<br />
<br />
<br />
<center>
<textarea cols="100">su goku -c 'sshfs -o idmap=user -o gid=1000 rukia@servidor.com:/home/rukia/foo /home/goku/fooG'</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
<br />
<br />
<b>Mount the directory without a password</b><br />
<br />
If we want the before explanation to work and our directory can be mounted at system boot, we have to avoid the remote computer to ask for a SSH password. We can solve this creating public keys.<br />
<br />
We create the key for the client user:</div>
<br />
<br />
<br />
<center>
<textarea>ssh-keygen -t rsa</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
For default the key is savedd in the .ssh home directory of the user that generated it, in our example is goku, so the key is:</div>
<br />
<br />
<br />
<center>
<textarea cols="40">/home/goku/.ssh/id_rsa.pub</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Now we have to copy this key to the server, we can do it with scp, the key has to be inside the file authorized_keys that is in the .ssh home directory of the ssh user that we'll use to log in, in this case is rukia. So we have to apply the next commands:<br />
<br />
Copy the key to the server:<br />
<br /></div>
<br />
<br />
<center>
<textarea cols="60">scp /home/goku/.ssh/id_rsa.pub rukia@servidor.com:/home/rukia</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Add it to the authorized_keys file (this is done in the server side):<br />
<br /></div>
<br />
<br />
<center>
<textarea cols="60">cat /home/rukia/id_rsa.pub >> /home/rukia/.ssh/authorized_keys</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
And finally for security reasons we just give permissions to the owner of the file:</div>
<br />
<br />
<center>
<textarea cols="40">chmod 700 /home/rukia/.ssh/authorized_keys</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
And we have our synchronized folder. This can be done in more computers not just with one, you can have more clients using the same folder applying all this steps.<br />
I hope this tutorial is useful, any doubt or complaint just comment.</div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-6293022436850110082012-07-06T20:06:00.000-05:002012-08-08T13:59:47.410-05:00Sincronizar carpetas en red con LinuxHola hoy escribiré sobre como tener una carpeta sincronizada en red utilizando SSHFS.<br />
<br />
SSHFS es un sistema de archivos que se monta como cliente de un directorio remoto. Utiliza el protocolo SFTP.<br />
Con SSHFS el cambio que se realice en un archivo se reflejará inmediatamente en el otro sitio. Si editamos un archivo en el cliente que tiene montada la carpeta remota se reflejará al momento el cambio en la ubicación remota y lo mismo pasa si hacemos esto en viceversa.<br />
<br />
La instalación, esta sólo se realiza en el equipo cliente, no se necesita en el equipo servidor, lo único que debe tener el equipo servidor es el servicio de SSH instalado y corriendo.<br />
<br />
<b>Instalación</b> <br />
<br />
Para Fedora y similares:<br />
<br />
<br />
<center>
<textarea>yum install sshfs</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Para Ubuntu y similares:</div>
<br />
<br />
<center>
<textarea>apt-get install ssh</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<b>Configuración </b><br />
<br />
Lo primero que hay que hacer es elegir el directorio que queremos sincronizar, este será entonces el equipo servidor. Debemos darle los permisos necesarios.</div>
<div style="text-align: left;">
En el ejemplo utilizaré el directorio /home/rukia/foo del cual es dueño rukia y pertenece al grupo rukia.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
En el equipo cliente creamos una carpeta en un directorio en el cual podemos escribir. En el ejemplo utilizaré el directorio /home/goku/fooG del cual es dueño goku y pertenece al grupo goku y su UID y GID es 1000. Le puse un nombre distinto al directorio para diferenciarlos pero se le puede poner el mismo también, no hay ningún problema.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Creamos la carpeta /home/goku/fooG:</div>
<br />
<br />
<br />
<center>
<textarea>mkdir /home/goku/fooG</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Ahora montamos la carpeta remota en fooG.</div>
<div style="text-align: left;">
Antes de hacerlo les explicaré unas opciones que se pueden aplicar al comando SSHFS. Con está opción establecemos si queremos que el directorio y archivos del cliente tenga el mismo dueño que en el servidor o si queremos que cada carpeta tenga su propio dueño y grupo.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br />
<b>Opciones de usuario y grupo para SSHFS</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
La opción para establecer usuario y grupo es idmap=Tipo</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Donde tipo puede ser:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
none: No se cambiará el UID y GID, se utilizarán los del dueño del directorio en el servidor (es la opción de default)</div>
<div style="text-align: left;">
user: Sólo se cambia el UID del servidor por el del cliente.</div>
<div style="text-align: left;">
file: Toma el UID Y GID de un archivo donde se establecen. (Aún no se como hacer este archivo).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Para nuestros ejemplos utilizaremos el tipo user pero ademas le vamos a especificar el GID.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Montar el directorio remoto estableciendo el UID y GID del cliente:</div>
<br />
<br />
<br />
<center>
<textarea cols="80">sshfs -o idmap=user -o gid=1000 rukia@servidor.com:/home/rukia/foo /home/goku/fooG</textarea></center>
<br />
<br />
Y listo ya tenemos una carpeta sincronizada. Si damos un ls en el directorio cliente veremos que el dueño y grupo es nuestro usuario, mientras que en el servidor sigue siendo el usuario y grupo establecidos en el.<br />
Y lo mejor es que si rukia o goku escriben, los permisos no cambian, en el cliente goku seguirá siendo el dueño y en el servidor lo seguirá siendo rukia.<br />
<br />
Pero si hubieramos elegido none en idmap entonces el dueño y grupo sería el del servidor para ambas partes. Pero aún así el cliente puede escribir en el directorio y los permisos no cambian.<br />
<br />
<br />
<b>Tener la carpeta sincronizada al iniciar el sistema</b><br />
<br />
Ahora sólo falta que nuestra carpeta se encuentre montada al iniciar el sistema, para eso agregamos la siguiente línea a /etc/rc.local arriba de exit 0<br />
<br />
<br />
<br />
<center>
<textarea cols="100">su goku -c 'sshfs -o idmap=user -o gid=1000 rukia@servidor.com:/home/rukia/foo /home/goku/fooG'</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
<br />
<b>Montar el directorio sin que pida contraseña</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Para que funcione lo anterior y nuestro directorio se encuentre montado al iniciar el sistema hay que evitar que pregunte por contraseña. Esto se soluciona creando unas llaves publicas.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Creamos la llave para el usuario cliente:</div>
<br />
<br />
<br />
<center>
<textarea>ssh-keygen -t rsa</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Por default la llave se guarda en el directorio .ssh del home del usuario que la generó, en nuestro ejemplo es goku asi que la llave sería:</div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="40">/home/goku/.ssh/id_rsa.pub</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Ahora hay que copiar esta llave al servidor, lo podemos hacer con scp, la llave debe ir en el archivo authorized_keys que se encuentra en .ssh en el home del usuario ssh con el que nos loguearemos, en este caso es rukia. Así que debemos aplicar los siguientes comandos:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Copiar la llave al servidor:</div>
<br />
<br />
<br />
<center>
<textarea cols="60">scp /home/goku/.ssh/id_rsa.pub rukia@servidor.com:/home/rukia</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Agregarla al archivo authorized_keys (esto se hace del lado del servidor):</div>
<br />
<br />
<br />
<br />
<center>
<textarea cols="60">cat /home/rukia/id_rsa.pub >> /home/rukia/.ssh/authorized_keys</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Y finalmente por seguridad le damos sólo permisos al dueño del archivo:</div>
<div style="text-align: left;">
<br /></div>
<br />
<br />
<br />
<center>
<textarea cols="40">chmod 700 /home/rukia/.ssh/authorized_keys</textarea></center>
<center>
</center>
<br />
<div style="text-align: left;">
Y listo tenemos una carpeta sincronizada. Esto se puede hacer en varios equipos no sólo con uno, pueden tener más clientes utilizando la carpeta compartida aplicando todos estos pasos.</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
Espero les sirva este tutorial, cualquier cosa comenten. Saludos! </div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-46746003651986321602012-07-03T16:36:00.000-05:002012-07-03T16:36:17.890-05:00Unix permissions: The sticky, SUID and SGID bitsHello, today I'll write about more permissions, this time it will be about the Sticky, SUID and SGID bits.<br />
I'll write about them because one of my readers told me that it would be a good idea to write about these bits.<br />
<br />
<b>Sticky bit</b><br />
<br />
What the sticky bit does is that when you execute an application it will be residing in the memory, so if other user (thinking in a multiuser environment) executes that same application it will run faster because it's already active in memory.<br />
So this permission fastens the executions if multiple users are using the same application.<br />
<br />
<b>SUID bit</b><br />
<br />
If we apply the SUID bit to an application, it will run with the UID of the owner even if you are logged in as another user. For example if all the users need to execute fdisk without using sudo or escalate to root we just have to apply this bit to fdisk.<br />
<br />
<b>SGID bit</b><br />
<br />
The same as SUID but it applies to the group owner of the application.<br />
<br />
<br />
<b>The SUID bit to execute bash scripts as root</b><br />
<br />
Even if we can apply SGID to execute applications with a different user as the one we are logged in, there are things we can't do even if the owner of the script is root.<br />
<br />
First of all, for a script to execute as root we have to apply the SUID bit to the shell we use to execute scripts, because the application in this case is the shell, the script is just a file that will be interpreted by the shell.<br />
<br />
Special commandas like adduser can't be executed by any other user even if it has the SUID bit of root. So it won't work a script that executes the adduser command even if the shell has the SUID bit. If you don't believe me tray it ;) I even set the SUID bit for root to my shell, to adduser, to my script that executes adduser and the system didn't permit it.<br />
<br />
<br />
<b>The SUID bit and GTK+</b><br />
<br />
GTK doesn't support the use of SUID or SGID. So if you try to run a GTK based application with one of these birs the execution will send and alert and it will not start.<br />
<br />
<br />
<b>Then how can we use these bits?</b><br />
<br />
It can be used to create scripts that write files inside directories in which other users don't have permissions. For example, that any user can create a file inside the root home directory.<br />
Or like I said it before, is possible to use some applications with SUID and SGID like fdisk.<br />
<br />
And now you may be asking, well a script to write file in /root, but hadn't you said that to make this work you have to apply the SUID bit to the shell? OK, do this can be risky, to let the shell execute always as root with any user, but there is a trick to make it work without making all your shell root.<br />
<br />
We just have to copy our shell to other directory and in that copy apply the SUID bit so the original shell doesn't have to be executed always by root. Then we point our sh to this shell.<br />
Even though this is not a good practice because it isn't secure to allow scripts to be executed as root, but SGID can make easy a lot of things if the server or computer where it is going to be apply is managed only by the right people or SysAdmins.<br />
<br />
<br />
<b>The commands to apply the SUID bit to a copy of the shell:</b><br />
<br />
First we find where is our shell:<br />
<br />
<br />
<br />
<br />
<center><textarea cols="40">ls -l /bin/sh</textarea></center><center><br /></center><br />
<div style="text-align: left;">
This will show us if we are using dash or bash, now let's find it's real location with the result of the last command, let's use as example that it is bash and let's search as root or with sudo so we don't have errors y our search:<br />
<br />
<br />
<br />
<center><textarea cols="40">find / -name bash</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Now that we know where it is let's copy it to other place, in this example will be to rukia's home from /bin/bash:</div>
</div>
<br />
<br />
<br />
<br />
<center><textarea cols="40">cp /bin/bash /home/rukia</textarea></center><center><br /></center><br />
<div style="text-align: left;">
And finally we just apply SUID or SGID to the shell copy. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br />
<br />
<b>The commands to apply these bits are:</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
SUID:</div>
<br />
<br />
<br />
<center><textarea cols="40">chmod u+s application</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Remove SUID:</div>
<br />
<br />
<br />
<center><textarea cols="40">chmod u-s application</textarea></center>
<center><br /></center><br />
<div style="text-align: left;">
SGID:</div>
<br />
<br />
<center><textarea cols="40">chmod g+s application</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Remove SGID:</div>
<br />
<br />
<br />
<br />
<center><textarea cols="40">chmod g-s application</textarea></center><center><br /></center><br />
<div style="text-align: left;">
</div>
<div style="text-align: left;">
Apply sticky bit:</div>
<br />
<br />
<br />
<center><textarea cols="40">chmod +t application</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Remove sticky bit:</div>
<br />
<br />
<center><textarea cols="40">chmod -t application</textarea></center><center><br /></center><br />
<div style="text-align: left;">
<br />
<br />
<b>How permissions are visualized</b><br />
<br /></div>
<div style="text-align: left;">
How permissions will be visualized for SUID if the owner doesn't have execute permissions for the application, in this example the owner only has reading and writing permissions, group reading permissions, other users reading permissions. Applying SUID:</div>
<br />
<br />
<br />
<br />
<center><textarea>rwS-r---r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualization with SUID if the owner has execute permissions, in this example the owner has reading, writing and execute permissions, group reading permissions, other users reading permissions. Applying SUID:</div>
<br />
<br />
<br />
<br />
<center><textarea>rws-r---r--</textarea></center><center><br /></center><br />
Visualization with SGID if the group doesn't have execute permissions, in this example the owner has reading permissions, group reading and writing permissions, other users reading permissions. Applying SGID:<br />
<br />
<br />
<br />
<br />
<center><textarea>r---rwS-r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualization with SGID if the group has execute permissions, in this example the owner has reading permissions, group reading and execute permissions, other users reading permissions. Applying SGID:</div>
<br />
<br />
<br />
<br />
<br />
<center><textarea>r---rws-r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualization of the sticky bit if other users doesn't have execute permissions, in this example the owner and group have all permissions, other users only reading and writing permissions. Applying sticky bit:</div>
<br />
<br />
<br />
<br />
<center><textarea>rwx-rwx-rwT</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualization of the sticky bit if other users have execute permissions, in this example the owner, group and other users have all permissions. Applying sticky bit:</div>
<br />
<br />
<center><textarea>rwx-rwx-rwt</textarea></center><center><br /></center><br />
<br />
<br />
<div style="text-align: left;">
And that is all I know right now about these bits, hope it helps and if something is wrong please tell me as I'm new to these bits too.
</div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-37165616775261870842012-06-29T19:51:00.002-05:002012-07-02T18:11:21.932-05:00Permisos Unix: Los bits SUID, SGID y stickyHola hoy escribiré sobre más permisos, esta vez será sobre los bits Sticky, SUID y SGID. Hablaré sobre ellos porque un seguidor solicitó que escribiera más sobre permisos, en particular estos.<br />
<br />
<b>Bit Sticky</b><br />
<br />
El bit Sticky lo que hace es que al ejecutar una aplicación esta resida en memoria por lo que si otro usuario (pensando en sistema multiusuario) accede a esa misma aplicación se ejecutará más rápido ya que se encuentra activo en la memoria.<br />
Entonces este permiso sirve para agilizar las ejecuciones en caso de que varios usuarios accedan a la vez a ella.<br />
<br />
<b>Bit SUID</b><br />
<br />
Si aplicamos el bit SUID a una aplicación al correrlo se ejecutará con el UID del dueño del archivo aunque nosotros estemos logueados con un usuario distinto. Así que por ejemplo si necesitamos que todos los usuarios puedan utilizar fdisk sin tener que escalar a root o utilizar sudo sólo debemos aplicar este bit.<br />
<br />
<b>Bit SGID</b><br />
<br />
Lo mismo que SUID pero aplica para el grupo al que pertenece la aplicación.<br />
<br />
<br />
<b>El bit SUID para ejecutar bash scripts como root</b><br />
<br />
A pesar de que al aplicar SGID podemos ejecutar aplicaciones con un usuario diferente al que estamos logueados, hay cosas que de todas formas no podemos hacer aunque sea root el dueño del script.<br />
<br />
Primero que todo para que un script se ejecute como root tendríamos que aplicar el bit SUID al shell que utilizamos para ejecutar los scripts ya que la aplicación en este caso es el shell, el script sólo es un archivo que será interpretado por el shell.<br />
<br />
Comandos especiales como adduser no pueden ser ejecutados por cualquier otro usuario aunque tengan el SUID de root. Por lo tanto tampoco funcionaría un script que mande ejecutar adduser a pesar de que el shell sea SUID. Sino me creen pruebenlo ;) incluso le puse SUID root a mi shell, a adduser, a mi archivo .sh que mandaba ejecutar adduser y no lo permite.<br />
<br />
<br />
<b>El bit SUID y GTK+</b><br />
<br />
GTK no soporta el uso de SUID o SGID. Por lo tanto si se intenta correr una aplicación basada en GTK con alguno de estos bits la ejecución mostrará una alerta y no iniciará.<br />
<br />
<br />
<b>¿Entonces en que se pueden usar estos bits?</b><br />
<br />
Se puede utilizar para crear scripts que escriban archivos sobre directorios en los cuales otros usuarios no tienen permisos. Por ejemplo que cualquier usuario pueda mandar a crear un archivo a la carpeta personal de root.<br />
O como mencioné anteriormente alguna aplicaciones si son posibles de usarse con SUID y SGID como fdisk.<br />
<br />
Y tal vez ahora se preguntan bueno un script para mandar a escribir en /root, ¿Pero qué no habías dicho también que para que esto funcione se tiene que hacer que el shell sea el que tenga el bit SUID? Bueno hacer esto puede ser inseguro, el hacer que el shell siempre se ejecute como root quien quiera que sea el que lo utilice, pero hay un pequeño truco para que funcione sin hacer todo el shell root.<br />
<br />
Sólo hay que copiar nuestro shell a otro directorio y ya en esa copia del shell aplicamos el SUID para que el shell original no sea siempre ejecutado por root. Ya después apuntamos nuestro sh hacia este shell.<br />
De todas formas no es recomendable permitir tanto poder para correr scripts, pero si puede facilitar muchas cosas si el servidor o equipo donde se va a aplicar lo manejan solamente las personas encargadas o SysAdmin y manejan varias cuentas para acceder.<br />
<br />
<br />
<b>Los comandos para darle SUID a una copia del shell:</b><br />
<br />
Primero encontremos donde está nuestro shell:<br />
<br />
<br />
<br />
<center><textarea cols="40">ls -l /bin/sh</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Lo que nos mostrará si estamos utilizando dash o bash, ahora a buscar su verdadera ubicación con la respuesta, utilicemos de ejemplo que nos apareció bash y busquemos como root o sudo para que no aparezcan errores de permiso denegado en la búsqueda:<br />
<br />
<br />
<br />
<center><textarea cols="40">find / -name bash</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Ya que lo tenemos lo copiamos a otro sitio en este ejemplo al home del usuario rukia desde /bin/bash:</div>
</div>
<br />
<br />
<br />
<center><textarea cols="40">cp /bin/bash /home/rukia</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Ahora aplicamos SUID o SGID a la copia de nuestro shell. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br />
<b>Los comandos para aplicar estos bits son:</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
SUID:</div>
<br />
<br />
<center><textarea cols="40">chmod u+s aplicación</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Para quitar SUID:</div>
<br />
<br />
<br />
<center><textarea cols="40">chmod u-s aplicación</textarea></center>
<center><br /></center><br />
<div style="text-align: left;">
SGID:</div>
<br />
<br />
<center><textarea cols="40">chmod g+s aplicación</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Para quitar SGID:</div>
<br />
<br />
<center><textarea cols="40">chmod g-s aplicación</textarea></center><center><br /></center><br />
<div style="text-align: left;">
</div>
<div style="text-align: left;">
Para aplicar el bit sticky:</div>
<br />
<br />
<br />
<center><textarea cols="40">chmod +t aplicación</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Para quitar el bit sticky:</div>
<br />
<br />
<br />
<center><textarea cols="40">chmod -t aplicación</textarea></center><center><br /></center><br />
<div style="text-align: left;">
<br />
<b>Como se ven los permisos</b><br />
<br /></div>
<div style="text-align: left;">
Como se visualizarían los permisos para SUID si el dueño no tiene permisos para ejecutar la aplicación, en el ejemplo el dueño sólo tiene permisos de lectura y escritura, grupo lectura, otros lectura con SUID:</div>
<br />
<br />
<center><textarea>rwS-r---r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualización con SUID si el dueño si tiene permisos para ejecutar, en el ejemplo el dueño puede leer, escribir y ejecutar, grupo leer, otros leer con SUID:</div>
<br />
<br />
<center><textarea>rws-r---r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualización con SGID si el grupo no tiene permisos para ejecutar, en el ejemplo el dueño puede leer, grupo leer y escribir, otros leer con SGID:</div>
<br />
<br />
<br />
<center><textarea>r---rwS-r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Visualización con SGID si el grupo tiene permisos para ejecutar, en el ejemplo el dueño puede leer, grupo leer, escribir y ejecutar, otros leer con SGID:</div>
<br />
<br />
<br />
<center><textarea>r---rws-r--</textarea></center><center><br /></center><br />
<div style="text-align: left;">
El bit sticky se visualiza de la siguiente forma si otros no tienen permisos de ejecución, en el ejemplo el dueño y grupo tiene todos los permisos, otros sólo de lectura y escritura con el bit sticky:</div>
<div style="text-align: left;">
</div>
<br />
<br />
<br />
<center><textarea>rwx-rwx-rwT</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Y el bit sticky se visualiza de esta forma si otros si tienen permisos de ejecución, en el ejemplo el dueño, grupo y otros tienen todos los permisos con el bit sticky:</div>
<br />
<br />
<center><textarea>rwx-rwx-rwt</textarea></center><center><br /></center><br />
<div style="text-align: left;">
Bueno eso sería todo lo que se hasta ahora de estos bits, espero les sea útil, cualquier duda comenten. Saludos!</div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-69831544690881118262012-06-25T13:29:00.000-05:002012-06-27T12:14:39.466-05:00How to install and configure suPHPThis tutorial is about how to install and configure suPHP. I know that they exist more tutorials about this but even though I'll write it because it took me a lot of time for me to make it work, and I want to explain how it finally work for me.<br />
I made this installation and configuration with Fedora 16 and httpd.<br />
<br />
What the suPHP module does is define which user and group will execute the PHP scripts. This is established inside one or more VirtualHost. This means that we can have multiple users for each one of our sites. They can even be executed by root but this is not advisable.<br />
<br />
Now let's see how to install it:<br />
<br />
It can be with yum or in case of Debian based distros with apt-get, but at least with Fedora and other similar distros I recommend to download the suPHP module from the official site. Here is the link: <br />
<br />
Now that we have downloaded the package, we untar it:<br />
<br />
<br />
<br />
<br />
<center><textarea cols="40">tar -xzvf suphp-*.tar.gz</textarea></center><br />
<br />
We get inside the folder that is generated after de untaring and we configure the installation before compiling it:<br />
<br />
<textarea cols="60" rows="3">./configure --with-apxs=/usr/sbin/apxs --with-apr=/usr/bin/apr-1-config --with-apache-user=apache --with-logfile=/var/log/httpd/suphp_log --with-setid-mode=paranoid --sysconfdir=/etc --enable-SUPHP_USE_USERGROUP=yes</textarea><br />
<br />
What do the parameters mean:<br />
<br />
<b>--with-apxs=/usr/sbin/apxs:</b> This establishes where is located apxs (this is where mine is located but it can be different in your distro, so first verify where it is yours). Apxs is an Apache utility that helps in the construction of modules.<br />
<br />
<b>--with-apr=/usr/bin/apr-1-config:</b> This establishes where is located apr-1-config. Apr is the Apache Portable Runtime configuration utility.<br />
<br />
<b>--with-apache-user=apache:</b> This establishes with what user is running actually Apache or httpd. (I wrote Apache, but you may have another user running your service, so first verify it).<br />
<br />
<b>--with-logfile=/var/log/httpd/suphp:</b> This establishes where the logs for suPHP are going to be saved. It can be a different location as long as the user that runs Apache or httpd has writing permissions for that directory.<br />
<br />
<b>--with-setid-mode=paranoid:</b> This establishes with what mode will be executed suPHP. Below you'll see the description of each mode.<br />
<br />
<b>--sysconfdir=/etc:</b> This establishes the directory where suPHP will search for the configuration files. At least it most be readable by the Apache or httpd user.<br />
<br />
<b>--enable-SUPHP_USE_USERGROUP=yes:</b> This enables the use of suPHP_UserGroup directive inside he Apache/httpd configuration. suPHP_UserGroup defines the user and group that will run the PHP scripts of Apache/httpd or just some VirtualHost.<br />
<br />
Modes for executing suPHP:<br />
<br />
Owner: The scripts will be executed with owner as the user and the owner group as the group.<br />
<br />
Force: The scripts will be executed as the user and group established in the Apache/httpd configuration under the suPHP_UserGroup directive even if the owner and group of that script is other user and group. (suPHP doesn't recommend the use of this mode).<br />
<br />
Paranoid: The scripts will be executed as the user and group established in the Apache/httpd configuration under the suPHP_UserGroup directive only if the user and group are the same as the owner and owner group of the script.<br />
<br />
Now let's continue with the installation, now let's compile:<br />
<br />
<br />
<br />
<br />
<center><textarea>make</textarea></center><br />
<br />
If any error appeared we proceed with installation:<br />
<br />
<br />
<br />
<br />
<center><textarea>make install</textarea></center><br />
<br />
Configuration of suPHP in Apache/httpd:<br />
<br />
We have to edit or if it doesn't exist, create the file suphp.conf inside the directory established at the --sysconfdir parameter:<br />
<br />
<textarea cols="90" rows="30">[global]
logfile=/var/log/suphp.log #Location of log
webserver_user=apache #User running Apache/httpd
###Security options
allow_file_group_writeable=true #Allows or denies file writing to group
allow_file_others_writeable=false #Allows or denies file writing to other users
allow_directory_group_writeable=true #Allows or denies directory writing to group
allow_directory_others_writeable=false #Allow or denies directory writing to other users
check_vhost_docroot=true #This option establishes that only scripts under the DOCROOT #established in the Apache/httpd configuration or inside the VirtualHosts
env_path=/bin:/usr/bin #Environment variable path (may also be different for your distro)
umask=077 #The umask that will be applied to establish the default permissions of files #and directories generated by the scripts.
min_uid=0 #The minimum UID to run the scripts.
min_gid=0 #The minimum GID to run the scripts.
####In this case I chose 0 because I needed to run my scripts as root but it is not #advisable, the minimum recommended UID nad GID are 1000, where the non-system users #start.
[handlers]
application/x-httpd-php="php:/usr/bin/php-cgi" #Establishes what application will #interpret the scripts, the php-cgi path goes here. </textarea><br />
<br />
<br />
The next step in configuration:<br />
<br />
<b>For httpd on Fedora or similars:</b><br />
<br />
Edit the file /etc/httpd/conf.d/suphp.conf with this:<br />
<br />
<br />
<textarea cols="45" rows="5">LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php .php
suPHP_AddHandler application/x-httpd-php </textarea><br />
<br />
And the configuration file for httpd in the VirtualHost section has to look like this (using as example the user rukia):<br />
<br />
<br />
<textarea cols="90" rows="5"><VirtualHost *:8080>
suPHP_UserGroup rukia rukia #Establishes the user and group to run the scripts
DocumentRoot /var/www/html #Route where the content to be shown by the web server is stored #(this route can be changed as long as it has the right permissions)
</VirtualHost> </textarea><br />
<br />
<b>For Apache on Ubuntu or similars:</b><br />
<br />
Add the first configuration text from above inside the VirtualHost that will use suPHP.<br />
<br />
So the configuration for a VirtualHost in Apache on Ubuntu to run scripts as rukia will be:<br />
<br />
<textarea cols="70" rows="10">LoadModule suphp_module /usr/lib/apache2/modules/mod_suphp.so
<VirtualHost *:8080>
suPHP_Engine on
AddType application/x-httpd-php .php
suPHP_AddHandler application/x-httpd-php
suPHP_UserGroup rukia rukia
DocumentRoot /var/www/html
</VirtualHost> </textarea><br />
<br />
And with this ends the installation and configuration of suPHP now we just have to restart the Apache/httpd service.<br />
<br />
We can try our configuration for example with a script that creates a file inside our DOCROOT:<br />
<br />
PHP code:<br />
<br />
<textarea cols="40">system("touch prueba.txt"); </textarea><br />
<br />
Any doubt please comment.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-7705194201692133832012-06-22T18:31:00.000-05:002012-06-25T13:16:34.454-05:00Instalación y configuración de suPHPHola hoy voy a hacer este tutorial de como instalar y configurar el módulo suPHP para Apache o httpd.<br />
La instalación la realicé en Fedora 16 con httpd.<br />
Tal vez ya muchos saben como instalarlo pero de todas formas lo escribiré ya que yo nunca antes lo había hecho y si me tomo tiempo para algo tan sencillo que es el lograr que funcionara.<br />
<br />
Lo que el módulo suPHP hace en si es definir que usuario y grupo ejecutará los scripts de PHP. Esto se define dentro de uno o varios VirtualHost. Esto quiere decir que podemos tener distintos usuarios para cada uno de nuestros sitios. Incluso pueden ejecutarse bajo root aunque no es recomendable.<br />
<br />
Ahora como se instala:<br />
<br />
Se puede con yum o en caso de distros basadas en Debian con apt-get, pero al menos en el caso de Fedora y otras distros similares recomiendo que se descargue desde la página oficial (lo digo por experiencia -.-). Aquí está el link: <a href="http://www.suphp.org/Download.html">http://www.suphp.org/Download.html</a><br />
<br />
Entonces ya descargado descomprimimos el paquete con:<br />
<br />
<div style="text-align: center;">
<textarea cols="30">tar -xzvf suphp-*.tar.gz</textarea></div>
<br />
Entramos a la carpeta que se generó tras descomprimir el paquete y configuramos la intalación antes de compilar:<br />
<br />
<textarea cols="60" rows="3">./configure --with-apxs=/usr/sbin/apxs --with-apr=/usr/bin/apr-1-config --with-apache-user=apache --with-logfile=/var/log/httpd/suphp_log --with-setid-mode=paranoid --sysconfdir=/etc --enable-SUPHP_USE_USERGROUP=yes</textarea><br />
<br />
Que son los parámetros establecidos:<br />
<br />
<b>--with-apxs=/usr/sbin/apxs:</b> Establecemos donde se encuentra apxs (esta es mi ubicación pero puede variar según las distros, así que primero verifiquen en donde se encuentra su apxs). Apxs es una utilidad de Apache que ayuda en la construcción de módulos.<br />
<br />
<b>--with-apr=/usr/bin/apr-1-config:</b> Igual que la anterior establecemos donde se encuentra en este caso apr-1-config. Apr es la utilidad de configuración Apache Portable Runtime.<br />
<br />
<b>--with-apache-user=apache:</b> Se establece con que usuario está corriendo Apache o httpd. (Yo escribí Apache porque así está corriendo mi httpd pero revisen cual es el suyo).<br />
<br />
<b>--with-logfile=/var/log/httpd/suphp:</b> Aquí establecemos en donde se van a estar almacenando los logs que genere suPHP. Puede ser una ubicación distinta siempre y cuando el usuario bajo el cual corre Apache o httpd tenga permisos de escritura sobre ese directorio.<br />
<br />
<b>--with-setid-mode=paranoid:</b> Se establece bajo que modo se ejecutará suPHP. Más abajo viene la descripción de los distintos modos.<br />
<br />
<b>--sysconfdir=/etc:</b> El directorio en donde se buscarán los archivos de configuración de suPHP. Al menos debe ser legible para el usuario de Apache o httpd.<br />
<br />
<b>--enable-SUPHP_USE_USERGROUP=yes:</b> Habilitar el uso de suPHP_UserGroup dentro de la configuración de Apache o httpd. suPHP_UserGroup es para establecer el usuario y grupo bajo el cual se ejecutará Apache/httpd o cierto/ciertos VirtualHost.<br />
<br />
Modos para ejecutar suPHP:<br />
<br />
Owner(dueño): Los scripts se ejecutarán con el usuario y grupo del dueño del archivo.<br />
<br />
Force(forzado): Los scripts serán ejecutados con el usuario y grupo establecidos en la configuración de Apache/httpd bajo suPHP_UserGroup sin importar que el dueño del script sea otro usuario o grupo. (suPHP no recomienda utilizar este modo ya que es el más inseguro).<br />
<br />
Paranoid(Paranoico): Los scripts serán ejecutados con el usuario y grupo establecidos en la configuración de Apache/httpd bajo suPHP_UserGroup pero sólo si ese usuario y grupo coinciden con el usuario y grupo del dueño del script.<br />
<br />
Ahora continuemos con la instalación, ya que se configuró pasemos a compilar:<br />
<br />
<div style="text-align: center;">
<textarea>make</textarea></div>
<br />
Si no apareció ningún error podemos pasar a la instalación:<br />
<br />
<div style="text-align: center;">
<textarea>make install</textarea></div>
<br />
<br />
<br />
Configuración de suPHP en Apache/httpd:<br />
<br />
Editamos o sino existe creamos el archivo suphp.conf dentro de /etc (o el directorio que establecieron que almacenaría los archivos de configuración). El archivo debe contener lo siguiente:<br />
<br />
<textarea cols="90" rows="30">[global]
logfile=/var/log/suphp.log #Ubicación del log
webserver_user=apache #Usuario bajo el cual corre Apache/httpd
###Opciones de seguridad
allow_file_group_writeable=true #Permite o niega la escritura de archivos al grupo
allow_file_others_writeable=false #Permite o niega la escritura de archivos a otros usuarios
allow_directory_group_writeable=true #Permite o niega la escritura de directorios al grupo
allow_directory_others_writeable=false #Permite o niega la escritura de directorios a otros
check_vhost_docroot=true #Esta opción establece que sólo se ejecutarán los scripts bajo el #DOCROOT establecido por el o los VirtualHost dentro de la configuración de Apache/httpd
env_path=/bin:/usr/bin #Ruta de la variable de entorno (también puede variar)
umask=077 #La umask que se aplicará para los permisos de archivos o directorios generados #por los scripts
min_uid=0 #El UID mínimo bajo el cual se pueden ejecutar los scripts
min_gid=0 #El GID mínimo bajo el cual se pueden ejecutar los scripts
####En este caso yo puse 0 ya que necesitaba que se ejecutarán bajo root los scripts pero #no es recomendable, el UID y GID mínimo recomendable es 1000, que es donde empiezan los #usuarios que no son de sistema
[handlers]
application/x-httpd-php="php:/usr/bin/php-cgi" #Se establece que aplicación será la que #interpretará los scripts, se debe poner la ruta donde se encuentre php-cgi.</textarea><br />
<br />
El siguiente paso en configuración:<br />
<br />
<b>Para httpd en Fedora o similares:</b><br />
<br />
Editar el archivo /etc/httpd/conf.d/suphp.conf con lo siguiente:<br />
<br />
<textarea cols="45" rows="5">LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php .php
suPHP_AddHandler application/x-httpd-php</textarea><br />
<br />
Y el archivo de configuración de httpd en la sección de los VirtualHost debe quedar parecido a esto (suponiendo que queremos correrlo con el usuario rukia):<br />
<br />
<textarea cols="90" rows="5"><VirtualHost *:8080>
suPHP_UserGroup rukia rukia #Se establece usuario y grupo para ejecutar los scripts
DocumentRoot /var/www/html #Ruta donde se encuentra el contenido que se mostrará en el #servidor web (puede cambiarse esta ruta, siempre y cuando tenga los permisos adecuados)
</VirtualHost></textarea><br />
<br />
<br />
<b>Para Apache en Ubuntu o similares:</b><br />
<br />
Agregar el texto anterior dentro de los VirtualHost que utilizaran suPHP.<br />
<br />
Por lo tanto la configuración para un VirtualHost de Apache en Ubuntu utilizando para ejecutar scripts al usuario rukia sería:<br />
<br />
<textarea cols="60" rows="10">LoadModule suphp_module /usr/lib/apache2/modules/mod_suphp.so
<VirtualHost *:8080>
suPHP_Engine on
AddType application/x-httpd-php .php
suPHP_AddHandler application/x-httpd-php
suPHP_UserGroup rukia rukia
DocumentRoot /var/www/html
</VirtualHost></textarea><br />
<br />
<br />
Y con esto finaliza la instalación y configuración de suPHP ahora sólo queda reiniciar el servidor Apache/httpd.<br />
<br />
Se puede probar por ejemplo con un script que mande a crear un archivo dentro del mismo directorio:<br />
<br />
Código PHP:<br />
<br />
<textarea cols="40">system("touch prueba.txt");</textarea><br />
<br />
Cualquier duda comenten porfavor, saludos!rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-18160870370956938122012-06-21T12:18:00.000-05:002012-06-21T12:18:22.940-05:00How to calculate permissions from umaskUmask (user mask) is a command that defines what default permissions will be established when a file is created by a determined process or user.<br /><br />First the basis: permissions are represented like this in Unix systems: <span style="color: blue;">rwx</span>-<span style="color: red;">rwx</span>-<span style="color: #38761d;">rwx</span>.<br /><br />Where r - Read<br />w - Write<br />x - Execute<br /><br />And where the first group of rwx belongs to the <span style="color: blue;">owner</span>, the second to the <span style="color: red;">group</span> and the third to <span style="color: #38761d;">other users</span>.<br /><br />Example: <span style="color: blue;">rwx</span>-<span style="color: red;">r-x</span>-<span style="color: #38761d;">r-x</span><br /><br />In this case the permissions are: <span style="color: blue;">the owner has rights to read, write and execute</span>. <span style="color: red;">The group to read and execute</span>. <span style="color: #38761d;">Other users to read and execute</span>.<br /><br />So now lets see how to obtain the permissions from a umask:<br /><br />Example: if our umask is of 022, the default permissions for directories will be: 755 (drwx-r-x-r-x) and for files 644 (rw-r---r--).<br /><br />And how did we obtain this? Now lets see how.<br />Before making any calculation:<br /><br />The initial permissions for directories are 777.<br />The initial permissions for files are 666.<br /><br />In the next steps will see how this values are applied to obtain the default permissions that the umask will provide using the example of the 022 umask.<br /><br />First, we make a binary NOT to the umask 022:<br /><br /><span style="color: #38761d;">Lets start with the first 2 (other users):</span><br /><br />
<div style="text-align: center;">
NOT 010=101=5</div>
<br /><span style="color: red;">The NOT to the next 2 will also result in a 5 (group).</span><br /><br /><span style="color: blue;">For the 0 (Owner):</span><br /><br />
<div style="text-align: center;">
NOT 000=111=7</div>
<br />So the result is <span style="color: blue;">7</span><span style="color: red;">5</span><span style="color: #38761d;">5</span>.<br /><br />Now that we have the NOT umask will get the default permissions for directories.<br />We just need to apply an AND binary operation with the 755 that we got before with the initial permissions for directories (777):<br /><br /><span style="color: #38761d;">Lets start with other users:</span><br style="color: #38761d;" /><br />
<div style="text-align: center;">
<span style="color: #38761d;">101(5) AND 111(7) = 101(5)</span></div>
<br /><span style="color: red;">Group:</span><br style="color: red;" /><br />
<div style="text-align: center;">
<span style="color: red;">101(5) AND 111(7) = 101 (5)</span></div>
<br /><span style="color: blue;">Owner:</span><br style="color: blue;" /><br />
<div style="text-align: center;">
<span style="color: blue;">111(7) AND 111(7) = 111 (7)</span></div>
<br />So the default permissions for directories will be 755 (rwx-r-x-r-x).<br /><br />And now lets do the same for the files. For files initial permissions are 666. So the AND will be with 755 and 666.<br /><br /><span style="color: #38761d;">Other users:</span><br style="color: #38761d;" /><br />
<div style="text-align: center;">
<span style="color: #38761d;">101(5) AND 110(6) = 100(4)</span></div>
<br /><span style="color: red;">Group:</span><br style="color: red;" /><br />
<div style="text-align: center;">
<span style="color: red;">101(5) AND 110(6) = 100(4)</span></div>
<br /><span style="color: blue;">Owner:</span><br style="color: blue;" /><br />
<div style="text-align: center;">
<span style="color: blue;">111(7) AND 110(6) = 110(6)</span></div>
<br />So the default permissions for the files will be 644 (rw--r---r--).<br /><br />Summary: with a umask of 022 we obtain 755 permission for directories and 644 permission for files.<br /><br />Hope this post helps, if you have any doubt or you think something is wrong just comment. Or also if you think another example is necessary.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-70389282948228684232012-06-20T12:04:00.001-05:002012-06-20T12:04:23.144-05:00How to build an IPv6 addressAn IPv6 address is composed by 8 fields of 16 bits and is represented like this:<br /><br />
<div style="text-align: center;">
x:x:x:x:x:x:x:x</div>
<br />Where each x is an hexadecimal value. If, in one of the fields we have zeros at the left it is not necessary to write them, also if a field has only zeros its representation can be simplified.<br /><br />For example:<br /><br />
<div style="text-align: center;">
1080:0:0:0:8:800:200C:417A</div>
<br />Simplified will be like this: <b>1080::8:800:200C:417A</b><br /><br />
<div style="text-align: center;">
0:0:0:0:0:0:0:1</div>
<br />Simplified: <b>::1</b><br /><br />Addresses are formed like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilhh7yqy_rY3QLeUSAHlTXdoNNDb0HSkhYlXsBt4uCbr5-zh1ihdBtuYc-jjMuPUsJMCxF_Mz2eJTER1pjb0J9g5nepaRsmR4AevQNRtySPH5pulEO0H8hFBoWvCSWj3iOKPQxGVR0wend/s1600/ipv6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilhh7yqy_rY3QLeUSAHlTXdoNNDb0HSkhYlXsBt4uCbr5-zh1ihdBtuYc-jjMuPUsJMCxF_Mz2eJTER1pjb0J9g5nepaRsmR4AevQNRtySPH5pulEO0H8hFBoWvCSWj3iOKPQxGVR0wend/s320/ipv6.jpg" width="320" /></a></div>
<br />
<br />
<br />Where:<br /><br /><b>Site prefix:</b> Composed of 48 bits. Describes the public topology that the ISP asigns.<br /><br /><b>Subnet ID:</b> Composed of 16 bits. Is assign by the user or the site administrator. The subnet ID describes the private topology, also denominated site topology.<br /><br /><b>Interface ID:</b> Composed of 64 bits. Contains the interface ID, also denominated token. The interface ID is configurated automatically using the MAC address of the interface or manually with the EUI64 format.<br /><br />To convert the MAC address using the EUI64 format we just have to use this simple formula. But first let's see the parts of a MAC address.<br /><br />Example:<br /><br />
<div style="text-align: center;">
00:04:AC:66:7D:47</div>
<br />The first field of 8 bits, in this case: <b>00</b>. Is the universal/local bit (seventh bit).<br />The second and third field of 8 bits, in this case: <b>04:AC</b> are the company ID.<br />And the three remaining fields, in this case: <b>66:7D:47</b> are the ID established by the company.<br /><br />EUI64 convertion formula:<br /><br />
<div style="text-align: center;">
02:[company ID]:FF:FE:[ID established by the company]</div>
<br />Then using the MAC address of the example, the EUI64 format would be:<br /><br />
<div style="text-align: center;">
02:04:AC:FF:FE:66:7D:47</div>
<br />And finally to use this format as the interface ID of the IPv6 address, two fields of 8 bits have to be grouped to make fields of 16 bits:<br /><br />
<div style="text-align: center;">
0204:ACFF:FE66:7D47<br /><br />Simplified: 204:ACFF:FE66:7D47</div>
<br />Now that we have the interface ID we can make an IPv6 address (this example uses an IPv6 global address):<br /><br />
<div style="text-align: center;">
<span style="color: blue;">2002:A09:807</span><span style="color: red;">::</span><span style="color: #38761d;">204:ACFF:FE66:7D47</span></div>
<br /><br />
<br />
Some types of IPv6 addresses:<br /><br /><b>Non-specified address (0:0:0:0:0:0:0:0):</b> This address shall never be asign to a node. This address indicates the absence of an address.<br /><br /><b>Link-local address:</b> A link-local address is asign automatically to an IPv6 interface when it is activated.<br /><br /><b>Site-local address:</b> It's an established range of addresses that are similar to the IPv4 private addresses. These addresses are used preferentially inside a site or in a LAN.<br /><br /><b>Global address:</b> It's also an established range of addresses that are similar to the IPv4 public addresses.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
And that's all hope it helps :)<br /><br />rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-27925359360199858442012-06-19T17:48:00.002-05:002012-06-19T17:49:57.942-05:00Run Apache with multiple usersYou can run Apache as multiple users with this module: apache2-mpm-itk. This module as I understand it is for executing one of the Apache processes as the user established in VirtualHost. So we can have multiple VirtualHost with multiple users.<br />
<br />
I have already used this module with Ubuntu and Apache2.<br />
<br />
Ubuntu installation:<br />
<br />
<span style="font-size: x-small;">apt-get install apache2-mpm-itk</span><br />
<br />
Then we just have to add this line inside a VirtualHost (or in all the VirtualHosts we want to run with a different user than the default for Apache):<br />
<br />
<span style="font-size: x-small;"><IfModule mpm_itk_module><br />AssignUserId <i>User Group</i><br /></IfModule></span><br />
<br />
And that's all. But obviously if we want the directory established to that VirtualHost to work, it must have the right permissions for that user and group whether to run scripts or to write a file.<br />
Even it's possible to run Apache as root.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-40903166691703300962012-06-19T16:14:00.001-05:002012-06-19T16:17:03.010-05:00Basic Linux stuff: The passwd file<span style="font-family: inherit; font-size: small;">The passwd file is located at /etc, and in that file is where the username and other user data is stored when a new user is created or when it is modified.<br />A line that represents the data of a user is written like this:<br /></span><br />
<div style="text-align: center;">
<span style="font-family: inherit; font-size: small;">rukia:x:1000:1000:Rukia:/home/rukia:/bin/bash</span></div>
<span style="font-family: inherit; font-size: small;"><br /></span><br />
<ol>
<li><span style="font-family: inherit; font-size: small;">rukia - Is the username. </span></li>
<li><span style="font-family: inherit; font-size: small;">x - This means that the user has a password. Passwords are encrypted and saved in the shadow file.</span></li>
<li><span style="font-family: inherit; font-size: small;">1000 - The user ID also known as UID.</span></li>
<li><span style="font-family: inherit; font-size: small;">1000 - The group ID also known as GID.</span></li>
<li><span style="font-family: inherit; font-size: small;">Rukia - This field is the complete name of the user but it also contains other data. For example, when in Ubuntu we create a new user, it asks for a lot of information like room number, telephone, etc., well all this info is saved in this field and it is known as the gecos field.</span></li>
<li><span style="font-family: inherit; font-size: small;">/home/rukia - The home folder.</span></li>
<li><span style="font-family: inherit; font-size: small;">/bin/bash - Is the shell that will be executed by the user when he or she logins at a terminal.</span></li>
</ol>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-27919047350218261502012-06-15T19:24:00.000-05:002012-06-15T19:24:00.071-05:00Como calcular permisos de umaskHola, hoy voy a escribir sobre como se calculan los permisos resultantes de umask (máscara de usuario). El umask es una orden que establece que permisos por defecto se van a establecer al crear un archivo por determinado proceso o usuario.<br />
<br />
Primero lo básico: los permisos se ven de esta forma en los sistemas Unix: <span style="color: blue;">rwx</span>-<span style="color: red;">rwx</span>-<span style="color: #38761d;">rwx</span>.<br />
<br />
Donde r - Lectura<br />
w - Escritura<br />
x - Ejecución<br />
<br />
Y donde el primer grupo de rwx corresponde al <span style="color: blue;">dueño</span>, el segundo al <span style="color: red;">grupo</span> y el tercero a <span style="color: #38761d;">otros usuarios</span>.<br />
<br />
Por ejemplo: <span style="color: blue;">rwx</span>-<span style="color: red;">r-x</span>-<span style="color: #38761d;">r-x</span> <br />
<br />
En este caso los permisos serían: <span style="color: blue;">el dueño tiene derecho a lectura, escritura y ejecución</span>. <span style="color: red;">El grupo a lectura y ejecución</span>. <span style="color: #38761d;">Otros usuarios a lectura y ejecución</span>.<br />
<br />
<br />
Entonces para calcular los permisos resultantes según la umask sería así:<br />
<br />
Por ejemplo si nuestra umask es 022, el permiso por defecto para directorios sería: 755 (drwx-r-x-r-x) y para archivos 644 (rw-r---r--).<br />
<br />
Antes de hacer los cálculos:<br />
<br />
Los permisos iniciales para directorios son 777<br />
Los permisos iniciales para archivos son 666<br />
<br />
En los siguientes pasos se verá como se aplican estos valores iniciales para obtener los permisos por defecto que nos proporciona la umask.<br />
<br />
Primero se hace una operación NOT binaria a 022:<br />
<br />
<div style="color: #38761d;">
Empezemos por el primer 2 (otros usuarios):</div>
<br />
<div style="text-align: center;">
NOT 010 = 101 = 5</div>
<br />
<div style="color: red;">
El siguiente 2 también sería 5 el resultado (grupo).</div>
<br />
<div style="color: blue;">
Para el 0 (dueño):</div>
<br />
<div style="text-align: center;">
NOT 000 = 111 = 7</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Por lo tanto el resultado es <span style="color: blue;">7</span><span style="color: red;">5</span><span style="color: #38761d;">5</span>. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Ahora pasamos a obtener los permisos que tendrán por defecto los directorios con esta umask negada: </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Sólo debemos aplicar un AND de 755 y los permisos iniciales para directorios (777):</div>
<div style="text-align: left;">
<br /></div>
<div style="color: #38761d;">
Iniciemos con otros:</div>
<div style="color: #38761d; text-align: left;">
<br /></div>
<div style="color: #38761d; text-align: center;">
101 (5)</div>
<div style="color: #38761d; text-align: center;">
AND </div>
<div style="color: #38761d; text-align: center;">
111 (7) </div>
<div style="text-align: center;">
<span style="color: #38761d;"> 101 (5) RESULTADO</span></div>
<div style="text-align: center;">
<br /></div>
<div style="color: red; text-align: left;">
Grupo:</div>
<div style="color: red; text-align: left;">
<br /></div>
<div style="color: red; text-align: center;">
101 (5)</div>
<div style="color: red; text-align: center;">
AND</div>
<div style="color: red; text-align: center;">
<span style="color: red;">111 (7) </span></div>
<div style="text-align: center;">
<span style="color: red;"> 101 (5) RESULTADO</span></div>
<div style="text-align: center;">
<br /></div>
<div style="color: blue; text-align: left;">
Dueño:</div>
<div style="color: blue; text-align: left;">
<br /></div>
<div style="color: blue; text-align: center;">
111 (7)</div>
<div style="color: blue; text-align: center;">
AND </div>
<div style="color: blue; text-align: center;">
111 (7)</div>
<div style="text-align: center;">
<span style="color: blue;"> 111 (7) RESULTADO</span></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Por lo tanto los permisos que se establecerán por defecto para los directorios serán 755 (rwx-r-x-r-x).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Ahora lo mismo pero para los archivos. Para ellos los permisos iniciales son de 666. Entonces el AND será entre 755 y 666.</div>
<div style="text-align: left;">
<br /></div>
<div style="color: #38761d; text-align: left;">
Otros:</div>
<div style="color: #38761d; text-align: left;">
<br /></div>
<div style="color: #38761d; text-align: center;">
101 (5)</div>
<div style="color: #38761d; text-align: center;">
AND </div>
<div style="text-align: center;">
<span style="color: #38761d;">110 (6) </span></div>
<div style="text-align: center;">
<span style="color: #38761d;"> 100 (4) RESULTADO</span></div>
<div style="text-align: center;">
<br /></div>
<div style="color: red; text-align: left;">
Grupo:</div>
<div style="color: red; text-align: left;">
<br /></div>
<div style="color: red; text-align: center;">
101 (5)</div>
<div style="color: red; text-align: center;">
AND</div>
<div style="color: red; text-align: center;">
110 (6) </div>
<div style="text-align: center;">
<span style="color: red;"> 100 (4) RESULTADO</span></div>
<div style="text-align: center;">
<br /></div>
<div style="color: blue; text-align: left;">
Dueño:</div>
<div style="color: blue; text-align: left;">
<br /></div>
<div style="color: blue; text-align: center;">
111 (7)</div>
<div style="color: blue; text-align: center;">
AND</div>
<div style="text-align: center;">
<span style="color: blue;">110 (6) </span></div>
<div style="text-align: center;">
<span style="color: blue;"> 110 (6) RESULTADO </span></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Por lo tanto los permisos que se establecerán por defecto para los archivos serán de 644 (rw--r---r--).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
En resumen con umask 022 obtenemos permisos 755 para directorios y 644 para archivos.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Y bueno eso es todo espero lo haya explicado bien, cualquier duda pueden comentar. Esto lo hice porque para el siguiente post hay que establecer umask para suPHP, para que así se pueda entender porque se le da el valor que se le da al campo umask en esa configuración. Saludos!</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com3tag:blogger.com,1999:blog-2401974794251107096.post-15023219371395438182012-06-08T20:03:00.000-05:002012-06-08T20:05:43.356-05:00Como formar una dirección IPv6Hola, hoy voy a explicar la representación de las direcciones IPv6 en honor a su lanzamiento esta semana.<br />
<br />
Una dirección IPv6 está compuesta por 8 campos de 16 bits y se representa de la siguiente manera:<br />
<br />
<div style="text-align: center;">
x:x:x:x:x:x:x:x</div>
<br />
Donde cada x es un valor hexadecimal. Si en uno de los campos hay ceros hacia la izquierda no es necesario escribirlos, también si un campo consta de sólo ceros se puede simplificar su escritura.<br />
<br />
Por ejemplo:<br />
<br />
<div style="text-align: center;">
1080:0:0:0:8:800:200C:417A</div>
<br />
Simplificada sería: <b>1080::8:800:200C:417A</b><br />
<br />
<div style="text-align: center;">
0:0:0:0:0:0:0:1</div>
<br />
Simplificada: <b>::1</b><br />
<br />
<br />
Las direcciones están conformadas de la siguiente forma:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio7oRGFfpswsOYy0o0XnCOgtyV9bPBIV13ywo8lVqVqgKm792_z-1WnsKcNcsVmARceCAnqXdGPrRlBn6g1mtn8Rmsh_TaFXxqdvDaNdFQnJdgWHy_dRNxzYr-bCAHlKEhnQ1O_rAF5dsQ/s1600/direccion+ipv6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio7oRGFfpswsOYy0o0XnCOgtyV9bPBIV13ywo8lVqVqgKm792_z-1WnsKcNcsVmARceCAnqXdGPrRlBn6g1mtn8Rmsh_TaFXxqdvDaNdFQnJdgWHy_dRNxzYr-bCAHlKEhnQ1O_rAF5dsQ/s1600/direccion+ipv6.jpg" /></a></div>
Donde:<br />
<br />
<b>Prefijo de sitio:</b> Compuesto de 48 bits. Describe la topología pública que el ISP suele asignar al sitio.<br />
<br />
<b>ID de subred:</b> Compuesto de 16 bits. Es asignada por el usuario o el administrador del sitio. El ID de subred describe la topología privada, denominada también topología del sitio<br />
<br />
<br />
<br />
<b>ID de interfaz:</b> Compuesto de 64 bits. Contiene el ID de interfaz, también denominado token. El ID de interfaz se configura automáticamente desde la dirección MAC de la interfaz o manualmente en formato EUI64.<br />
<br />
<br />
Para convertir la MAC utilizando el formato EUI64 sólo hay que usar la siguiente fórmula que es muy sencilla. Pero primero vamos a ver como está conformada una MAC.<br />
<br />
Ejemplo para ver como se forma:<br />
<br />
<div style="text-align: center;">
00:04:AC:66:7D:47</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
El primer grupo de 8 bits, en este caso: <b>00</b>. Es donde se encuentra el bit universal/local (séptimo bit).<br />
</div>
<div style="text-align: left;">
El segundo y tercer grupo de 8 bits, en este caso: <b>04:AC</b> son el ID de la compañía.<br />
</div>
<div style="text-align: left;">
Y los tres grupos restantes, en este caso: <b>66:7D:47</b> corresponden al ID establecido por el fabricante.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Fórmula conversión EUI64:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
02:[id de la compañía]:FF:FE:[id establecido por el fabricante] </div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Entonces utilizando de ejemplo la MAC anterior, el formato EUI64 quedaría de la siguiente forma:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
02:04:AC:FF:FE:66:7D:47</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Y finalmente para utilizar este formato como el ID de interfaz de la dirección IPv6, se agrupan dos grupos de 8 bits para hacer los campos de 16 bits:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
0204:ACFF:FE66:7D47</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Simplificado: 204:ACFF:FE66:7D47</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Ya con el ID de interfaz se puede formar una dirección IPv6. En este ejemplo se muestra una dirección global IPv6: </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
<span style="color: blue;">2002:A09:807</span><span style="color: red;">::</span><span style="color: #38761d;">204:ACFF:FE66:7D47</span></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;">Algunos tipos de direcciones IPv6:</span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"></span></span></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><b>Dirección sin especificar (0:0:0:0:0:0:0:0):</b> Nunca deberá ser asignada a ningún nodo. Esta dirección indica la ausencia de una dirección.</span></span></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><br /></span></span> </div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"></span></span></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><b>Dirección local de enlace (link-local):</b> Cuando una interfaz IPv6 es activada, se le asignara automáticamente una dirección local de sitio.</span></span></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><br /></span></span> </div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><b>Dirección local de sitio (site-local):</b> Es un rango de direcciones establecido que vendría siendo como las direcciones privadas IPv4. Estas direcciones se utilizan preferentemente dentro de un mismo sitio o LAN.</span></span></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><br /></span></span> </div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><b>Dirección global:</b> Es también un rango de direcciones establecido que vendrían siendo como las direcciones públicas IPv4.</span></span></div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><br /></span></span> </div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;"><br /></span></span> </div>
<div style="text-align: left;">
<span style="color: #38761d;"><span style="color: black;">Y bueno esto es todo lo básico que se sobre IPv6, si tienen más dudas pueden comentar ya que no soy experta en el tema pero si lo maneje por un tiempo ya que realicé un trabajo en IPv6 para mi titulación. Pero cualquier duda me dicen y sino puedo responderla busco la info.</span></span></div>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com2tag:blogger.com,1999:blog-2401974794251107096.post-60234875733564606122012-06-01T19:41:00.000-05:002012-06-01T19:41:07.170-05:00Ejecutar Apache con múltiples usuarios en UbuntuBueno otra vez voy a escribir algo rápido que puede ser útil. <br />
<br />
Esta vez necesitaba ejecutar Apache como root, pero es obvio que esto no es seguro, así que quería ejecutar sólo un VirtualHost bajo root.<br />
<br />
Buscando en Internet di con un blog que explicaba sobre un módulo para<br />
<br />
Apache llamado <b>apache2-mpm-itk</b>. Este módulo según entiendo es para ejecutar uno de los procesos de Apache como el usuario establecido en el VirtualHost. Por lo tanto podemos tener múltiples VirtualHost con múltiples usuarios.<br />
<br />
Este módulo ya lo utilicé en Ubuntu con Apache2, lo que no he logrado desfortunadamente es que me funcione en Fedora16 con httpd. Pero sigo haciendo el intento todos los días si me es posible de ver la forma de correr httpd con distintos usuarios. Existen otras opciones como suPHP y suExec pero no les he dedicado el tiempo para checarlos. Pero bueno sigamos con lo del módulo itk.<br />
<br />
<b>Para instalarlo en Ubuntu </b><br />
<br />
<span style="font-size: x-small;">apt-get install apache2-mpm-itk</span><br />
<b> </b><br />
Después sólo basta agregar lo siguiente dentro de uno de nuestros VirtualHost:<br />
<br />
<span style="font-size: x-small;"><IfModule mpm_itk_module></span><br />
<span style="font-size: x-small;">AssignUserId <i>Usuario Grupo</i></span><br />
<span style="font-size: x-small;"></IfModule> </span><br />
<br /><br />
Y ya es todo. Pero obviamente para que funcione el directorio indicado para ese VirtualHost debe tener los permisos adecuados para ese usuario y grupo, ya sea para ejecutar scripts o escribir un archivo.<br />
Incluso se puede ejecutar como root.<br />
<br /><br />
Espero les sirva este dato porque a mi me ha ayudado mucho para mi proyecto sólo espero resolverlo para Fedora y lo escribiré también<br />
<br /><br />
Conocí este módulo gracias a la publicación en este blog: <a href="http://blog.andreaolivato.net/open-source/running-apache2-virtualhost-with-different-users.html">http://blog.andreaolivato.net/open-source/running-apache2-virtualhost-with-different-users.html</a><br />
<pre class="apache" style="font-family: monospace;"> </pre>
<pre class="apache" style="font-family: monospace;">
</pre>
<div class="apache" style="font-family: inherit;">
<span style="font-size: small;"> Cualquier duda dejen comentarios.</span></div>
<br /><pre class="bash" style="font-family: monospace;">
</pre>rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-39653913353865904132012-05-25T18:54:00.000-05:002012-05-25T19:06:25.121-05:00Cosas básicas Linux: El archivo passwdEstos días he utilizado mucho el archivo passwd por un proyecto y hasta
ahora he analizado como está compuesto -.-... Así que publicaré una
descripción de como entender este archivo. A lo mejor muchos ya saben o
ya hay muchos artículos pero aún así lo voy a poner.<br />
<br />
Bueno el archivo passwd se encuentra en el directorio /etc y ahí es
donde se almacenan el nombre de usuario, y otros datos más cuando se
agrega un usuario nuevo o cuando se modifica.<br />
Una línea que representa los datos de un usuario está escrita de la siguiente forma:<br />
<br />
<br />
<blockquote class="tr_bq">
<div style="text-align: center;">
rukia:x:1000:1000:Rukia:/home/rukia:/bin/bash</div>
</blockquote>
<br />
<ol>
<li>rukia - Es el nombre de usuario.</li>
<li>x - Esto quiere decir que el usuario tiene una contraseña. Las
contraseñas se almacenan en el archivo shadow de forma encriptada.</li>
<li>1000 - Es el ID de usuario también conocido como UID.</li>
<li>1000 - El ID de grupo también conocido como GID.</li>
<li>Rukia - Este campo es el nombre completo del usuario pero también
contiene otros datos. Por ejemplo en Ubuntu cuando creamos un nuevo
usuario que hace ese montón de preguntas como número de cuarto el tel
etc., bueno todo eso se almacena en ese campo y es conocido como el
campo gecos.</li>
<li>/home/rukia - La carpeta home o personal del usuario.</li>
<li>/bin/bash - Es el shell que ejecutará el usuario cuando inicia sesión en terminal.</li>
</ol>
<br />
Y bueno así está compuesto este archivo. Saludos! <br />rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com0tag:blogger.com,1999:blog-2401974794251107096.post-57757983989432107762012-03-09T18:40:00.000-06:002012-03-09T18:40:53.855-06:00Presentación de blog de tutoriales y más cosas LinuxHola a quien me lea,<br />
<br />
Hice este blog para subir tutoriales de Linux y otras cosas que se me ocurra comentar de compus, y para contestar dudas.<br />
<br />
No soy experta en Linux pero haré estos tutoriales en base a cosas que he hecho en Linux por cuenta propia o por mi trabajo. He trabajado con las distribuciones de Debian, Ubuntu, EduLinux, CentOS y RedHat. Así que tal vez pueda responder varias cosas o no. Pero el chiste es aprender más con este blog.<br />
<br />
Sobre mi y las compus: Mi sistema operativo favorito es Linux, Windows tiene lo suyo para usuarios finales y para jugar. Y cualquier cosa de la marca Apple la detesto, pero no haré comentarios porque sino luego hay problemas pero aún así si respeto que la Mac es lo mejor para el diseño.<br />
<br />
El primer tutorial que subiré será sobre como montar un servidor VPN en Ubuntu con autenticación a través de Active Directory.rukiaEnixhttp://www.blogger.com/profile/03036252496419117497noreply@blogger.com3