<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sin ambición &#187; iptables</title>
	<atom:link href="http://www.guero.net/tag/iptables/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guero.net</link>
	<description>Detalles técnicos del mundo del desarrollo web y sistemas, proyectos y opinión.</description>
	<lastBuildDate>Wed, 05 May 2010 10:01:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Shorewall en Ubuntu &#124; firewall, QoS, NAT</title>
		<link>http://www.guero.net/2009/09/shorewall-en-ubuntu-firewall-qos-nat/</link>
		<comments>http://www.guero.net/2009/09/shorewall-en-ubuntu-firewall-qos-nat/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 16:44:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sistemas y redes]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ifb]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[qos]]></category>
		<category><![CDATA[shorewall]]></category>

		<guid isPermaLink="false">http://www.guero.net/?p=62</guid>
		<description><![CDATA[ACTUALIZACIÓN: Instalación muy similar pero en shorewall 4.4 He realizado unas cuantas instalaciones de shorewall 4.2 en ubuntu server 8.04-LTS y están funcionando muy bien, lo recomiendo. Aún no he probado la última versión de shorewall 4.4 pero cuando lo haga lo publicaré. Tras un par de intentos fallidos de utilizar los repositorios PPA de [...]]]></description>
			<content:encoded><![CDATA[<p>ACTUALIZACIÓN: <a title="Shorewall 4.4, QoS, Ubuntu" href="http://www.guero.net/2009/11/shorewall-4-4-en-ubuntu-con-qos-ifb-nat/">Instalación muy similar pero en shorewall 4.4</a></p>
<p>He realizado unas cuantas instalaciones de <a title="Is high-level tool for configuring Netfilter" href="http://www.shorewall.net/" target="_blank">shorewall</a> 4.2 en ubuntu server 8.04-LTS y están funcionando muy bien, lo recomiendo. Aún no he probado la última versión de shorewall 4.4 pero cuando lo haga lo publicaré. Tras un par de intentos fallidos de utilizar los repositorios <a href="https://launchpad.net/~bmonty/+archive/ppa" target="_blank">PPA de Ubuntu</a> creo que es mejor <strong>no utilizarlos</strong>, instalar el paquete es muy fácil y no requiere demasiadas actualizaciones.</p>
<p>El objetivo de una instalación de este tipo es mantener una buena calidad de conexión para todos los equipos en una red local, para evitar que ninguno de los ordenadores acapare la conexión (ni con p2p, http, ftp,&#8230;). En definitiva, QoS (Quality of services).</p>
<p>Antes de que alguien me meta caña por lo que voy a decir, puntualizo que esto es para una red de ordenadores, no para servidores. Si alguien quiere montar un firewall con QoS para servidores debe tomar en cuenta otras cosas como ataques DDoS, flush control, etc.. etc.. largo etc..</p>
<p><span id="more-62"></span></p>
<p>Instalar Ubuntu Server 8.04 (o el LTS del momento)</p>
<p>En la instalación solo hace falta OpenSSH (ni escritorio, ni apache, ni nada..)</p>
<p><strong>* Definición de la red</strong></p>
<p><strong>eth1</strong> Tarjeta ethernet que va a internet<br />
<strong>eth2</strong> Tarjeta ethernet que va al switch de la red local</p>
<p><strong>* A partir veremos lo que es la instalación</strong></p>
<p>Una vez instalado descargamos <a href="http://slovakia.shorewall.net/pub/shorewall/4.2/shorewall-4.2.11/shorewall-common-4.2.11.tar.bz2">shorewall-comon</a> y <a href="http://slovakia.shorewall.net/pub/shorewall/4.2/shorewall-4.2.11/shorewall-perl-4.2.11.1.tar.bz2">shorewall-perl</a></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>slovakia.shorewall.net<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>shorewall<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4.2</span><span style="color: #000000; font-weight: bold;">/</span>shorewall-4.2.11<span style="color: #000000; font-weight: bold;">/</span>shorewall-perl-4.2.11.1.tar.bz2<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>slovakia.shorewall.net<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>shorewall<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4.2</span><span style="color: #000000; font-weight: bold;">/</span>shorewall-4.2.11<span style="color: #000000; font-weight: bold;">/</span>shorewall-common-4.2.11.tar.bz2</div></div>
<p>Descomprimimos</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">tar</span> jxvf shorewall-perl-4.2.11.1.tar.bz2<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> jxvf shorewall-common-4.2.11.tar.bz2</div></div>
<p>Instalamos shorewall-perl</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> shorewall-perl-4.2.11.1<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> .<span style="color: #000000; font-weight: bold;">/</span>install.sh<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> ..</div></div>
<p>Instalamos shorewall-common</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> shorewall-common-4.2.11<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> .<span style="color: #000000; font-weight: bold;">/</span>install.sh<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> ..</div></div>
<p>Editamos /etc/default/shorewall y cambiamos una variable de 0 a 1.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">startup</span>=<span style="color: #000000;">1</span></div></div>
<p>Copiamos el fichero para que se ejecute al inciar el sistema y lo definimos en el arranque</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>shorewall<span style="color: #000000; font-weight: bold;">/</span>init <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>shorewall<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> update-rc.d shorewall defaults</div></div>
<p><strong>* A partir veremos lo que es la configuración básica del firewall</strong></p>
<p>Editamos <strong>/etc/shorewall/init</strong><br />
<em>Con esto lo que hacemos es decir a shorewall que inicie el modulo ifb, lenbante la interface y cree un directorio donde pondrá el -PID- de shorewall</em></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">qt modprobe ifb <span style="color: #007800;">numifbs</span>=<span style="color: #000000;">1</span><br />
qt ip <span style="color: #c20cb9; font-weight: bold;">link</span> <span style="color: #000000; font-weight: bold;">set</span> dev ifb0 up<br />
qt <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>Ahora definimos las interfaces y sus funciones<br />
Editamos <strong>/etc/shorewall/init</strong><br />
<em>En este caso tenemos <strong>eth1 para internet</strong> y <strong>eth2 para la red local</strong>. En el caso de la red local yo utilizo un servidor de DHCP, que está en el mismo servidor donde instalo shorewall</em></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#ZONE &nbsp; &nbsp; &nbsp; INTERFACE &nbsp; BROADCAST &nbsp; OPTIONS</span><br />
net &nbsp; &nbsp; eth1<br />
loc &nbsp; &nbsp; eth2&nbsp; &nbsp; &nbsp; &nbsp; detect&nbsp; &nbsp; &nbsp; dhcp</div></div>
<p>Definimos las <strong>zonas</strong>.<br />
Editamos <strong>/etc/shorewall/zones</strong></p>
<blockquote><p>Aquí tenemos un tema de conceptos:<br />
<strong>fw</strong> se refiere al mismo servidor, al mismo firewall<br />
<strong>net</strong> se refiere a internet, las conexiones desde fuera que NO la interface de conexión con internet<br />
<strong>loc</strong> se refiere a la red local</p></blockquote>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#ZONE &nbsp; TYPE&nbsp; &nbsp; &nbsp; &nbsp; OPTIONS &nbsp; &nbsp; IN&nbsp; &nbsp; &nbsp; OUT</span><br />
fw&nbsp; firewall<br />
net ipv4<br />
loc ipv4<br />
<span style="color: #666666; font-style: italic;">#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE</span></div></div>
<p>Activamos la función de masquerading, es decir NAT (sería DNAT).<br />
Editamos <strong>/etc/shorewall/masq</strong></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#INTERFACE&nbsp; SOURCE&nbsp; &nbsp; &nbsp; ADDRESS &nbsp; &nbsp; PROTO &nbsp; PORT(S)</span><br />
eth1&nbsp; &nbsp; &nbsp; &nbsp; eth2</div></div>
<p>Ahora definimos las reglas generales por las que va a funcionar este firewall.<br />
Editamos <strong>/etc/shorewall/policy</strong><br />
<em>Aquí le diremos que todos las conexiones de la red local pueden ir a internet o bien lo contrario. En este caso es una red local con libre acceso a internet, pero no podrá entrar ninguna conexión desde internet. El mismo tiempo le decimos que las conexiones de internet en dirección al firewall no serán aceptadas pero si las de la red local.</em></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#SOURCE &nbsp; &nbsp; DEST&nbsp; &nbsp; &nbsp; &nbsp; POLICY&nbsp; &nbsp; &nbsp; LOG LEVEL &nbsp; LIMIT:BURST</span><br />
loc &nbsp; &nbsp; net &nbsp; &nbsp; ACCEPT<br />
loc &nbsp; &nbsp; <span style="color: #007800;">$FW</span> &nbsp; &nbsp; ACCEPT<br />
<span style="color: #007800;">$FW</span> &nbsp; &nbsp; loc &nbsp; &nbsp; ACCEPT<br />
<span style="color: #007800;">$FW</span> &nbsp; &nbsp; net &nbsp; &nbsp; ACCEPT<br />
all &nbsp; &nbsp; all &nbsp; &nbsp; REJECT&nbsp; &nbsp; &nbsp; info</div></div>
<p>Activamos la función de masquerading, es decir NAT (sería DNAT).<br />
Editamos <strong>/etc/shorewall/masq</strong></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#INTERFACE&nbsp; SOURCE&nbsp; &nbsp; &nbsp; ADDRESS &nbsp; &nbsp; PROTO &nbsp; PORT(S)</span><br />
eth1&nbsp; &nbsp; &nbsp; &nbsp; eth2</div></div>
<p><strong>* A partir de aquí empieza todo lo referente a QoS</strong></p>
<p>Definimos las interfaces que estarán en las reglas de QoS.<br />
Editamos <strong>/etc/shorewall/tcdevices</strong><br />
<em>En este caso tenemos 350kbit de subida y 6000kbit de bajada</em></p>
<blockquote><p>Aquí esta todo en OUT-BANDWIDTH porque lo que hacemos realmente es redirigir todo el tráfico entrante de eth1 ha ifb0 para que esta pueda rechazar paquetes simulando que no tiene ancho de banda suficiente. Esto no se puede hacer directamente sin ifb ya que no podemos decir al driver de la tarjeta que rechace determinados paquetes.</p></blockquote>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#NUMBER:&nbsp; &nbsp; IN-BANDWITH OUT-BANDWIDTH &nbsp; OPTIONS &nbsp; &nbsp; REDIRECTED</span><br />
<span style="color: #666666; font-style: italic;">#INTERFACE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INTERFACES</span><br />
<span style="color: #000000;">1</span>:eth1&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; 350kbit &nbsp; &nbsp; classify<br />
<span style="color: #000000;">2</span>:ifb0&nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; 6000kbit&nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; eth1<br />
<span style="color: #666666; font-style: italic;">#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</span></div></div>
<p>Definimos las <strong>class</strong> para la red.<br />
Editamos <strong>/etc/shorewall/tcclasses</strong></p>
<blockquote><p>Las clases son colas, igual que al llegar a aduanas. Una cola para personas del mismo país, otra para extranjeros, etc.. etc.. Pero al tratarse de una red lo que encolamos son paquetes. Con otro archivo diremos en que cola debe entrar cada tipo de conexión pero en este creamos los niveles. (<a href="http://shorewall.net/traffic_shaping.htm">más info</a>)</p></blockquote>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#INTERFACE:CLASS&nbsp; &nbsp; MARK&nbsp; &nbsp; RATE&nbsp; &nbsp; &nbsp; &nbsp; CEIL&nbsp; &nbsp; &nbsp; &nbsp; PRIORITY&nbsp; &nbsp; OPTIONS</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">110</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp; tcp-ack,tos-minimize-delay<br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">2</span> &nbsp; &nbsp; &nbsp; tos-minimize-delay<br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">120</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">8</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">3</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">130</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">4</span> &nbsp; &nbsp; &nbsp; default<br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">140</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">5</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">110</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp; tcp-ack,tos-minimize-delay<br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">2</span> &nbsp; &nbsp; &nbsp; tos-minimize-delay<br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">120</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">8</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">3</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">130</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">4</span> &nbsp; &nbsp; &nbsp; default<br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">140</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">*</span>full<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">5</span><br />
<span style="color: #666666; font-style: italic;">#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</span></div></div>
<p>Ahora definimos que paquetes van por cada class.<br />
Editamos <strong>/etc/shorewall/tcfilters</strong><br />
<em>El tráfico más importante es el de icmp para establecer las conexiones, luego los puertos de mantenimiento como SSH (DNS también está en esta clase para que no tarde en buscar el host cada solicitud), luego puertos más utilizados para la red local (web, mail, etc..) y todo lo que no coincida con lo anterior lo mandaremos a la última class, la de menos peso.</em></p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#INTERFACE: SOURCE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DEST&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PROTO &nbsp; DEST&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SOURCE</span><br />
<span style="color: #666666; font-style: italic;">#CLASS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PORT(S) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PORT(S)</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OUTGOING TRAFFIC</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">120</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">80</span>,<span style="color: #000000;">443</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; udp - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1194</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1194</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">ssh</span>,<span style="color: #000000;">53</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; udp - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">53</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">110</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icmp&nbsp; &nbsp; echo-request,echo-reply<br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INCOMING TRAFFIC</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">120</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">80</span>,<span style="color: #000000;">443</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; udp <span style="color: #000000;">1194</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">1194</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #c20cb9; font-weight: bold;">ssh</span>,<span style="color: #000000;">53</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">111</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; udp <span style="color: #000000;">53</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">110</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icmp&nbsp; &nbsp; echo-request,echo-reply<br />
<span style="color: #666666; font-style: italic;">#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</span></div></div>
<p>Y listo, ejecutamos y a probar:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>shorewall start</div></div>
<p>ACTUALIZACIÓN (13/Oct/2009): Me equivoqué en la edición de &#8216;/etc/shorewall/tcfilters&#8217;, como está ahora mismo es la versión correcta.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guero.net/2009/09/shorewall-en-ubuntu-firewall-qos-nat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
