viernes, 17 de agosto de 2012

Hola Mundo en Html


http://www.holamundo.es/lenguaje/html/

HTML

HTML, acrónimo inglés de Hypertext Markup Language (lenguaje de etiquetado de documentos hipertextual), es un lenguaje de marcado diseñado para estructurar textos y presentarlos en forma de hipertexto, que es el formato estándar de las páginas web. Gracias a Internet y a los navegadores del tipo Internet Explorer, Opera, Firefox o Netscape, el HTML se ha convertido en uno de los formatos más populares que existen para la construcción de documentos.

Web Oficial (o significativa)


Ejemplo 1


<HTML>
<HEAD>
<TITLE>ejemplo hola mundo</TITLE>
</HEAD>
<BODY>
<P>Hola Mundo</P>
</BODY>
</HTML>

ISA server, publicacion de dominios WEB dentro de una red ISA

http://www.isaserver.org/tutorials/multiwebpubpart2.html
Publishing Multiple Web Roots with a Path Statement, Part 2
By Thomas W Shinder M.D.
In the first part of this two part article, I introduced the topic of publishing multiple Web sites using a single IP address and single domain name, but a different path statement in the URL. If you missed the first part or need a refresher, head on over to http://www.isaserver.org/tutorials/multiwebpubpart1.html and first part 1. In this second and final part of the two part article I’ll go over how to create and configure the Web sites on Internet Information Server 5.0 (IIS 5.0) and DNS issues you need to address so that external network clients can access your sites.
Get the Book!
===========================
Create the Web Sites on the Web Server
===========================
There’s a good chance that someone else has probably already created the Web sites for you. If you have to play both Web server and firewall administrator, then you might have to create the Web sites yourself. Creating new Web sites is very easy if you use Internet Information Server 5.0 (IIS 5.0). The only requirement from the firewall point of view is that each site have a different IP address (at least in the scenario that we’re discussing today, you could use different port numbers).
It’s very important to remember that the ISA Server isn’t going to protect you from everything that comes from the Internet into your Web server. While the ISA Server can perform content inspection and protect against many different types of exploits, the ISA Server does not replace host based security. You need to harden the Web server based on the Web server’s role. Fortunately, you can secure your Web server to a fairly high level even if you’re not a Web site security specialist. The IISLockdown tool and URLScan can do the heavy lifting for you. Check out these tools at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=DDE9EFC0-BB30-47EB-9A61-FD755D23CDEC
You must bind all the IP addresses you need to the Web server computer before you being assigning these addresses to the Web sites. Remember that the Default Web Site and the Administration Web Site also need an IP address; they can share the same IP address but you do not want them to share an address with any of your other sites. While you have the option to create all your Web sites to listen on "all addresses" before assigning them to a specific IP address, I highly recommend that you bind the IP addresses to the network interface before you create the sites. By adding the IP address first, you’ll be much less likely to forget something important.
Perform the following steps to create a new Web site after you’ve bound the IP addresses to the Web server’s interface:
  1. Open the Internet Information Services console from the Administrative Tools menu.
  2. Expand your server name. Right click on the Default Web Site and click Properties.
  3. Click on the Web Site tab in the Default Web Site Properties dialog box. Notice that the IP Address setting is set to [All Unassigned] by default. Click the down arrow and select an IP address for the Default Web Site to use. Select the address then click Apply and then click OK.
  4. Repeat this procedure at the Administration Web Site.
  5. Right click on the Default Web Site, point to New and click on Site.
  6. Click Next on the Welcome to the Web Site Creation Wizard page.
  7. On the Web Site Description page, type in a name for the site. This is the name that will appear in the left pane of the console. Click Next.

  1. On the IP Address and Port Settings page, select the IP address you want to use for the site in the Enter the IP address to use for the Web site drop down list box. Leave the TCP port this web site should use at 80. You’re not doing any port redirection, so you don’t want to use an alternate port number. Click Next to continue.

  1. On the Web Site Home Directory page, type in the path to the folder where you want the Web site to live on the hard disk. The wizard will not create the folder for you, so if you forgot to create the folder, you can leave the dialog box as it is and open the Windows Explorer to create the new folder After creating the folder, return to the dialog box and type in the path. Click Next.

  1. On the Web Site Access Permissions dialog box, leave the default settings or change them depending on your requirements. Your requirements are determined by the goals and functions of your site. Click Next to continue.
  2. Click Finish on the You have successfully completed the Web Site Creation Wizard page.
