<?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>gugaBSD &#187; Packet Filter</title>
	<atom:link href="http://www.luizgustavo.pro.br/blog/tag/packet-filter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.luizgustavo.pro.br/blog</link>
	<description>Software Livre, BSD e outras coisas mais...</description>
	<lastBuildDate>Fri, 13 Jan 2012 13:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Implementando segurança em Jail</title>
		<link>http://www.luizgustavo.pro.br/blog/2010/02/04/implementando-seguranca-em-jail/</link>
		<comments>http://www.luizgustavo.pro.br/blog/2010/02/04/implementando-seguranca-em-jail/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 19:02:16 +0000</pubDate>
		<dc:creator>luizgustavo</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[mundo BSD]]></category>
		<category><![CDATA[Jail]]></category>
		<category><![CDATA[Packet Filter]]></category>

		<guid isPermaLink="false">http://www.luizgustavo.pro.br/blog/?p=332</guid>
		<description><![CDATA[Este tutorial tem o intuito de orientar uma configuração de ambiente de Jail onde o trafego entre o mundo externo e as Jail&#8217;s sejam gerenciados pelo servidor principal (o qual provê as Jail&#8217;s) com o uso de uma interface virtual (tap). Toda a comunicação é gerenciada pelo firewall (no caso deste tutorial é o PF), [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail.png"><img class="alignleft size-full wp-image-333" title="freebsd_jail" src="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail.png" alt="" width="118" height="126" /></a>Este tutorial tem o intuito de orientar uma configuração de ambiente de Jail onde o trafego entre o mundo externo e as Jail&#8217;s sejam gerenciados pelo servidor principal (o qual provê as Jail&#8217;s) com o uso de uma interface virtual (tap).</p>
<p>Toda a comunicação é gerenciada pelo firewall (no caso deste tutorial é o PF), portanto, iremos isolar as maquinas Jail&#8217;s em uma especie de DMZ.<br />
<span id="more-332"></span></p>
<p>Vamos ao ambiente:</p>
<blockquote><p>Não vou entrar em detalhes de como configurar uma Jail, isto já tem documentação bem difundida e inclusive eu fiz um tutorial de como <a href="http://luizgustavo.pro.br/wiki/doku.php?id=artigos_freebsd:ezjail&amp;s[]=ezjail" target="_blank">gerenciar Jail usando o software Ezjail</a>.</p></blockquote>
<p>Temos um FreeBSD 7.2 &#8211; Stable com:</p>
<p><a href="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/ambiente_jail.png"><img class="aligncenter size-full wp-image-336" title="ambiente_jail" src="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/ambiente_jail.png" alt="" width="285" height="110" /></a></p>
<p>Vamos efetuar a configuração de uma interface virtual para comunicação com as Jail&#8217;s:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ifconfig</span> tap0 create
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> tap0 172.16.50.1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span></pre></div></div>

<p>Para tornar essa configuração permanente, use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'cloned_interfaces=&quot;tap0&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'ifconfig_tap0=&quot;inet 172.16.50.1 netmask 255.255.255.0&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf</pre></div></div>

<p>Dai, precisamos ainda criar um ip de alias na interface tap0 para criação de uma de nossas maquinas Jail:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ifconfig</span> tap0 <span style="color: #7a0874; font-weight: bold;">alias</span> 172.16.50.10<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'ifconfig_tap0_alias0=&quot;inet 172.16.50.10/32&quot;  # IP Jail Mail'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf</pre></div></div>

<p style="text-align: center;"><a href="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/ambiente_jail2.png"><img class="aligncenter size-full wp-image-338" title="ambiente_jail2" src="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/ambiente_jail2.png" alt="" width="501" height="194" /></a></p>
<p>Pronto, agora podemos fazer a criação de nossa Jail:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ezjail-admin create <span style="color: #660033;">-f</span> default mail-server.dominio.com.br 172.16.50.10</pre></div></div>

<p>Faça as devidas configurações em relação à sua Jail.</p>
<p>Agora vamos configurar o firewall para criar uma entrada/saida dessa Jail na internet.</p>
<p>Coloque no arquivo /etc/pf.conf o seguinte conteúdo:</p>

<div class="wp_syntax"><div class="code"><pre class="pf" style="font-family:monospace;">jail_mail-server<span style="color: #000000; font-weight: bold;">=</span><span style="color: #CC0000;">&quot;172.16.50.10&quot;</span>
nat_jail_mail-server<span style="color: #000000; font-weight: bold;">=</span><span style="color: #CC0000;">&quot;200.x.x.20&quot;</span>
<span style="color: #007800;">if_ext</span><span style="color: #000000; font-weight: bold;">=</span><span style="color: #CC0000;">&quot;fxp0&quot;</span>
<span style="color: #007800;">if_jail</span><span style="color: #000000; font-weight: bold;">=</span><span style="color: #CC0000;">&quot;tap0&quot;</span>
nat <span style="color: #7a0874;">on</span> <span style="color: #007800;">$if_ext</span> from <span style="color: #000099; font-weight: bold;">172.16.50.10</span> to any -<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$nat_jail_mail</span>-server
<span style="color: #009900; font-weight: bold;">pass</span> all</pre></div></div>

<p>A partir dai é usar sua imaginação/necessidade em gerir as regras de firewall, nesse ambiente a Jail irá ficar isolada em uma especie de DMZ gerenciada pelo firewall da maquina principal, você pode inclusive criar politicas de roteamento e/ou balanceamento entre as maquinas Jail&#8217;s através do PF.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.luizgustavo.pro.br/blog/2010/02/04/implementando-seguranca-em-jail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

