<?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>OpenBSD and FreeBSD resources &#187; Network</title>
	<atom:link href="http://purebsd.com/tag/network/feed" rel="self" type="application/rss+xml" />
	<link>http://purebsd.com</link>
	<description></description>
	<lastBuildDate>Tue, 01 Jun 2010 06:01:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>TCP Wrappers / Hosts Access</title>
		<link>http://purebsd.com/tcp-wrappers-hosts-access.html</link>
		<comments>http://purebsd.com/tcp-wrappers-hosts-access.html#comments</comments>
		<pubDate>Tue, 01 Jun 2010 05:31:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[TCP]]></category>

		<guid isPermaLink="false">http://purebsd.com/?p=54</guid>
		<description><![CDATA[This is a short and basic introduction to the TCP wrappers. Useful as a start to create your own access control files tailored to your own specific needs. Introduction Probably most people know Wietse Venema&#8217;s TCP Wrapper software as a result of their usage ofinetd, the internet &#8220;super-server&#8221;, in combination with tcpd. An arbitrary line of/etc/inetd.conf, [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short and basic introduction to the TCP wrappers. Useful as a start to create your own access control files tailored to your own specific needs.</p>
<p><strong>Introduction</strong></p>
<p>Probably most people know Wietse Venema&#8217;s TCP Wrapper software as a result of their usage of<code>inetd</code>, the internet &#8220;super-server&#8221;, in combination with <code>tcpd</code>. An arbitrary line of<code>/etc/inetd.conf</code>, the configuration file of <code>inetd</code>:</p>
<p><code>ident stream tcp nowait nobody /usr/libexec/tcpd /usr/libexec/identd -elo</code></p>
<p>The <code>/usr/libexec/tcpd</code> here is the program that takes a look at the incoming connection that <code>inetd</code> has accepted on behalf of the <code>identd</code> program. If it thinks it can allow the connection, it passes it to identd. If not, it unleashes hell (well,.. it just drops the connection) on that TCP connection and <code>identd</code> will never see a packet coming from the remote client.</p>
<p>But not only <code>tcpd</code> uses the wrapping functionality. By default OpenBSD&#8217;s Sendmail and SSH daemon are linked to LIBWRAP and can use its functionality too.</p>
<p><strong>Access control flow/algorithm</strong></p>
<p>To tell tcpd and other programs linked to LIBWRAP which connection to which daemon/service to allow, one should modify or leave alone the following two files:<br />
<code>/etc/hosts.allow</code><br />
<code>/etc/hosts.deny</code></p>
<p>In <code>hosts.allow</code> you put the remote host/local daemon combinations that you approve of having a happy TCP chatter. If a remote host, the client, likes to chat with a local daemon and that client/daemon pair has a positive match in the <code>hosts.alllow</code> file, the client is granted access to the daemon&#8217;s services. The <code>hosts.deny</code> file is ignored.</p>
<p>If there is no positive match, the <code>hosts.deny</code> is checked for a match. If the tcp wrapper can find a positive match in <code>hosts.deny</code>, the client is not granted access to the daemon and the TCP connection gets dropped. But if the client/daemon pair is not matched, the connection to the daemon is granted.</p>
<p>If one or both of the hosts access files is missing, the above explained flow treats them as if they exist, but are empty.</p>
<p>The control flow is a Yes-Unless kind of strategy. You can come in, unless you&#8217;re mentioned in<code>hosts.deny</code>. To reverse that strategy that you can configure <code>hosts.deny</code> to deny all access. Then all clients trying to communicatie with a daemon should be listed in <code>hosts.allow</code>. Then we have a No-Unless situation created.</p>
<p><strong>Configuration</strong></p>
<p>Here I&#8217;ll explain how to create that el neato No-Unless situation with some real life X-rated examples.</p>
<p>First we edit <code>hosts.deny</code> to disallow life, the universe and everything:</p>
<p><code>ALL: ALL</code></p>
<p>Then we edit <code>hosts.allow</code> to let the complete internet whisper in the ears of our SSH daemon, Sendmail and our ident daemon:</p>
<p><code>identd: ALL</code><br />
<code>sendmail: ALL</code><br />
<code>sshd: ALL</code></p>
<p>Don&#8217;t use above example if you don&#8217;t like allowing anyone to access the Sendmail daemon, ssh daemon and/or ident daemon.<br />
The combination of the above example of the <code>hosts.deny</code> and <code>hosts.allow</code> allows the complete internet access to your sendmail, ssh daemon and ident daemon, but completely forbids anyone to access any other daemon/service you&#8217;re running.</p>
<p>If you&#8217;d like to have hosts on your intranet access to your POP3 daemon, but not anyone else you can do something like this in <code>hosts.allow</code>:</p>
<p><code>popa3d: 127.0.0.1 192.168.0.</code></p>
<p>With this rule access is granted to our POP3 daemon popa3d from localhost and the &#8220;192.168.0.&#8221; IP range. You can read &#8220;192.168.0.&#8221; like 192.168.0.*, 192.168.0.1 &#8211; 192.168.0.254, or 192.168.0.0/24. It comes down to 254 IP addresses that start with &#8220;192.168.0&#8243;.</p>
<p><strong>More information</strong></p>
<p>More information can be obtained by reading the following man pages:</p>
<p>- hosts_access(5)<br />
- hosts_options(5)<br />
- tcpd(8)</p>
<p>They provide far more advanced information then you can find here and recommended reading if you&#8217;d like to tailor the hosts access files to your own specific (and complex?) needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://purebsd.com/tcp-wrappers-hosts-access.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