In this scenario, we need to create three sites, called Web10, Web11 and Web12. The figure below shows what the console looks like after creating the three sites.

Now that you have the Web sites, you can create the subfolders used for the path-based redirection. For example, for Web10, we need to create a subdirectory in the root folder for Web10 named web10. After you create the subfolder in the physical directory, you can return to the Internet Information Services console and configure the redirection on that folder to the Web root.
  1. Open the Windows Explorer and create the subdirectory for the redirect. In our example, we want users to be able to type www.internal.net/web10 to receive the redirect to the root of the Web10 site. You can see the subdirectories used for the redirection in the figure below.

  1. Return to the Internet Information Services console. Click the Refresh button in the console’s button bar. You should now see the directory you just created in the right pane of the console. Right click on that directory and click Properties.
  2. Click on the Directory tab. Click on the A redirection to a URL option. Type in the URL that you want to use for the redirect in the Redirect to text box. Note that the FQDN has to be exactly the same as the one you used into the Destination Set for the Redirect Web Publishing Rule you created for the site. In this example, when users connect to the web10 subdirectory on this web site, they will be sent a redirect that tells them to request the default document at http://www10.internal.net. Do not select The exact URL entered above option unless you want to limit users to the default document at the redirected site. For example, if a user typed http://www.internal.net/web10/stuff.txt in the browser, the redirect would be to http://www10.internal.net if you select the exact URL option. However, if you do not select that option (which I recommend), when a user tries to access http://www.internal.net/web10/stuff.txt, they will be redirected to http://www10.internal.net/stuff.txt. You can select the A permanent redirection for this resource to improve performance on busy sites. Click Apply and then OK after making the changes.

  1. After making the changes you’ll see the subdirectory used for the redirect in the right pane of the console and it shows that requests to that directory are redirected to the URL of your choice. This is the key setting that allows you to redirect to the root of the site. This redirect works together with the Web Publishing Rule you created earlier.

  1. Stop and start the Web site using the stop and start buttons in the button bar in the console.
  2. Repeat this procedure with your other Web sites. In this example, we’re publishing three different sites, so we need to create the redirects for the subfolders in Sites Web11 and Web12.
You’re almost done. You’ve configured the Incoming Web Requests listener, the Destination Sets, the Web Publishing Rules and the Web sites. There’s only one thing left for you to do: create the DNS records the external users need to access your primary and redirect sites.
Get the New Book!
===========================
Create the DNS Records
===========================
Let’s take another look at our scenario diagram:
The external network clients need to be able to resolve the names:
www.internal.net
www10.internal.net
www11.internal.net
www12.internal.net
The first entry is required for the primary connections (www.internal.net/web10, etc). The three Web Publishing Rules we created for the primary connections can use the first DNS entry, since the primary connections are always to www.internal.net. However, we need three different DNS entries for the redirects, because the redirects are to three different host names (within the same domain as the primary connection, in this example).
All of the Host (A) entries map to the same IP address, which is the single IP address bound to the external interface of the ISA Server; this address is used by the Incoming Web Requests listener. You don’t have to do it this way, but there’s no reason not to. This method allows you to preserve you public IP addresses for Server Publishing Rules, in the event that you might need to use them in the future. The great thing about Web Publishing Rules is that you can publish 5000 Web sites using a single IP address on the external interface of the ISA Server!
Keep in mind that the Host (A) entries have to be created on a public DNS server. It won’t do you any good at all to put these entries on your private network’s DNS server. The records must be accessible to external network clients. The public DNS server can be hosted by your ISP, by your friend’s DNS server, or you can publish your own DNS server. What’s important is that external network clients are able to access the DNS server authoritative for the domains you’ve included in the Destination Sets.
Get the New Book!
===========================
Putting it All Together
===========================
The ISA Server is configured, the Web sites are set up, and the DNS host records are in place. Let’s look at the details of what happens when the external clients make the request.
  1. The external client makes a request for http://www.internal.net/web10 using Internet Explorer.
  2. The request is intercepted by the Incoming Web Requests listener at IP address 1.1.1.1. The Incoming Web Requests listener passes the request to the Web Proxy service. The Web Proxy service looks at the HTTP header and finds the request is for www.internal.net/web10. The Web Proxy service compares this request string with the entries in the Destination Sets contained in all the Web Publishing Rules. Web Publishing Rules are arranged in hierarchical order, so the one on top is evaluated first. The first rule that contains a Destination Set with an entry www.internal.net/web10 is a match. The matched Web Publishing rule tells the Web Proxy service to forward the request to the http://10.0.0.10/web10
  3. The Web site at 10.0.0.10, which is Web10, detects the incoming request to its /web10 directory.
  4. The internal Web server sends back to the requesting client a redirect, telling the Web client to go to www.10.internal.net.
  5. The external client sends a request for www10.internal.net
  6. The Incoming Web Requests listener intercepts the request for www10.internal.net and forwards it to the Web Proxy service. The Web Proxy service compares the string www.internal.net in the request with the entries in the Destination Sets used by the Web Publishing Rules. The highest ranked Web Publishing Rule that contains www.interal.net in its Destination Set is triggered and is configured to redirect the request to http://10.0.0.10
