<?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>techslaves.org &#187; security</title>
	<atom:link href="http://techslaves.org/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://techslaves.org</link>
	<description>Owned (and fascinated) by technology!</description>
	<lastBuildDate>Wed, 16 Nov 2011 03:36:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Remote Access Solution: Follow Up</title>
		<link>http://techslaves.org/2011/02/21/remote-access-solution-follow-up/</link>
		<comments>http://techslaves.org/2011/02/21/remote-access-solution-follow-up/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 00:29:31 +0000</pubDate>
		<dc:creator>rthomson</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[campus]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[users]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://techslaves.org/?p=127</guid>
		<description><![CDATA[Yes! We&#8217;ve implemented what I think is the best compromise for our remote access problem that I outlined earlier. Three major things happened that made it possible to compromise: 1. I received an OK from the higher-ups that indeed it would be ok to mandate that users who want remote access to our system have [...]
Related posts:<ol>
<li><a href='http://techslaves.org/2011/02/10/remote-access-solution/' rel='bookmark' title='Remote Access Solution'>Remote Access Solution</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Yes! We&#8217;ve implemented what I think is the best compromise for our <a href="/2011/02/10/remote-access-solution/">remote access problem that I outlined earlier</a>.</p>
<p>Three major things happened that made it possible to compromise:</p>
<p>1. I received an OK from the higher-ups that indeed it would be ok to mandate that users who want remote access to our system have all their Internet traffic routed via the VPN.</p>
<p>2. The VPN configuration that was proposed is not that of a private group but the generic campus-wide VPN solution with ACLs to allow VPN clients to access our resources.</p>
<p>3. The generic campus-wide VPN service does *not* implement any outgoing restrictions, unlike the private VPN groups do. This makes it possible for VPN users to do whatever they want when connected, with the stipulation that it&#8217;s akin to bringing your personal computer to campus in terms of privacy.</p>
<p>This really is the best of both worlds (security, ease of use). The campus VPN service is super-simple to use and we restrict access to our services to VPN users instead of the whole Internet. While we don&#8217;t control who gets access to the VPN, the pool of users is MUCH smaller and at least semi-trusted by the organization. Thus the risk is greatly reduced.</p>
<p>I&#8217;m happy.</p>
<p>Related posts:<ol>
<li><a href='http://techslaves.org/2011/02/10/remote-access-solution/' rel='bookmark' title='Remote Access Solution'>Remote Access Solution</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://techslaves.org/2011/02/21/remote-access-solution-follow-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cfengine 3 Snippets Part 2: sudo</title>
		<link>http://techslaves.org/2010/10/02/cfengine-3-snippets-part-2-sudo/</link>
		<comments>http://techslaves.org/2010/10/02/cfengine-3-snippets-part-2-sudo/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 02:59:42 +0000</pubDate>
		<dc:creator>rthomson</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[cfengine]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://techslaves.org/?p=87</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve really had time to delve too much further into cfengine 3 since my previous post on the subject way back in May but I do have another simple example to share. This time it&#8217;s about managing your sudo policy via the sudoers file. The example is that of a very, [...]
Related posts:<ol>
<li><a href='http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/' rel='bookmark' title='Cfengine 3 Snippets Part 1: DenyHosts'>Cfengine 3 Snippets Part 1: DenyHosts</a></li>
<li><a href='http://techslaves.org/2010/03/29/nanorcs/' rel='bookmark' title='Nanorcs: Ultrasimplistic Configuration File Revision Control'>Nanorcs: Ultrasimplistic Configuration File Revision Control</a></li>
<li><a href='http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/' rel='bookmark' title='RHEL/CentOS, NFS and Firewalls'>RHEL/CentOS, NFS and Firewalls</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve really had time to delve too much further into cfengine 3 since my <a href="http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/">previous post</a> on the subject way back in May but I do have another simple example to share. This time it&#8217;s about managing your sudo policy via the <em>sudoers</em> file.</p>
<p>The example is that of a very, very basic <em>sudoers</em> policy but the principles are easily extended to create much more complex policy. The general idea here is that we want cfengine to ensure that specific rules are always in place. Instructed properly, cfengine accomplishes this very well.</p>
<p>Warning: I don&#8217;t know anything. I&#8217;m just someone learning cfengine 3 and posting about it. If I&#8217;m wrong about something, let me know! If you find this at all useful, be my guest. That is all.</p>
<p><span id="more-87"></span></p>
<pre>################################################################################
##
## FILE: sudo.cf
## DESC: Control /etc/sudoers file on various servers
##
################################################################################

bundle agent sudo
{

vars:

  "sudoers" string =&gt; "/etc/sudoers";

  "sudo"     slist =&gt; {
                      "%admin ALL = ALL",
                      "%sysadmin ALL = /sbin/mount",
                      "%devel ALL = /sbin/mount"
                      };

packages:

  Night::

  "sudo" -&gt; "Security policy"
    comment               =&gt; "Ensure sudo is up to date every 24 hours (and only at night)",
    package_policy        =&gt; "update",
    package_method        =&gt; yum,
    package_architectures =&gt; { "$(sys.arch)" },
    action                =&gt; if_elapsed("1440");

files:

  "$(sudoers)" -&gt; "Security Policy"
    comment      =&gt; "Append common configuration to sudoers",
    edit_line    =&gt; append_if_no_lines("$(sudo)");

}</pre>
<p>As with last snippet I posted, the above does not even resemble a complete cfengine policy/configuration, just a small portion that can be contained in it&#8217;s own bundle. It can be put in a separate .cf file, imported by promises.cf and added to the bundle sequence, inheriting variables and classes! Also, just like last time I&#8217;m using cfengine&#8217;s built in interface for package management systems to ensure &#8220;sudo&#8221; is always installed via yum at night, every 24 hours.</p>
<p>What&#8217;s new here is file editing with <em>edit_line</em> and the use of iteration which proves to be very powerful in cfengine 3.</p>
<h2>Editing Files</h2>
<p>Editing files with cfengine is supposed to be easy but initially it seemed a bit awkward to me.</p>
<p>First you have the promise file promise:</p>
<pre>files:

  "$(sudoers)" -&gt; "Security Policy"
    comment      =&gt; "Append common configuration to sudoers",
    edit_line    =&gt; append_if_no_lines("$(sudo)");</pre>
<p>Which makes some reference to the <em>edit_line</em> facility and what looks like a function name with <em>append_if_no_lines(&#8230;)</em>.</p>
<p>Then you have the <em>edit_line</em> bundle defined elsewhere:</p>
<pre>bundle edit_line append_if_no_lines(list)
{
insert_lines:

 "$(list)";
}</pre>
<p>Which describes what &#8220;append_if_no_lines&#8221; actually does.</p>
<p>Of course I&#8217;m just learning cfengine and new things can often seem strange and scary but I am finally warming up to editing files with cfengine&#8230; I think. What I seemed to have initial trouble with was with the <em>bundles</em> necessary for <em>edit_lines</em>, as described above. The bundle within a bundle concept. The <em>append_if_no_lines</em> and <em>append_if_no_line</em> bundles I&#8217;m using are implemented in the <a href="http://www.cfengine.org/manuals/cfengine_stdlib.cf">cfengine std library</a>, which is highly recommended so that you may avoid re-inventing the wheel a little bit.</p>
<p>For basic promises, to add or remove, comment or uncomments lines and the such there are good <em>edit_lines</em> bundles available in the stdlib. For other more complex or customized file editing, writing your own bundles will be necessary. Either way, understanding what a <em>bundle</em> is and how to create your own is key to fully grasping file editing and getting the most out of it. This seems obvious in retrospect but something I didn&#8217;t pickup instantly.</p>
<p>See the cfengine documentation for more about editing files, check the cfengine documentation. There&#8217;s waaaaay more good information over there and it&#8217;s from the cfengine team, not some random newb.</p>
<h2><strong>Iteration</strong></h2>
<p>Iteration is powerful mechanism within cfengine that harnesses the power of lists to express a large possible number of actions/operations with very little amount of code. When lists are used, single actions can be made to repeat for every item in a list by using the <em>$(varname)</em> syntax to refer to the list&#8230; which as it turns out is the same for scalar values! Funny that!</p>
<p>So cfengine allows us to define X different lines of code to ensure are in a file using only a single <em>file:</em> promise all with the same simple syntax as scalar variables? Brilliant!</p>
<p>A demonstration of iteration can be seen with the <em>$(sudo)</em> slist and the &#8220;Append common configuration to sudoers&#8221; <em>file:</em> promise. With this single promise definition, <em>up to</em> 6 actual promises are made because the <em>$(sudo)</em> variable is an slist. Each element or item in the list is iterated over in sequence and the promise is evaluated and acted upon, if necessary. The reason that <em>up to</em> 6 promises will be evaluated is the <em>ifvarclass</em> property of promise, ensuring the promise will only be kept if we&#8217;re in the context of the class&#8230; and looking at the promise to find out which class, we see another example of iteration using the <em>$(sudo)</em> list and the <em>canonify</em> function that turns a string into a class. Thusly, if the host currently running this policy defines all the classes that are tested by the <em>ifvarclass</em> iteration, 6 promises will be made. If the host defines 3 of the classes, then 3 promises will be made and so on, and so forth.</p>
<p>As a beginner, using lists and iteration effectively and creatively seems fairly important to getting the most out of cfengine 3.</p>
<h2>Editing Files vs. Copying Files</h2>
<p>In my previous snippet, I demonstrated how to promise to copy a file from a secure remote server if the local file does not match the server&#8217;s file in order to manage a configuration with cfengine. This time, I&#8217;m promising to add lines to a configuration file if they do not already exist exactly as provided.</p>
<p>This represents two rather different takes on policy. The first says: &#8220;The configuration must always be exactly like this file, byte per byte!&#8221; the second says &#8220;These lines must exist but I don&#8217;t care about anything else in the file&#8221;. The file copy method is what I would call hard policy and the second is soft policy. In the cfengine community solutions, they recommend managing sudo by copying an <em>/etc/sudoers</em> from a remote server. That way is great (just like my DenyHosts example) but this is just another way if you have a use case for cfengine not owning every byte of your configuration file.</p>
<h2>Conclusion</h2>
<p>Yeah, that&#8217;s about it. Enjoy.</p>
<p>Related posts:<ol>
<li><a href='http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/' rel='bookmark' title='Cfengine 3 Snippets Part 1: DenyHosts'>Cfengine 3 Snippets Part 1: DenyHosts</a></li>
<li><a href='http://techslaves.org/2010/03/29/nanorcs/' rel='bookmark' title='Nanorcs: Ultrasimplistic Configuration File Revision Control'>Nanorcs: Ultrasimplistic Configuration File Revision Control</a></li>
<li><a href='http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/' rel='bookmark' title='RHEL/CentOS, NFS and Firewalls'>RHEL/CentOS, NFS and Firewalls</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://techslaves.org/2010/10/02/cfengine-3-snippets-part-2-sudo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cfengine 3 Snippets Part 1: DenyHosts</title>
		<link>http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/</link>
		<comments>http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/#comments</comments>
		<pubDate>Tue, 18 May 2010 22:02:09 +0000</pubDate>
		<dc:creator>rthomson</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[cfengine]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[denyhosts]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://techslaves.org/?p=63</guid>
		<description><![CDATA[I&#8217;ve recently begun looking into configuration management with cfengine 3. I&#8217;ve ignored this growing sub-field of system administration for too long and I just can&#8217;t ignore it anymore. After spending quite some time researching the philosophies, methods and different tools out there, I settled on starting out with cfengine 3. There&#8217;s no special reason that [...]
Related posts:<ol>
<li><a href='http://techslaves.org/2010/10/02/cfengine-3-snippets-part-2-sudo/' rel='bookmark' title='Cfengine 3 Snippets Part 2: sudo'>Cfengine 3 Snippets Part 2: sudo</a></li>
<li><a href='http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/' rel='bookmark' title='RHEL/CentOS, NFS and Firewalls'>RHEL/CentOS, NFS and Firewalls</a></li>
<li><a href='http://techslaves.org/2010/03/29/nanorcs/' rel='bookmark' title='Nanorcs: Ultrasimplistic Configuration File Revision Control'>Nanorcs: Ultrasimplistic Configuration File Revision Control</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently begun looking into configuration management with <a href="http://cfengine.org">cfengine 3</a>. I&#8217;ve ignored this growing sub-field of system administration for too long and I just can&#8217;t ignore it anymore. After spending quite some time researching the philosophies, methods and different tools out there, I settled on starting out with cfengine 3. There&#8217;s no special reason that I chose cfengine instead of puppet, bcfg2, chef or AutomateIT. I haven&#8217;t used any of these tools and thus I cannot pass judgement on them or their methods. All these projects seem to have intelligent and highly motivated people behind them. I simply gravitated towards cfengine because of its strong academic background and the fact that version 3 now represents the most recent and modern research in the field by Mark Burgess et. al.</p>
<p>As part of my learning experience with cfengine, I&#8217;ve decided to start posting some of the code that I&#8217;ve begun developing in the hopes that by writing about it, I can learn better, faster and maybe even receive some helpful comments from readers along the way. Beware, I&#8217;m a cfengine newbie and so what I post here should NOT be copy and pasted into your environment unless you&#8217;re ok with the potential of wildly breaking things!</p>
<p>The first snippet of code I want to discuss is related to managing our <a href="http://denyhosts.sourceforge.net/">DenyHosts</a> configuration. As part of our &#8220;security policy&#8221;, I would like to ensure that every RedHat/CentOS system is running a properly configured DenyHosts instance. Here is what I&#8217;ve come up with so far.</p>
<p><span id="more-63"></span></p>
<pre>################################################################################
#
# FILE: denyhosts.cf
# DESC: Install, update, configure and ensure DenyHosts is running
# DATE: May 2010
#
#################################################################################

bundle agent denyhosts
{

packages:

  "denyhosts" -&gt; "Security policy"
    comment               =&gt; "Ensure denyhosts is installed once a week",
    package_policy        =&gt; "add",
    package_method        =&gt; yum,
    package_architectures =&gt; { "noarch" },
    action                =&gt; if_elapsed("10080");

  Night::

  "denyhosts" -&gt; "Security policy"
    comment               =&gt; "Check for update to denyhosts every 24 hours (and only at night)",
    package_policy        =&gt; "update",
    package_method        =&gt; yum,
    package_architectures =&gt; { "noarch" },
    action                =&gt; if_elapsed("1440");

files:

  "/etc/denyhosts.conf" -&gt; "Security policy"
    comment   =&gt; "Standard base DenyHosts configuration",
    copy_from =&gt; mycopy("$(g.confdir)/denyhosts/denyhosts.conf", "$(g.cfserver)"),
    classes   =&gt; cdefine("denyhosts_restart", "denyhosts_conf_copy_failed"),
    perms     =&gt; mo("400", "root"),
    action    =&gt; if_elapsed("1440");

processes:

  "python /usr/bin/denyhosts.py" -&gt; "Security policy"
    comment       =&gt; "Define denyhosts_restart class if denyhost is NOT running",
    restart_class =&gt; canonify("denyhosts_restart");

commands:

  "/sbin/service denyhosts restart" -&gt; "Security policy"
     comment    =&gt; "Restarting DenyHosts after configuration change or death",
     ifvarclass =&gt; canonify("denyhosts_restart");

}</pre>
<p>If you&#8217;re familiar with cfengine at all, you&#8217;ll quickly realize this is not a complete configuration. I am relying on the cfengine standard library for several body definitions as well as custom site variables defined in the common bundle named &#8220;g&#8221; (not shown). And of course, there are no control bodies, bundlesequence or many other things that make up a complete cfengine configuration, hence &#8220;snippet&#8221;.</p>
<p>Let&#8217;s ignore what&#8217;s lacking for now and focus on the meat of the promises.</p>
<h3>Packages</h3>
<p>The first part of the denyhosts bundle is dealing with packages. I&#8217;m making two promises regarding the &#8220;denyhosts&#8221; package. The first promise is that the package has been added to the system via yum and the second is that the package is up to date via yum. I&#8217;m not entirely clear on how to best manage promises like this yet so perhaps I&#8217;m missing some cute shorthand for both adding and keeping packages up to date. For now, I&#8217;ll stick with two separate promises.</p>
<p>You&#8217;ll also notice that I&#8217;m only checking to see if the package is installed once a week (via action =&gt; if_elapsed) and only checking to see if the package is up to date once every 24 hours (if_elapsed, again). The update promise is also subject to the Night class to ensure that package updates only occur at night and not during the work day. This is just a matter of preference. I&#8217;d prefer if updates occur at night, you may not.</p>
<p>Since I&#8217;m using a &#8220;smart&#8221; package manager to ensure that denyhosts is installed, I can count on having yum resolve any dependencies (such as python) for me automatically. I would loath to describe every dependency for every package I want control over by hand.</p>
<h3>Files</h3>
<p>There is only one file that I&#8217;m concerned with when it comes to denyhosts and that is the denyhosts configuration file in /etc/denyhosts.conf. Instead of doing file edits on the default denyhosts.conf file provided in the denyhosts packages that I&#8217;ve promised to install, I simply copy a pre-defined configuration from my cfengine server. This file has our site&#8217;s default denyhosts configuration all ready to go. If I needed to customize the configuration on a per-host or per-host-type basis, I could copy the base file to a temporary location then perform edits on the temp file and write out the changes to the final location of the default configuration file or simply maintain several pre-configured versions of denyhosts.conf and copy the appropriate file.</p>
<p>Also of note about files is that if the file promise must be repaired (if the file must be copied because it&#8217;s changed), I&#8217;m setting a class to be defined so that DenyHosts can be restarted. More on that later.</p>
<h3>Processes</h3>
<p>In this case, I&#8217;m only checking to see if the DenyHosts python process is running or not. If DenyHosts is running, we do nothing. If DenyHosts is not running, we define a class using the same name as the class we define if we have to copy the configuration file.</p>
<h3>Commands</h3>
<p>Finally, in the commands section we tell cfengine how and when to restart DenyHosts. If the &#8220;denyhosts_restart&#8221; class is defined, we instruct cfengine to restart DenyHosts with the &#8220;/sbin/service denyhosts restart&#8221; command. The canonify and cdefine special functions in cfengine provide a very powerful way of defining some rather complex relationships.</p>
<h3>What is Missing?</h3>
<p>Well, probably <em>a lot</em> of stuff. One obvious thing is that I&#8217;m not promising that DenyHosts is set to startup at boot time using the hosts&#8217; native init system. Of course, this shouldn&#8217;t be a big deal because cfengine will start it up if it&#8217;s not running at the next cf-agent run, but perhaps it would be nice to make that promise anyways.</p>
<p>I&#8217;m also not using many (or any!) classes to limit the scope of where (to what hosts) these promises will apply. Right now, I&#8217;m just working with a test environment so it&#8217;s easy to get away with that but I&#8217;m learning that it&#8217;s good to be as explicit at possible from the start when building promises.</p>
<p><strong>UPDATE:</strong> Ah, how could I forget.. Reporting is totally missing! I knew I was setting some of those classes for a reason. In the next installment, I&#8217;ll include the most basic of reporting functionality.</p>
<p>I think that&#8217;s all for now. Please critique my amateur use of cfengine 3 in the comments, I want to hear from you!</p>
<p>Related posts:<ol>
<li><a href='http://techslaves.org/2010/10/02/cfengine-3-snippets-part-2-sudo/' rel='bookmark' title='Cfengine 3 Snippets Part 2: sudo'>Cfengine 3 Snippets Part 2: sudo</a></li>
<li><a href='http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/' rel='bookmark' title='RHEL/CentOS, NFS and Firewalls'>RHEL/CentOS, NFS and Firewalls</a></li>
<li><a href='http://techslaves.org/2010/03/29/nanorcs/' rel='bookmark' title='Nanorcs: Ultrasimplistic Configuration File Revision Control'>Nanorcs: Ultrasimplistic Configuration File Revision Control</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RHEL/CentOS, NFS and Firewalls</title>
		<link>http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/</link>
		<comments>http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:01:20 +0000</pubDate>
		<dc:creator>rthomson</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[vendor]]></category>

		<guid isPermaLink="false">http://techslaves.org/?p=61</guid>
		<description><![CDATA[I recently decided that it&#8217;s about time to setup consistent, explicit and tight firewall policy across our Linux (mostly RHEL/CentOS) servers. One of the initial issues I faced was NFS. NFS implementations are very well known to make use of the portmapper and dynamically assigned port for rpc.mountd and because of this dynamic assignment, firewalling [...]
Related posts:<ol>
<li><a href='http://techslaves.org/2011/05/13/browsing-automounted-nfs-with-nautilus/' rel='bookmark' title='Browsing Automounted NFS with Nautilus'>Browsing Automounted NFS with Nautilus</a></li>
<li><a href='http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/' rel='bookmark' title='Cfengine 3 Snippets Part 1: DenyHosts'>Cfengine 3 Snippets Part 1: DenyHosts</a></li>
<li><a href='http://techslaves.org/2010/03/30/opengear-cm4116-review/' rel='bookmark' title='OpenGear CM4116 Review'>OpenGear CM4116 Review</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently decided that it&#8217;s about time to setup consistent, explicit and tight firewall policy across our Linux (mostly RHEL/CentOS) servers. One of the initial issues I faced was NFS. NFS implementations are very well known to make use of the portmapper and dynamically assigned port for rpc.mountd and because of this dynamic assignment, firewalling NFS can be challenging.</p>
<p>Luckily, RedHat&#8217;s <em>/etc/sysconfig/nfs</em> configuration file read by  various &#8220;nfs&#8221;, &#8220;nfslock&#8221; and RPC services init scripts provides an easy means of locking down specific ports for all the NFS-related services so that one doesn&#8217;t have to work around the dynamic port assignment problem when it comes to firewalling.</p>
<p><span id="more-61"></span></p>
<p>In <em>/etc/sysconfig/nfs</em> there are six different options relating to port assignment:</p>
<ol>
<li>RQUOTAD_PORT</li>
<li>LOCKD_TCPPORT</li>
<li>LOCKD_UDPPORT</li>
<li>MOUNTD_PORT</li>
<li>STATD_PORT</li>
<li>STATD_OUTGOING_PORT</li>
</ol>
<p>These options do not represent all the ports that will be used by the entire NFS service but it includes the most important option for eliminating the uncertainty of rpc.mountd.</p>
<p>I&#8217;ve set the port options as follows:</p>
<ol>
<li>RQUOTAD_PORT=875</li>
<li>LOCKD_TCPPORT=4045</li>
<li>LOCKD_UDPPORT=4045</li>
<li>MOUNTD_PORT=861</li>
<li>STATD_PORT=865</li>
<li>STATD_OUTGOING_PORT=866</li>
</ol>
<p>After making the changes, restart the &#8220;nfs&#8221; and &#8220;nfslock&#8221; services and check to make sure the configured ports are now in fact in use with the &#8220;rpcinfo -p&#8221; command:</p>
<pre># rpcinfo -p
program vers proto   port  service
100000    4   tcp    111  portmapper
100000    3   tcp    111  portmapper
100000    2   tcp    111  portmapper
100000    4   udp    111  portmapper
100000    3   udp    111  portmapper
100000    2   udp    111  portmapper
100011    1   udp    875  rquotad
100011    2   udp    875  rquotad
100011    1   tcp    875  rquotad
100011    2   tcp    875  rquotad
100021    1   udp   4045  nlockmgr
100021    3   udp   4045  nlockmgr
100021    4   udp   4045  nlockmgr
100021    1   tcp   4045  nlockmgr
100021    3   tcp   4045  nlockmgr
100021    4   tcp   4045  nlockmgr
100003    2   tcp   2049  nfs
100003    3   tcp   2049  nfs
100003    4   tcp   2049  nfs
100003    2   udp   2049  nfs
100003    3   udp   2049  nfs
100003    4   udp   2049  nfs
100005    1   udp    861  mountd
100005    1   tcp    861  mountd
100005    2   udp    861  mountd
100005    2   tcp    861  mountd
100005    3   udp    861  mountd
100005    3   tcp    861  mountd
100024    1   udp    865  status
100024    1   tcp    865  status</pre>
<p>Now, the entire NFS-related firewall rules must allow the following ports from the applicable client address range(s):</p>
<ul>
<li>Incoming and Outgoing ICMP type 3</li>
<li>Incoming TCP and UDP ports 111, 861, 865, 875, 2049, 4045</li>
<li>Outgoing TCP and UDP ports 111, 861, 865, 866, 875, 2049, 4045</li>
</ul>
<p>These rules can easily be configured with your favorite firewalling software (I&#8217;m using fwbuilder to manage iptables rules). Often times firewalls will be configured to allow all outgoing connections, so if that&#8217;s the case with your firewalls, don&#8217;t worry about specific outgoing rules. I&#8217;ve been testing this configuration for two days now and all seems well.</p>
<p>Related posts:<ol>
<li><a href='http://techslaves.org/2011/05/13/browsing-automounted-nfs-with-nautilus/' rel='bookmark' title='Browsing Automounted NFS with Nautilus'>Browsing Automounted NFS with Nautilus</a></li>
<li><a href='http://techslaves.org/2010/05/18/cfengine-3-snippets-part-1-denyhosts/' rel='bookmark' title='Cfengine 3 Snippets Part 1: DenyHosts'>Cfengine 3 Snippets Part 1: DenyHosts</a></li>
<li><a href='http://techslaves.org/2010/03/30/opengear-cm4116-review/' rel='bookmark' title='OpenGear CM4116 Review'>OpenGear CM4116 Review</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://techslaves.org/2010/05/07/rhelcentos-nfs-and-firewalls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

