<?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>Pario TechnoBlob &#187; rpcinfo</title>
	<atom:link href="http://pario.no/tag/rpcinfo/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 26 Apr 2012 08:18:54 +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>Allow NFS through iptables on a RedHat system</title>
		<link>http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/</link>
		<comments>http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/#comments</comments>
		<pubDate>Tue, 15 Jan 2008 11:17:29 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[RedHat]]></category>
		<category><![CDATA[rpcinfo]]></category>

		<guid isPermaLink="false">http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/</guid>
		<description><![CDATA[This post describes how you can configure your RedHat Enterprise WS 4 NFS system behind a iptables firewall to be available for clients outside the firewall on a permanent basis. Symptom NFS relies on portmap to assign the ports on which it will listen. One side effect of this is that the ports are randomly [...]]]></description>
			<content:encoded><![CDATA[<p>This post describes how you can configure your RedHat Enterprise WS 4 NFS system behind a iptables firewall to be available for clients outside the firewall on a permanent basis.</p>
<p><strong>Symptom</strong><br />
NFS relies on portmap to assign the ports on which it will listen. One side effect of this is that the ports are randomly assigned, so each time NFS is restarted the ports will change. This can make it difficult to run an NFS server behind a firewall which only allows access to specific ports on the system.</p>
<p><strong>Solution</strong><br />
The first step is to assign a permanent port number to each of the NFS services (rquotad, mountd, statd, and lockd). While they can use any unused ports greater than 1024, it is recommended that you first consult the file <strong>/etc/services</strong> to find a valid unused port range. The following examples use the range 10000-10005.</p>
<p>The majority of the ports are configured through the file <strong>/etc/sysconfig/nfs</strong>. You will need to create this file if it does not exist. It should look similar to the following example:</p>
<pre>
# NFS port numbers
STATD_PORT=10002
STATD_OUTGOING_PORT=10003
MOUNTD_PORT=10004
RQUOTAD_PORT=10005</pre>
<p>The lockd service is configured differently from the others because it is compiled as a kernel module. To set the port which lockd uses, add these options in the <strong>/etc/sysconfig/nfs</strong> file:</p>
<pre>
LOCKD_UDPPORT=30001
LOCKD_TCPPORT=30001</pre>
<p>where &#8220;30001&#8243; can be replaced with any port that is available and can be assigned for use.</p>
<p>After these configuration changes, you can view the port assignments with the command <em>rpcinfo -p <hostname></hostname></em></p>
<pre>
# rpcinfo -p | awk -F " " '{print $3 ", " $4 ", " $5}' | sort | uniq
   proto, port,
tcp, 111, portmapper
tcp, 2049, nfs
tcp, 32771, nlockmgr
tcp, 800, rquotad
tcp, 814, mountd
udp, 111, portmapper
udp, 2049, nfs
udp, 32768, nlockmgr
udp, 797, rquotad
udp, 811, mountd</pre>
<p>At this point, the ports will remain the same when NFS is restarted. The following is a list of ports which need to be opened on the firewall:</p>
<pre>
proto, port,
tcp, 10004, mountd
tcp, 10005, rquotad
tcp, 111, portmapper
tcp, 2049, nfs
tcp, 32771, nlockmgr
udp, 10004, mountd
udp, 10005, rquotad
udp, 111, portmapper
udp, 2049, nfs
udp, 32768, nlockmgr</pre>
<p>You can now open these ports on the firewall to allow remote clients to mount a share on the server. If you are using iptables, the following commands can be used to add inbound/outbound rules to allow access to these ports.<br />
<note>Note that this is only an example, as your specific firewall rules may differ.</note><br />
This is an excerp of my <strong>/etc/sysconfig/iptables</strong> file. It allows NFS connections from IP address 192.168.0.10 but doesn&#8217;t restrict traffic out.</p>
<pre>
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p tcp -m tcp --dport 111 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p udp -m udp --dport 111 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10  -p tcp -m tcp --dport 2049 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p udp -m udp --dport 2049 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p tcp -m tcp --dport 10000 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p udp -m udp --dport 10001 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p tcp -m tcp --dport 10002:10005 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.0.10 -p udp -m udp --dport 10002:10005 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -p tcp -m tcp -j LOG --log-prefix "Reject Traffic " --log-level 6
-A RH-Firewall-1-INPUT -i eth0 -p tcp -m tcp -j REJECT --reject-with icmp-port-unreachable</pre>
<p>This post is a modified example of the solution from <a href="http://kbase.redhat.com/faq/FAQ_85_5928.shtm">RedHat Knowledgebase Article ID 5928</a>.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/kbase.redhat.com\/faq\/FAQ_85_5928.shtm"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDEvMTUvYWxsb3ctbmZzLXRocm91Z2gtaXB0YWJsZXMtb24tYS1yZWRoYXQtc3lzdGVtLzx3cHRiPkFsbG93IE5GUyB0aHJvdWdoIGlwdGFibGVzIG9uIGEgUmVkSGF0IHN5c3RlbTx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Allow NFS through iptables</title>
		<link>http://pario.no/2007/12/20/allow-nfs-through-iptables/</link>
		<comments>http://pario.no/2007/12/20/allow-nfs-through-iptables/#comments</comments>
		<pubDate>Thu, 20 Dec 2007 09:50:41 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[nmap]]></category>
		<category><![CDATA[rpcinfo]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://pario.no/2007/12/20/allow-nfs-through-iptables/</guid>
		<description><![CDATA[This is one way to determine the ports needed to open in your iptables rules to get NFS to work properly. First we need to determine the ports NFS uses rpcinfo -p &#124; awk -F " " '{print $3 ", " $4 ", " $5}' &#124; sort &#124; uniq Notice! Since portmap assigns ports on [...]]]></description>
			<content:encoded><![CDATA[<p>This is one way to determine the ports needed to open in your iptables rules to get NFS to work properly. First we need to determine the ports NFS uses</p>
<pre>
rpcinfo -p | awk -F " " '{print $3 ", " $4 ", " $5}' | sort | uniq</pre>
<p><strong>Notice!</strong><br />
Since portmap assigns ports on random this example is only valid as long as you don&#8217;t restart your NFS.</p>
<p>On my system, a RedHat Enterprise Linux WS 4, the result was</p>
<pre>
proto, port,
tcp, 111, portmapper
tcp, 2049, nfs
tcp, 32771, nlockmgr
tcp, 768, rquotad
tcp, 782, mountd
udp, 111, portmapper
udp, 2049, nfs
udp, 32768, nlockmgr
udp, 765, rquotad
udp, 779, mountd</pre>
<p>This gave me  a nice overview of protocols (tcp/udp) and ports used.</p>
<p>Now the rules</p>
<pre>
iptables -A RH-Firewall-1-INPUT -s 192.168.0.0/255.255.255.0 -i eth0 -p tcp -m state --state NEW -m multiport --dports 111,2049,32771,768,782 -j ACCEPT
iptables -A RH-Firewall-1-INPUT -s 192.168.0.0/255.255.255.0 -i eth0 -p udp -m state --state NEW -m multiport --dports 111,2049,32768,765,779 -j ACCEPT</pre>
<p>You see that the multiport statement is just like the result of my rpcinfo command above.</p>
<p>Remember to save your new rules, othervise they will disappear the next time the iptables rules are being loaded.</p>
<p>In addition to this rule you should add the <a href="http://pario.no/2007/05/08/ssh-dictionary-attack-prevention-with-iptables/">iptables rule for ssh access</a> I wrote about earlier.</p>
<p>Another way to determine the ports</p>
<pre>
nmap -sC -p 111 localhost</pre>
<p><strong>Notice!</strong><br />
This solution won&#8217;t work after a reboot of the server since NFS changes ports. One way to overcome this problem is to follow the instructions in a newer post I&#8217;ve made about <a href="http://pario.no/2008/01/15/allow-nfs-through-iptables-on-a-redhat-system/">RedHat and NFS</a>.</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDcvMTIvMjAvYWxsb3ctbmZzLXRocm91Z2gtaXB0YWJsZXMvPHdwdGI%2BQWxsb3cgTkZTIHRocm91Z2ggaXB0YWJsZXM8d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2007/12/20/allow-nfs-through-iptables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