Get the Book!
Summary
In this two part article we went over the procedures required to publish multiple Web sites using the same FQDN, but different paths within that domain. The procedure is fairly straightforward, with the key element being the differentiation of the primary and redirect connections. You first create Destination Sets for the primary and redirect connections, then you create Web Publishing Rules based on those Destination Sets. The Web sites are configured so that when a user connects to a specific folder on the Web site, the user receives a redirect to the root of the same site, but via an alternate FQDN. While we used the same Web site for the redirect in this example, there is nothing preventing you from redirecting to an entirely different site.
I hope you enjoyed this article and found something in it that you can apply to your own network. If you have any questions on anything I discussed in this article, head on over to http://forums.isaserver.org/ultimatebb.cgi?ubb=get_topic;f=5;t=001383 and post a message. I’ll be informed of your post and will answer your questions ASAP. Thanks! –Tom

jueves, 16 de agosto de 2012

Lógica Proposicional - Formalización de Enunciados con Símbolos - Variables Booleanas


http://cibernous.com/logica/ejercicios/ejercicio1.html


EJERCICIOS SOBRE FORMALIZACIÓN DE ENUNCIADOS


1. Formaliza las siguientes proposiciones:

a. No es cierto que no me guste bailar
b. Me gusta bailar y leer libros de ciencia ficción.
c. Si los gatos de mi hermana no soltaran tanto pelo me gustaría acariciarlos.
d. Si y sólo si viera un marciano con mis propios ojos, creería que hay vida extraterrestre.
e. Una de dos: o salgo a dar un paseo, o me pongo a estudiar como un energúmeno.
f. Si los elefantes volaran o supieran tocar el acordeón, pensaría que estoy como una regadera y dejaría que me internaran en un psiquiátrico.
g. Prefiero ir de vacaciones o estar sin hacer nada si tengo tiempo para ello y no tengo que ir a trabajar.

Si y sólo si has intentado realizar tú mismo este ejercicio, pulsa el enlace para ver las soluciones   ;-)

2. Formaliza la siguientes proposición:

a. Si tuvieran que justificarse ciertos hechos por su enorme tradición entonces, si estos hechos son inofensivos y respetan a todo ser viviente y al medio ambiente, no habría ningún problema. Pero si los hechos son bárbaros o no respetuosos con los seres vivientes o el medio ambiente, entonces habría que dejar de justificarlos o no podríamos considerarnos dignos de nuestro tiempo.

Las premisas se nombran con variables booleanas


SOLUCIONES AL EJERCICIO 1

a.
[b me gusta bailar]. ¬(¬b)
b. [b me gusta bailar. c me gusta leer libros de ciencia ficción]. b & c
c. [ g los gatos de mi hermana sueltan pelo. a me gusta acariciar los gatos ]. ¬g -> a
d. [ m ver un marciano con mis propios ojos. e creer en los extraterrestres ]. m <-> e
e. [ p salir a dar un paseo. e estudiar como un energúmeno]. p V e

f. [ v los elefantes vuelan. t los elefantes tocan el acordeón. l estar loco. p internar en un psiquiátrico ]. ( v V t ) -> ( l & p)
g. [ v ir de vacaciones. n no hacer nada. t tener tiempo. i ir a trabajar ]. (t & ¬i ) -> (v V n )


SOLUCIONES AL EJERCICIO 2

