<?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; Jail</title>
	<atom:link href="http://www.luizgustavo.pro.br/blog/tag/jail/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>Jail rápido e fácil no FreeBSD9</title>
		<link>http://www.luizgustavo.pro.br/blog/2011/12/01/jail-rapido-e-facil-no-freebsd9/</link>
		<comments>http://www.luizgustavo.pro.br/blog/2011/12/01/jail-rapido-e-facil-no-freebsd9/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 21:05:02 +0000</pubDate>
		<dc:creator>luizgustavo</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[FreeBSD9]]></category>
		<category><![CDATA[Jail]]></category>

		<guid isPermaLink="false">http://www.luizgustavo.pro.br/blog/?p=659</guid>
		<description><![CDATA[Neste artigo &#8220;jogo rápido&#8221;, irei mostrar os comandos necessários para criar uma Jail no FreeBSD 9 (RC3) usando os binários de instalação do FreeBSD. Para isso, comece pelo o download do arquivo &#8220;base&#8221; a partir de um FTP, como no exemplo abaixo: Você também pode usar o arquivo encontrado no cd de instalação cd /tmp [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail.png"><img class="alignright 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="168" height="177" /></a>Neste artigo &#8220;jogo rápido&#8221;, irei mostrar os comandos necessários para criar uma Jail no FreeBSD 9 (RC3) usando os binários de instalação do FreeBSD.</p>
<p>Para isso, comece pelo o download do arquivo &#8220;base&#8221; a partir de um FTP, como no exemplo abaixo:</p>
<blockquote><p><em>Você também pode usar o arquivo encontrado no cd de instalação</em></p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
fetch <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>ftp3.br.freebsd.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>FreeBSD<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>amd64<span style="color: #000000; font-weight: bold;">/</span>amd64<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9.0</span>-RC3<span style="color: #000000; font-weight: bold;">/</span>base.txz</pre></div></div>

<p>Feito isso, basta criar o ambiente da Jail, como no exemplo abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>jails<span style="color: #000000; font-weight: bold;">/</span>jail-dev
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>jails<span style="color: #000000; font-weight: bold;">/</span>jail-dev
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--unlink</span> <span style="color: #660033;">-xpJvf</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>base.txz</pre></div></div>

<p>Configure alguns parâmetros na jail através de chroot na jail:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chroot</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>jails<span style="color: #000000; font-weight: bold;">/</span>jail-dev <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">csh</span>
<span style="color: #666666; font-style: italic;"># configure senha de root</span>
<span style="color: #c20cb9; font-weight: bold;">passwd</span>
<span style="color: #666666; font-style: italic;"># adicione um usuario</span>
pw add user admin <span style="color: #660033;">-m</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">csh</span> <span style="color: #660033;">-G</span> wheel
<span style="color: #c20cb9; font-weight: bold;">passwd</span> admin
<span style="color: #666666; font-style: italic;"># configure o rc.conf</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'rpcbind_enable=&quot;NO&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;">'network_interfaces=&quot;&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: #666666; font-style: italic;"># crie um fstab vazio para evitar mensagens de erro</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>fstab
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>Pronto, a Jail já esta funcional.</p>
<p>Configure-a conforme o exemplo abaixo no arquivo /etc/rc.conf:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">jail_enable=&quot;YES&quot;
jail_list=&quot;jaildev&quot;
jail_jaildev_rootdir=&quot;/usr/jails/jail-dev&quot;
jail_jaildev_hostname=&quot;jail-dev.mundounix.com.br&quot;
jail_jaildev_interface=&quot;bge0&quot;
jail_jaildev_ip=&quot;192.168.83.100&quot;
jail_jaildev_exec_start=&quot;/bin/sh /etc/rc&quot;
jail_jaildev_exec_stop=&quot;/bin/sh /etc/rc.shutdown&quot;
jail_jaildev_devfs_enable=&quot;YES&quot;</pre></td></tr></table></div>

<p>Dai, é inicia-la com o comando:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>jail start jaildev</pre></div></div>

<p>E divirta-se !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.luizgustavo.pro.br/blog/2011/12/01/jail-rapido-e-facil-no-freebsd9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brincando com vnet em Jail no FreeBSD</title>
		<link>http://www.luizgustavo.pro.br/blog/2010/07/29/brincando-com-vnet-em-jail-no-freebsd/</link>
		<comments>http://www.luizgustavo.pro.br/blog/2010/07/29/brincando-com-vnet-em-jail-no-freebsd/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 09:11:16 +0000</pubDate>
		<dc:creator>luizgustavo</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Jail]]></category>
		<category><![CDATA[vnet]]></category>

		<guid isPermaLink="false">http://www.luizgustavo.pro.br/blog/?p=592</guid>
		<description><![CDATA[Este tutorial é uma serie de dicas e comando para gerenciar Jails com o novo esquema de emulação de rede que ainda esta experimental no FreeBSD. Mas já é possível usar as features que o mesmo oferece e criar um ambiente totalmente personalizado com firewall e ferramentas de diagnósticos de rede dentro de uma jail. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail.png"><img class="alignright size-thumbnail wp-image-333" title="freebsd_jail" src="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail-150x150.png" alt="" width="80" height="80" /></a>Este tutorial é uma serie de dicas e comando para gerenciar Jails com o novo esquema de emulação de rede que ainda esta experimental no FreeBSD. Mas já é possível usar as features que o mesmo oferece e criar um ambiente totalmente personalizado com firewall e ferramentas de diagnósticos de rede dentro de uma jail.</p>
<p style="text-align: justify;">Uma ótima definição sobre Jail esta disponível no Wikipedia no endereço:<br />
<a href="http://pt.wikipedia.org/wiki/FreeBSD_jail" target="_blank">http://pt.wikipedia.org/wiki/FreeBSD_jail</a></p>
<p style="text-align: justify;">Para iniciar-mos o tutorial, precisamos como pre-requisito que você conheça como recompilar o kernel do FreeBSD, tarefa ao qual existem bons documentos disponíveis, a começar pelo o <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/" target="_blank">Handbook</a>.</p>
<p><span id="more-592"></span>No kernel precisaremos das seguintes entradas no arquivo de configuração:</p>
<pre>options LIBALIAS
options IPFIREWALL
options IPFIREWALL_NAT
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT

options DUMMYNET
options HZ=1000

options VIMAGE</pre>
<p>Assim que configurar o kernel, faca a recompilação do mesmo e reinicie o servidor.</p>
<p style="text-align: justify;">No exemplo que estou citando aqui, estou usando um FreeBSD 8.1-RELEASE, para o mesmo eu apenas recompilei o kernel com as opções acima, fica ao seu critério configurar o FreeBSD, o importante que as opções citadas acima possam estar disponíveis no kernel.</p>
<p style="text-align: justify;">Feito isso, podemos iniciar a configuração do FreeBSD, para agilizar a visualização do mesmo, eu preparei um vídeo com as alterações. Abaixo do vídeo deixei disponível os comandos para que possam ser anotadas com mais facilidade.</p>
<p><script type='text/javascript' src='http://www.luizgustavo.pro.br/blog/wp-content/plugins/hana-flv-player/flowplayer3/example/flowplayer-3.2.6.min.js'></script>
<div >
<div id='hana_flv_flow3_1' style='display:block;width:540px;height:300px;' title=""></div>
</div>

			<script  type='text/javascript'>
		flowplayer('hana_flv_flow3_1', { src: 'http://www.luizgustavo.pro.br/blog/wp-content/plugins/hana-flv-player/flowplayer3/flowplayer-3.2.7.swf', wmode: 'transparent' }, { 

    		clip:  { 
    			url: 'http://luizgustavo.pro.br/videos/jail.flv',
        		scaling: 'scale', autoPlay: false, autoBuffering: false 
				   , onFinish : function () { this.seek(0); } 
	        }

		}); 
			</script></p>
<p>Utilizando ZFS, vamos criar o ambiente da Jail</p>
<pre>zfs create tank/jails
zfs set mountpoint=/usr/jails tank/jails
zfs create tank/jails/jail_teste</pre>
<p>Se voce executou um &#8220;make world&#8221; no seu sistema, muito provavelmente você tem os binários disponíveis no diretório &#8220;/usr/src&#8221;, então, use-o para criar o ambiente da Jail:</p>
<pre>cd /usr/src
make installworld distribution DESTDIR=/usr/jails/jail_teste</pre>
<p>Senão, configure a Jail usando o utilitário sysinstall conforme mostra o vídeo.</p>
<p>Vamos iniciar a Jail e configurar a rede:</p>
<pre>mount -t devfs devfs /usr/jails/centreon/dev
jail -c vnet host.hostname=jail_test.server path=/usr/jails/jail_teste persist
ifconfig bridge0 create
ifconfig epair create
ifconfig bridge0 addm em0 addm epair0a up   # sendo em0 sua interface de rede real
ifconfig epair0a up
jls
 JID  IP Address      Hostname                      Path
 1  -               jail_teste.server               /usr/jails/jail_teste
ifconfig epair0b vnet 1</pre>
<p>Agora precisamos entrar na Jail e configura-la:</p>
<pre>jexec 1 /bin/csh

Configure a loopback:
# ifconfig lo0 127.0.0.1/8 up

Configure o ip na interface:
# ifconfig epair0b 192.168.4.231/24 up
# route add default 192.168.4.3
add net default: gateway 192.168.4.3
# echo 'nameserver 8.8.8.8' &gt; /etc/resolv.conf

# Teste a conectividade...
# ping google.com
PING google.com (64.233.163.104): 56 data bytes
64 bytes from 64.233.163.104: icmp_seq=0 ttl=55 time=16.151 ms
64 bytes from 64.233.163.104: icmp_seq=1 ttl=55 time=18.904 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 16.151/17.527/18.904/1.377 ms</pre>
<p>É isso&#8230; agora basta trabalhar dentro da sua Jail conforme um FreeBSD normal e usando os recursos de rede mais facilmente.</p>
<p>Abraços</p>
]]></content:encoded>
			<wfw:commentRss>http://www.luizgustavo.pro.br/blog/2010/07/29/brincando-com-vnet-em-jail-no-freebsd/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://luizgustavo.pro.br/videos/jail.flv" length="21666168" type="video/x-flv" />
		</item>
		<item>
		<title>Fundação FreeBSD anuncia patrocionio para o projeto JAIL</title>
		<link>http://www.luizgustavo.pro.br/blog/2010/06/17/fundacao-freebsd-anuncia-patrocionio-para-o-projeto-jail/</link>
		<comments>http://www.luizgustavo.pro.br/blog/2010/06/17/fundacao-freebsd-anuncia-patrocionio-para-o-projeto-jail/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 18:21:35 +0000</pubDate>
		<dc:creator>luizgustavo</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Fundação FreeBSD]]></category>
		<category><![CDATA[Jail]]></category>

		<guid isPermaLink="false">http://www.luizgustavo.pro.br/blog/?p=568</guid>
		<description><![CDATA[No dia 10 de Junho, a fundação FreeBSD anunciou através de mensagem na lista publica announce@freebsd.org a concessão de bolsa para financiar o trabalho de Bjoern A. Zeeb no desenvolvimento do projeto de virtualização de Jail no FreeBSD. A ideia é que em conjunto com a empresa onde Bjoern trabalha, seja negociado horas para que [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail.png"><img class="alignright size-thumbnail wp-image-333" style="margin: 5px;" title="freebsd_jail" src="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail-150x150.png" alt="" width="98" height="98" /></a>No dia 10 de Junho, a fundação FreeBSD anunciou através de mensagem na lista publica announce@freebsd.org a concessão de bolsa para financiar o trabalho de Bjoern A. Zeeb no desenvolvimento do projeto de virtualização de Jail no FreeBSD.</p>
<p style="text-align: justify;">A ideia é que em conjunto com a empresa onde Bjoern trabalha, seja negociado horas para que o mesmo dedique trabalhar na limpeza do código e na implementação de novas features. Esperamos em breve ( e já temos até uma data para que alguma coisa seja apresentada: meados de Julho deste ano) que tudo de certo e o esquema de uso de Jail no FreeBSD fique ainda melhor. Há uma previsão de que todas as alterações no projeto entre em produção na familia 9.x do FreeBSD.</p>
<p>Veja mais detalhes no anuncio oficial no seguinte endereço:<br />
<a href="http://lists.freebsd.org/pipermail/freebsd-announce/2010-June/001327.html" target="_blank">http://lists.freebsd.org/pipermail/freebsd-announce/2010-June/001327.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.luizgustavo.pro.br/blog/2010/06/17/fundacao-freebsd-anuncia-patrocionio-para-o-projeto-jail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jails no FreeBSD: Rápido e Fácil</title>
		<link>http://www.luizgustavo.pro.br/blog/2010/05/30/jails-no-freebsd-rapido-e-facil/</link>
		<comments>http://www.luizgustavo.pro.br/blog/2010/05/30/jails-no-freebsd-rapido-e-facil/#comments</comments>
		<pubDate>Mon, 31 May 2010 01:40:11 +0000</pubDate>
		<dc:creator>luizgustavo</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Jail]]></category>

		<guid isPermaLink="false">http://www.luizgustavo.pro.br/blog/?p=544</guid>
		<description><![CDATA[Vamos lá, bem rapidinho&#8230; Qual é a ideia ? Mostrar como é facil criar uma jail no FreeBSD sem stress de recompilação de kernel, etc&#8230;. Para a criação da Jail, vamos usar o sysinstall para criar o ambiente root dela, assim: Antes de mais nada, não esquecer de deixar o seu sistema atualizadinho, então, vale [...]]]></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" style="border: 0pt none; margin: 5px;" title="freebsd_jail" src="http://www.luizgustavo.pro.br/blog/wp-content/uploads/2010/02/freebsd_jail.png" alt="" width="77" height="82" /></a>Vamos lá, bem rapidinho&#8230; Qual é a ideia ? Mostrar como é facil criar uma jail no FreeBSD sem stress de recompilação de kernel, etc&#8230;.</p>
<p>Para a criação da Jail, vamos usar o sysinstall para criar o ambiente root dela, assim:</p>
<p>Antes de mais nada, não esquecer de deixar o seu sistema atualizadinho, então, vale lembrar dos comandos:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># freebsd-update</span>
<span style="color: #666666; font-style: italic;"># portsnap fetch update</span></pre></div></div>

<p>Supondo que você vá guardar suas jails em <strong>&#8220;/usr/jails&#8221;</strong>, vamos criar uma chamada <strong>&#8220;dns&#8221;</strong></p>
<pre>mkdir -p /usr/jails/dns
</pre>
<p><span id="more-544"></span><br />
Agora vamos iniciar o aplicativo &#8220;sysinstall&#8221;</p>
<p>Escolha o item &#8220;Options&#8221;</p>
<pre>Options Editor
Name            Value                   Name            Value
----            -----                   ----            -----
NFS Secure      NO                      Browser Exec    /usr/local/bin/links
NFS Slow        NO                      Media Type      &lt;not yet set&gt;
NFS TCP         NO                      Media Timeout   300
NFS version 3   YES                     Package Temp    /var/tmp
Debugging       NO                      Newfs Args      -b 16384 -f 2048
No Warnings     NO                      Fixit Console   serial
Yes to All      NO                      Re-scan Devices &lt;*&gt;
DHCP            NO                      Use Defaults    [RESET!]
IPv6            NO
FTP username    ftp
Editor          vi
Extract Detail  high
Release Name    8.0-RELEASE
Install Root    /usr/jails/dns
Browser package links
Use SPACE to select/toggle an option, arrow keys to move,
? or F1 for more help.  When you're done, type Q to Quit.

NFS server talks only on a secure port</pre>
<p style="text-align: justify;">e altere o item <strong>&#8220;Install Root&#8221;</strong> para o caminho da sua jail, como no exemplo acima.</p>
<p style="text-align: justify;">Ao voltar no menu inicial, escolha o item <strong>&#8220;Configure&#8221;</strong>, depois <strong>&#8220;Distribuitions&#8221;</strong> e marque o item <strong>&#8220;base&#8221;</strong>, se quiser, pode marcar os outros pacotes, como doc, man, etc&#8230;. mas o unico exigido é realmente o pacote &#8220;base&#8221;, que é suficiente para sua Jail.</p>
<p>Ao sair deste menu, você sera solicitado a escolher a midia de instalação, selecione a que melhor lhe convém, CDROM ou FTP&#8230;.</p>
<p>Prossiga a instalação e criação do seu ambiente de Jail.</p>
<p>Terminada a instalação, sua Jail esta pronta para ser iniciada, bastando algumas configurações em relação à isto.</p>
<p>Então vamos lá</p>
<p>vamos mexer no rc.conf agora e colocar as entradas de inicialização da jail, então, coloque as linhas abaixo adaptando-a para as suas necessidades:</p>
<pre>jail_enable="YES"
jail_list="dns" # separe os nomes das jails com espaço
jail_dns_rootdir="/usr/jails/dns"
jail_dns_hostname="dns.dominio.com.br"
jail_dns_ip="192.168.1.100"
jail_dns_exec_start="/bin/sh /etc/rc"
jail_dns_devfs_enable="YES"
jail_dns_devfs_ruleset="devfsrules_jail"</pre>
<p style="text-align: justify;">Salve o rc.conf, pronto, a jail ta prontinha pra ser iniciada, então vamos lá:</p>
<pre>/etc/rc.d/jail start</pre>
<p style="text-align: justify;">Para listar se a jail esta no ar:</p>
<pre># jls
 JID  IP Address      Hostname                      Path
 1    192.168.1.100   dns.dominio.com.br            /usr/jails/dns</pre>
<p style="text-align: justify;">Mas perai, ainda precisamos ajeitar a Jail, então, vamos entrar nela:</p>
<pre># jexec 1 /bin/csh</pre>
<p style="text-align: justify;">Configure uma senha para o root:</p>
<pre># passwd</pre>
<p style="text-align: justify;">Crie um usuario para entrar nela:</p>
<pre># pw add user usuario -m -G wheel -s /bin/csh</pre>
<p style="text-align: justify;"><em>* não esquecer de colocar o usuario no grupo &#8220;wheel&#8221; para poder usar &#8220;su -&#8221;</em></p>
<p>Sete uma senha para ele:</p>
<pre># passwd usuario</pre>
<p style="text-align: justify;">Agora coloque as seguintes entradas no rc.conf:</p>
<pre>sshd_enable="YES"</pre>
<p style="text-align: justify;">e agora configure o resolv.conf para que a jail consiga resolver nomes:</p>
<pre># echo 'nameserver 8.8.8.8' &gt; /etc/resolv.conf</pre>
<p style="text-align: justify;">Inicie o sshd:</p>
<pre># /etc/rc.d/sshd start</pre>
<p style="text-align: justify;">Pronto ! sua Jail esta pronta para ser usada !!!</p>
<p><span style="text-decoration: underline;"><strong>Uma ultima dica:</strong></span><br />
Crie uma montagem &#8220;nullfs&#8221; para o ports dentro da Jail, para isso, siga os comandos abaixo:<br />
* Na maquina raiz:</p>
<pre># mkdir /usr/jails/dns/usr/ports</pre>
<p style="text-align: justify;">
<pre># mount_nullfs /usr/ports /usr/jails/dns/usr/ports</pre>
<p style="text-align: justify;">
<pre># echo '/usr/ports /usr/jails/dns/usr/ports nullfs rw 0 0' &gt;&gt; /etc/fstab</pre>
<p style="text-align: justify;">Pronto, agora você tem o ports compartilhado dentro da Jail.</p>
<p>É isso&#8230; abraços<br />
luizgustavo@luizgustavo.pro.br</p>
]]></content:encoded>
			<wfw:commentRss>http://www.luizgustavo.pro.br/blog/2010/05/30/jails-no-freebsd-rapido-e-facil/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<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>

