<?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; shorewall</title>
	<atom:link href="http://www.guero.net/tag/shorewall/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 4.4 en Ubuntu (con QoS, IFB, Nat)</title>
		<link>http://www.guero.net/2009/11/shorewall-4-4-en-ubuntu-con-qos-ifb-nat/</link>
		<comments>http://www.guero.net/2009/11/shorewall-4-4-en-ubuntu-con-qos-ifb-nat/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 11:52:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Sistemas y redes]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[qos]]></category>
		<category><![CDATA[shorewall]]></category>
		<category><![CDATA[shorewall 4.4]]></category>

		<guid isPermaLink="false">http://www.guero.net/?p=92</guid>
		<description><![CDATA[En el post anterior sobre shorewall 4.2 expliqué su instalación y configuración para una red básica. Ahora voy a documentar lo mismo pero con la última versión de shorewall 4.4. La nueva versión tiene cosas muy interesantes pero la que a mi más me interesó es el soporte de flow (&#8220;flow&#8221; traffic classifier, lo explicaré [...]]]></description>
			<content:encoded><![CDATA[<p>En el <a href="http://www.guero.net/2009/09/shorewall-en-ubuntu-firewall-qos-nat/">post anterior sobre shorewall 4.2</a> expliqué su instalación y configuración para una red básica. Ahora voy a documentar lo mismo pero con la última versión de <a href="http://www1.shorewall.net/pub/shorewall/4.4/shorewall-4.4.4/releasenotes.txt">shorewall 4.4</a>. La nueva versión tiene cosas muy interesantes pero la que a mi más me interesó es el soporte de flow (<a href="http://www.shorewall.net/traffic_shaping.htm#tcclasses">&#8220;flow&#8221; traffic classifier</a>, lo explicaré en otro post).</p>
<p><strong>Definición de la red</strong></p>
<blockquote><p><strong>eth1</strong>: Interfase para conexión a internet (ip dinámica)<br />
<strong>eth2</strong>: Interfase para la red local (192.168.8.0/24)</p></blockquote>
<p><strong>Hacemos una copia de la instalación anterior y eliminamos (si existe)</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: #c20cb9; font-weight: bold;">mkdir</span> shorewall.old <br />
<span style="color: #7a0874; font-weight: bold;">cd</span> shorewall.old<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shorewall<span style="color: #000000; font-weight: bold;">/*</span> .<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p><strong>Descargamos e Instalamos</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: #c20cb9; font-weight: bold;">mkdir</span> shorewall<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> shorewall<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>shorewall.de<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.4</span><span style="color: #000000; font-weight: bold;">/</span>shorewall-4.4.4<span style="color: #000000; font-weight: bold;">/</span>shorewall-4.4.4.1.tar.bz2<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> jxf shorewall-4.4.4.1.tar.bz2<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> shorewall-4.4.4.1<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> .<span style="color: #000000; font-weight: bold;">/</span>install.sh</div></div>
<p><strong>Documentación oficial</strong><br />
En toda instalación de un firewall hay particularidades, por lo que recomiendo leer la documentación oficial de shorewall. Iré poniendo links a la documentación oficial sobre cada acción.</p>
<p><em>[DOC] <strong><a href="http://www.shorewall.net/configuration_file_basics.htm">Sobre la estructura de los ficheros de configuración</a></strong></em></p>
<p><strong>Comandos necesarios para el arranque</strong>: /etc/shorewall/init</p>
<blockquote><p>Que cargue con el <a href="http://www.shorewall.net/traffic_shaping.htm#IFB">modulo de IFB</a>, creando solo un dispositivo que será ifb0.</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">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><strong>/etc/shorewall/interfaces</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;">#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><strong>/etc/shorewall/masq</strong><br />
<em>[DOC] <strong><a href="http://shorewall.net/Documentation.htm#Masq">NAT</a> &#8211; <a href="http://shorewall.net/NAT.htm">NAT2</a></strong></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;">#INTERFACE&nbsp; &nbsp; &nbsp; SOURCE&nbsp; &nbsp; &nbsp; ADDRESS &nbsp; &nbsp; PROTO &nbsp; PORT(S) IPSEC &nbsp; MARK</span><br />
eth1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 192.168.8.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span></div></div>
<p><strong>/etc/shorewall/zones</strong><br />
<em>[DOC] <strong><a href="http://www.shorewall.net/manpages/shorewall-zones.html">Zonas bajo control</a></strong></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; TYPE&nbsp; &nbsp; &nbsp; &nbsp; OPTIONS &nbsp; &nbsp; IN&nbsp; &nbsp; &nbsp; OUT</span><br />
fw&nbsp; firewall<br />
net ipv4<br />
loc ipv4</div></div>
<p><strong>/etc/shorewall/policy</strong><br />
<em>[DOC] <strong><a href="http://www.shorewall.net/manpages/shorewall-policy.html">Politica general</a></strong></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><strong>/etc/shorewall/rules</strong><br />
<em>[DOC] <strong><a href="http://www.shorewall.net/manpages/shorewall-rules.html">Reglas</a></strong></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;"># ACTION&nbsp; &nbsp; SOURCE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DEST&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PROTO &nbsp; &nbsp; &nbsp; DEST PORT(S)&nbsp; &nbsp; ORIGINAL DESTRATE LIMIT</span><br />
<span style="color: #666666; font-style: italic;"># Redirección de puertos</span><br />
DNAT&nbsp; &nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loc:192.168.8.78&nbsp; &nbsp; &nbsp; &nbsp; tcp &nbsp; &nbsp; <span style="color: #000000;">5900</span><br />
DNAT&nbsp; &nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loc:192.168.8.78&nbsp; &nbsp; &nbsp; &nbsp; tcp &nbsp; &nbsp; <span style="color: #000000;">8500</span>:<span style="color: #000000;">8600</span><br />
DNAT&nbsp; &nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loc:192.168.8.78&nbsp; &nbsp; &nbsp; &nbsp; udp &nbsp; &nbsp; <span style="color: #000000;">8500</span>:<span style="color: #000000;">8600</span><br />
<span style="color: #666666; font-style: italic;"># FROM Net TO firewall</span><br />
ACCEPT&nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">$FW</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icmp&nbsp; &nbsp; &nbsp; &nbsp; <br />
ACCEPT&nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">$FW</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp &nbsp; &nbsp; <span style="color: #000000;">22</span></div></div>
<p><strong>* Hasta aquí es lo básico en cuando a seguridad y NAT, con esto la red ya funciona. A partir de aquí es <a href="http://www.shorewall.net/traffic_shaping.htm">QoS o Traffic Shaping</a>.</strong></p>
<p><strong>/etc/shorewall/tcdevices</strong><br />
<em>[DOC] <strong><a href="http://www.shorewall.net/traffic_shaping.htm#tcdevices">Devices</a> &#8211; <a href="http://www.shorewall.net/traffic_shaping.htm#IFB">Redirigir el tráfico a IFB</a></strong></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;">#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; 300kbit &nbsp; &nbsp; classify&nbsp; &nbsp; <br />
<span style="color: #000000;">2</span>:ifb0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; 6000kbit&nbsp; &nbsp; &nbsp; &nbsp; classify&nbsp; &nbsp; eth1</div></div>
<p><strong>/etc/shorewall/tcclasses</strong><br />
<em>[DOC] <strong><a href="http://www.shorewall.net/traffic_shaping.htm#tcclasses">Clases</a></strong></em></p>
<blockquote><p>
Ahora es donde voy a dar mi opinion sobre como deberían ir estas clases, esto depende de la experiencia de cada uno, pero en fin, esta es la mía: </p>
<ul>
<li>Dividir en tres partes VoIP y Video IP (1:10 y 2:10) , ICMP/DNS y puertos conocidos (1:11 y 2:11) y por último tráfico desconocido (1:19 y 2:19)</li>
<li>Antes le daba mayor prioridad a SSH o ICMP y en mantenimientos he cortado llamadas y en alguna prueba de rendimiento también me quede sin teléfonos (que también puede ser un ataque DDoS u otros..)</li>
<li>La segunda clase sera para icmp y dns y tráfico conocido, y esta esta dividida en subclases con el fin de garantizar un mínimo a cada conexión</li>
<li>En mi red tengo un servidor DNS para que los equipos no vayan a buscar cada dominio en internet, de modo que al DNS le doy más prioridad que al trafico en si mismo ya que se realiza pocas veces y agiliza la navegación</li>
<li>Y ya que tengo servicios dentro de la red que son utilizados en ocasiones desde fuera de ella considero que se aplican los mismos principios para el trafico entrante</li>
<li>Sobre los porcentajes que he utilizado en este ejemplo es por el ancho de banda que tengo en esa instalación, esto cada uno lo tiene que mirar pero yo he intentado garantizar 128kbit a la voip tanto de subida como de bajada</li>
<li>Lo de enviar el tráfico desconocido a la última clase es para evitar el esfuerzo y la complicación de identificar las conexiones P2P, hay otras técnicas pero al final después de muchas pruebas esto es lo que me ha resultado más fácil de mantener</li>
</ul>
</blockquote>
<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:CLASS&nbsp; &nbsp; MARK&nbsp; &nbsp; RATE: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CEIL&nbsp; &nbsp; &nbsp; &nbsp; PRIORITY&nbsp; &nbsp; OPTIONS</span><br />
<span style="color: #666666; font-style: italic;">##&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DMAX:UMAX</span><br />
<span style="color: #666666; font-style: italic;"># #</span><br />
<span style="color: #666666; font-style: italic;"># # eth1</span><br />
<span style="color: #666666; font-style: italic;"># #</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">10</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">43</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> &nbsp; &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; tcp-ack,tos-minimize-delay <span style="color: #666666; font-style: italic;"># voip</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">47</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> &nbsp; &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">2</span> &nbsp; tcp-ack,tos-minimize-delay <span style="color: #666666; font-style: italic;"># icmp / dns</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">101</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">11</span>&nbsp; <span style="color: #666666; font-style: italic;"># openvpn</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">102</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">12</span>&nbsp; <span style="color: #666666; font-style: italic;"># vnc</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">103</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">13</span>&nbsp; <span style="color: #666666; font-style: italic;"># http/https</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">104</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">14</span>&nbsp; <span style="color: #666666; font-style: italic;"># mail</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">105</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">15</span>&nbsp; <span style="color: #666666; font-style: italic;"># irc,msn,...</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">19</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> &nbsp; &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">99</span>&nbsp; tos-minimize-cost,default<br />
<span style="color: #666666; font-style: italic;"># #</span><br />
<span style="color: #666666; font-style: italic;"># # ifb0</span><br />
<span style="color: #666666; font-style: italic;"># #</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">10</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span>&nbsp; &nbsp; &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; tcp-ack,tos-minimize-delay <span style="color: #666666; font-style: italic;"># voip</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">87</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> &nbsp; &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">2</span> &nbsp; tcp-ack,tos-minimize-delay <span style="color: #666666; font-style: italic;"># icmp / dns</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">101</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">11</span>&nbsp; <span style="color: #666666; font-style: italic;"># openvpn</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">102</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">12</span>&nbsp; <span style="color: #666666; font-style: italic;"># vnc</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">103</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">13</span>&nbsp; <span style="color: #666666; font-style: italic;"># http/https</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">104</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">14</span>&nbsp; <span style="color: #666666; font-style: italic;"># mail</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>:<span style="color: #000000;">105</span>&nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; &nbsp; &nbsp; full&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">15</span>&nbsp; <span style="color: #666666; font-style: italic;"># irc,msn,...</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">19</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> &nbsp; &nbsp; full<span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> &nbsp; <span style="color: #000000;">99</span>&nbsp; tos-minimize-cost,default</div></div>
<p><strong>/etc/shorewall/tcfilters</strong><br />
<em>[DOC] <strong><a href="http://www.shorewall.net/traffic_shaping.htm#tcfilters">Filtros para identificar el tráfico</a></strong></em></p>
<blockquote><p>Yo he identificado estos puertos como útiles para mi red, como decía antes, cada uno sabrá lo que le es útil y lo que no.</p></blockquote>
<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;">10</span>&nbsp; &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;">4569</span>,<span style="color: #000000;">5060</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">10</span>&nbsp; &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;">4569</span>,<span style="color: #000000;">5060</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icmp&nbsp; &nbsp; echo-request,echo-reply<br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>&nbsp; &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;">53</span>,<span style="color: #000000;">22</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">11</span>&nbsp; &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;">101</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;">101</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;">102</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;">5900</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">103</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;">104</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;">25</span>,<span style="color: #000000;">465</span>,<span style="color: #000000;">110</span>,<span style="color: #000000;">995</span>,<span style="color: #000000;">143</span>,<span style="color: #000000;">993</span><br />
<span style="color: #000000;">1</span>:<span style="color: #000000;">105</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;">1493</span>,<span style="color: #000000;">1542</span>,<span style="color: #000000;">1863</span>,<span style="color: #000000;">1963</span>,<span style="color: #000000;">5222</span>,<span style="color: #000000;">6667</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; INCOMING TRAFFIC</span><br />
<span style="color: #666666; font-style: italic;"># #</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">10</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; udp <span style="color: #000000;">4569</span>,<span style="color: #000000;">5060</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">10</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">4569</span>,<span style="color: #000000;">5060</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icmp&nbsp; &nbsp; echo-request,echo-reply<br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>&nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">53</span>,<span style="color: #000000;">22</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">11</span>&nbsp; &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;">101</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;">101</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;">102</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">5900</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">103</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;">104</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">25</span>,<span style="color: #000000;">465</span>,<span style="color: #000000;">110</span>,<span style="color: #000000;">995</span>,<span style="color: #000000;">143</span>,<span style="color: #000000;">993</span><br />
<span style="color: #000000;">2</span>:<span style="color: #000000;">105</span> &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp <span style="color: #000000;">1493</span>,<span style="color: #000000;">1542</span>,<span style="color: #000000;">1863</span>,<span style="color: #000000;">1963</span>,<span style="color: #000000;">5222</span>,<span style="color: #000000;">6667</span></div></div>
<p><strong>Esto es todo, ahora compilamos:</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: #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 restart</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.guero.net/2009/11/shorewall-4-4-en-ubuntu-con-qos-ifb-nat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