a.
J justificar hechos por su tradición. i ser inofensivo. r ser respetuoso con los seres vivos. m ser respetuoso con el medio ambiente. p tener problemas. b ser bárbaro. d ser digno de nuestro tiempo.
j -> (( i & m) -> ¬p) & (( b V ¬( r V m) -> (¬j V ¬d))





miércoles, 15 de agosto de 2012

iptables y NAT para vagos

http://bulma.net/impresion.phtml?nIdNoticia=1522

Bisoños Usuarios de GNU/Linux de Mallorca y Alrededores   |   Bergantells Usuaris de GNU/Linux de Mallorca i Afegitons
iptables y NAT para vagos (282440 lectures)
Per Ricardo Galli Granada, gallir (http://mnm.uib.es/gallir/)
Creado el 30/09/2002 13:57 modificado el 14/01/2003 18:47

A pesar que en Bulma hay varios artículos(1) explicando estos temas, es una pregunta recurrente(2) en la lista Bulmailing. Además no se suelen usar las características, muy buenas, de control de conexiones del netfilter. Aquí doy un par de ejemplos concretos, especialmente preparados para los vagos que no se leen ningún tutorial :-)
En nuestros ejemplos vamos aprovechar las capacidades de control de conexiones que tienen las iptables. Primero, hay que tener en cuenta que el forwarding debe estar habilitado:
echo 1 > /proc/sys/net/ipv4/ip_forward
Y también recordar que para cambiar las reglas, primero hay que “borrar” las anteriores, por ejemplo:
iptables -F
iptables -t nat -F
Ahora veremos ejemplos particulares, en todos los ejemplos suponemos que las direcciones de nuestra red privada son 192.168.0.0/24 (es decir la máscara es de 24 bits: 255.255.255.0)

Sólo quiero hacer masquerading de una IP asignada dinámicamente

Caso común para un Linux que obtiene direcciones dinámicas de su proveedor de Internet, en el ejemplo lo doy con la interfaz ippp0, que es la que se usa para RDSI, pero podéis sustituirla por caulquier interfaz que uséis (eth0, ppp0...).
Además de hacer el NAT, vamos a permitir el tráfico ICMP (de los pings...) ya que está recomendado que así funcione. Veremos que las última 3 reglas, que no son obligatorias, peri os las recomiendo, lo que haces es descartar cualquier paquete que no sea de uina conexión previamente establecida.
# Habilito el NAT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 0.0.0.0/0  \
     -j MASQUERADE
# Dejo pasar los paquetes ICMP
iptables -A INPUT -i ippp0 -p ICMP -j ACCEPT
# Acepto paquetes de conexiones ya establecidas
iptables -A INPUT -p TCP -m state --state RELATED \
    -j ACCEPT
# Rechazamos paquetes de conexiones nuevas
iptables -A INPUT -i ippp0 -m state --state NEW,INVALID -j DROP
# Rechazamos paquetes de forwarding de conexiones no establecidas
iptables -A FORWARD -i ippp0 -m state --state NEW,INVALID -j DROP

Pero también quiero permitir conexiones entrantes SSH y HTTP

Eso es fácil, antes de las últimas reglas “DROP” hay que poner unas que permitan las conexiones nuevas a esos puertos. Las reglas nos quedan de la siguiente forma:
# Habilito el NAT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 0.0.0.0/0  \
    -j MASQUERADE
# Dejo pasar los paquetes ICMP
iptables -A INPUT -i ippp0 -p ICMP -j ACCEPT
# Permito conexiones al puerto 80 (HTTP)
iptables -A INPUT -i ippp0 -p TCP --dport 80 -m state --state NEW  \
    -j ACCEPT
# Permito conexiones al puerto 22 (SSH)
iptables -A INPUT -i ippp0 -p TCP --dport 22 -m state --state NEW  \
    -j ACCEPT
# Acepto paquetes de conexiones ya establecidas
iptables -A INPUT -p TCP -m state --state RELATED  \
    -j ACCEPT
# Rechazamos paquetes de conexiones nuevas
iptables -A INPUT -i ippp0 -m state --state NEW,INVALID -j DROP
# Rechazamos paquetes de forwarding de conexiones no establecidas
iptables -A FORWARD -i ippp0 -m state --state NEW,INVALID -j DROP

Si queréis “abrir” otros puestos, sólo tenéis que agregar esas nuevas reglas.

Tengo dirección IP fija, ¿como lo hago?

Es muy fácil, en vez de usar masquerading, vamos a usar una solución mejor: source NAT. Sólo hay que cambiar la regla del nat (la primera en los ejemplos anteriores). Si la interfaz que tiene la IP fija es la eth0, y la IP fija es la 111.111.111.111, nos quedaría:
# Habilito el SNAT
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 111.111.111.111
# Dejo pasar los paquetes ICMP
iptables -A INPUT -i eth0 -p ICMP -j ACCEPT
# Permito conexiones al puerto 80 (HTTP)
iptables -A INPUT -i eth0 -p TCP --dport 80 -m state --state NEW  \
    -j ACCEPT
# Permito conexiones al puerto 22 (SSH)
iptables -A INPUT -i eth0 -p TCP --dport 22 -m state --state NEW  \
    -j ACCEPT
# Acepto paquetes de conexiones ya establecidas
iptables -A INPUT -p TCP -m state --state RELATED  \
    -j ACCEPT
# Rechazamos paquetes de conexiones nuevas
iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
# Rechazamos paquetes de forwarding de conexiones no establecidas
iptables -A FORWARD -i eth0 -m state --state NEW,INVALID -j DROP

Vale, pero ahora quiero redireccionar las conexiones a un puerto hacia un ordenador interno de mi LAN

Esto se llama destination NAT es bastante sencillo, sólo hay que poner una regla adicional. Por ejemplo, si queremos redireccionar las conexiones al puerto 80 hacia el puerto 80 de un ordenador en la red interna (192.168.0.111).
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT \
           --to 192.168.0.111:80
Otro ejemplo sencillo y muy útil, redireccionar el puerto 2022 del ordenador haciendo de NAT o firewall hacia el puerto 22 (ssh) de un ordenador de la red interna.
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2022 -j DNAT \
           --to 192.168.0.111:22
Voilà, funciona. También podéis leer los Howtos y tutoriales(3), que están hasta en castellano.

Lista de enlaces de este artículo:
  1. http://bulma.net/htdig-bin/htsearch?config=htdig&exclude=&method=and&format=buil
  2. http://bulma.net/htdig-bin/htsearch?config=htdig&exclude=&method=and&format=buil
  3. http://www.netfilter.org/documentation/

E-mail del autor: gallir _ARROBA_ uib.es
Podrás encontrar este artículo e información adicional en: http://bulma.net/body.phtml?nIdNoticia=1522

Linux IPTables: Incoming and Outgoing Rule Examples (SSH and HTTP)


http://www.thegeekstuff.com/2011/03/iptables-inbound-and-outbound-rules/

Linux IPTables: Incoming and Outgoing Rule Examples (SSH and HTTP)

by Ramesh Natarajan on March 15, 2011
In our previous IPTables firewall series article, we reviewed how to add firewall rule using “iptables -A”.
We also explained how to allow incoming SSH connection. On a high-level, it involves following 3 steps.
  1. Delete all existing rules: “iptables -F”
  2. Allow only incoming SSH: “iptables -A INPUT -i eth0 -p tcp –dport 22 -j ACCEPT”
  3. Drop all other incoming packets: “iptables -A INPUT -j DROP”
The above works. But it is not complete. One problem with the above steps is that it doesn’t restrict the outgoing packets.

Default Chain Policy

The default policy of a chain is ACCEPT. If you don’t what what a chain means, you better read our iptables introduction article. So, both the INPUT and OUTPUT chain’s default policy is ACCEPT. In the above 3 steps we dropped all incoming packets at the end (except incoming ssh). However, we didn’t restrict the outgoing traffic.
As you notice below, it says “(policy ACCEPT)” next to all the three chain names (INPUT, OUTPUT, and FORWARD). This indicates that the default chain policy is ACCEPT.
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
So, you have two options here.

Option 1: Add drop rules

At the end, add the following three drop rules that will drop all incoming, outgoing, and forward packets (except those that are defined above these three rules). If you do this, the default chain policy is still ACCEPT, which shouldn’t matter, as you are dropping all the packets at the end anyway.
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
iptables -A FORWARD -j DROP

Option 2: Change the default chain policy to DROP

At the beginning, execute the following three commands that will change the chain’s default policy to DROP.
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
Now, if you add the allow ssh rule: “iptables -A INPUT -i eth0 -p tcp –dport 22 -j ACCEPT”, and do iptables -L, you’ll notice that it says “(policy DROP)” next to all the three chains.
# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination
But there is a problem here. The allow ssh incoming connection rule will not work anymore, because all the outgoing packets are dropped.

Allow Incoming Connections

When the default policy is DROP for INPUT and OUTPUT chains, for every incoming firewall rule, you need to specify the following two rules.
  1. Request rule: This is the request that comes from the client to the server for the incoming connection.
  2. Response rule: This is for the response that goes out from the server to the client (for the corresponding incoming request).

Example 1: Allow incoming SSH connection

This is to allow SSH connection from outside to your server. i.e You can ssh to your server from outside.
This involves two steps. First, we need to allow incoming new SSH connections. Once the incoming ssh connection is allowed, we also need to allow the response back for that incoming ssh connection.
First, Allow incoming SSH connection request, as shown below.
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
In the above example:
  • iptables -A INPUT: Append the new rule to the INPUT chain. For incoming connection request, this always has to be INPUT.
  • -i eth0: This refers to the input interface. For incoming connections, this always has to be ‘-i’.
  • -p tcp: Indicates that this is for TCP protocol.
  • –dport 22: This refers to the destination port for the incoming connection. Port 22 is for ssh.
  • -m state: This indicates that the “state” matching module is used. We’ll discuss more about “-m” option (and all available matching modules for iptables) in future article.
  • –state NEW, ESTABLISHED: Options for the “state” matching module. In this example, only NEW and ESTABLISHED states are allowed. The 1st time when a SSH connection request is initiated from the client to the server, NEW state is used. ESTABLISHED state is used for all further request from the client to the server.
Next, Allow outgoing (ESTABLISHED state only) SSH connection response (for the corresponding incoming SSH connection request).
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
In the above example:
  • iptables -A OUTPUT: Append the new rule to the OUTPUT chain. Since this is for the response rule (for the corresponding incoming request) that goes out from the server, this should be OUTPUT.
  • -o eth0: This refers the output interface. For outgoing connections, this always has to be ‘-o’.
  • -p tcp: Indicates that this is for TCP protocol.
  • –sport 22: This refers to the source port for the outgoing connection. Port 22 is for ssh. Since the incoming request (from the previous rule) came to the “destination” port, the outgoing response will go through the “source” port.
  • -m state: This indicates that the “state” matching module is used.
  • –state ESTABLISHED: Since this is a response rule, we allow only ESTABLISHED connection (and not any NEW connection).

Example 2: Allow incoming HTTP connection

This is to allow HTTP connection from outside to your server. i.e You can view your website running on the server from outside.
Just like the above SSH incoming rules, this also involves two steps. First, we need to allow incoming new HTTP connection. Once the incoming HTTP connection is allowed, we need to allow the response back for that incoming HTTP connection.
First, Allow incoming HTTP connection request, as shown below.
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
Next, Allow outgoing (ESTABLISHED only) HTTP connection response (for the corrresponding incoming SSH connection request).
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
Note: In the above HTTP request and response rule, everything is same as the SSH example except the port number.

Allow Outgoing Connections

When the default policy is DROP for the INPUT and OUTPUT chains, for every outgoing firewall rule, you need to specify the following two rules.
  1. Request rule: This is the request that goes out from the server to outside for the outgoing connection.
  2. Response rule: This is for the response that comes back from the outside to the server (for the corresponding outgoing request).

Example 3: Allow outgoing SSH connection

This is to allow SSH connection from your server to the outside. i.e You can ssh to outside server from your server.
This involves two steps. First, we need to allow outgoing new SSH connection. Once the outgoing ssh connection is allowed, we also need to allow the response back for that outgoing ssh connection.
First, Allow outgoing SSH connection request, as shown below.
iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
In the above example:
  • iptables -A OUTPUT: Append the new rule to the OUTPUT chain. For outgoing connection request, this always has to be OUTPUT.
  • -o eth0: This refers the output interface. For outgoing connections, this always has to be ‘-o’.
  • -p tcp: Indicates that this is for TCP protocol.
  • –dport 22: This refers to the destination port for the outgoing connection.
  • -m state: This indicates that “state” matching module is used.
  • –state NEW, ESTABLISHED: Options for the “state” matching module. In this example, only NEW and ESTABLISHED states are allowed. The 1st time when a SSH connection request is initiated from the server to the outside, NEW state is used. ESTABLISHED state is used for all further request from the server to the outside.
Next, Allow outgoing (ESTABLISHED only) SSH connection response (for the corresponding incoming SSH connection request).
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
In the above example:
  • iptables -A INPUT: Append the new rule to the INPUT chain. Since this is for the response rule (for the corresponding outgoing request) that comes from the outside to the server, this should be INPUT.
  • -i eth0: This refers the input interface. For incoming connections, this always has to be ‘-i’.
  • -p tcp: Indicates that this is for TCP protocol.
  • –sport 22: This refers to the source port for the incoming connection. Since the outgoing request (from the previous rule) went to the “destination” port, the incoming response will come from the “source” port.
  • -m state: This indicates that the “state” matching module is used.
  • –state ESTABLISHED: Since this is a response rule, we allow only ESTABLISHED connection (and not any NEW connection).

Putting it all together

Create rules.sh shell script which does the following:
  1. Delete all existing rules
  2. Set default chain policies
  3. Allow inbound SSH
  4. Allow inbound HTTP
  5. Allow outbound SSH
First, create the rules.sh
$ vi rules.sh
# 1. Delete all existing rules
iptables -F

# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# 3. Allow incoming SSH
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT

# 4. Allow incoming HTTP
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

# 5. Allow outgoing SSH
iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
Next, execute the rules.sh and view the rules.
# chmod u+x rules.sh

# ./rules.sh

# iptables -L
Chain INPUT (policy DROP)
target     prot opt source      destination
ACCEPT     tcp  --  anywhere    anywhere      tcp dpt:ssh state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere    anywhere      tcp dpt:http state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere    anywhere      tcp spt:ssh state ESTABLISHED 

Chain FORWARD (policy DROP)
target     prot opt source      destination         

Chain OUTPUT (policy DROP)
target     prot opt source      destination
ACCEPT     tcp  --  anywhere    anywhere      tcp spt:ssh state ESTABLISHED
ACCEPT     tcp  --  anywhere    anywhere      tcp spt:http state ESTABLISHED
ACCEPT     tcp  --  anywhere    anywhere      tcp dpt:ssh state NEW,ESTABLISHED
Using this as a basis you should be able to write your own incoming and outgoing iptables firewall rules. There is lot more to cover in IPTables. Stay tuned!
Previous articles in the iptables series:

lunes, 13 de agosto de 2012

Componentes Buena Página con características Eléctricas y Dimensiones

http://www.futurlec.com/LEDGen.shtml

The ELECTRONIC COMPONENTS Superstore

Por ejemplo puede encontrar desde LEDS hasta Integrados. Buena Para tener en cuenta cuando se hagan Diseños en Eagle.


LCDs

LCD Digital Displays

Features
• Clear Easy to Read Digits
• Low Power Consumption
• Works with ICL7106 or equivalent
• PCB Mounting

LCD Digit Display's

Part No. Description More
Info
In
Stock
Package
Qty.
Price
US$
Order
Qty.
Order
35LCD 3 1/2 Digit LCD Display Yes 1 $3.95
40LCD 4 Digit LCD Display Yes 1 $5.50
60LCD 6 Digit LCD Display   Yes 1 $6.50

Character LCD

Character LCD's

Features
• Standard Type
• Uses HD44780 Controller or Equivalent
• Works with almost any Microcontroller
• Great Value Pricing

Teoría de Máquinas de Estado (FSM)

Teoría de Máquinas de Estado (FSM)

La teoría de máquinas de estado es el nombre con el que se conocen los métodos deAnálisis y Diseño de Circuitos Secuenciales Sincrónicos. Esta lección constituye unaintroducción al tema del capítulo, donde se definirá lo que son las máquinas de estado y los conceptos básicos para entender la metodología de Análisis y Diseño de CircuitosSecuenciales.Las máquinas de estado son circuitos secuenciales que se encuentran constituidos poruna etapa combinacional y una etapa de memoria, relacionadas de tal forma queconforman un sistema secuencial para algún propósito especial. Los registros ycontadores con entradas asincrónicas son ejemplos de este tipo de sistemassecuenciales.
Máquinas de Estado de Mealy y Moore
 

Teoria Maquinas de Estado