1b961 Remote file mount won't work when pf is enable - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Firewalls

Firewalls IPFW, PF, IPF (but not limited) related discussion

Reply
 
Thread Tools Display Modes
  #1  
Old December 9th, 2009, 12:00
hollis2507 hollis2507 is offline
Junior Member
 
Join Date: Sep 2009
Location: Reading, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Remote file mount won't work when pf is enable

Hi all,

I have a server and a client. I have set up an NFS server on the server and i can successfully connect to my backup file from my client machine.

My issue is that this will only work with the firewall off. When i turn the firewall on i get
Quote:
RPCPROG_NFS: RPC: Port mapper failure - RPC: Timed out
I'm not very experienced with the firewalls within BSD. I've tried enabling various ports within the pf.conf but i still have the same issue.

Is there any configuration changes i can make in order to allow this through?

Thanks in advance
Reply With Quote
  #2  
Old December 9th, 2009, 12:05
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,522
Thanks: 422
Thanked 607 Times in 475 Posts
Default

Code:
pass on $ext_if proto { tpc, udp } from any to any port { nfsd, lockd }
i think should work
Reply With Quote
  #3  
Old December 9th, 2009, 12:19
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,694
Thanks: 47
Thanked 2,021 Times in 1,860 Posts
Default

NFS is somewhat tricky to firewall. RPC uses different ports each time.
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #4  
Old December 9th, 2009, 12:34
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,522
Thanks: 422
Thanked 607 Times in 475 Posts
Default

In that case you can allow all ports form known to be "secure" hots... [similar to what i did with ftp ]
Reply With Quote
  #5  
Old December 9th, 2009, 12:46
hollis2507 hollis2507 is offline
Junior Member
 
Join Date: Sep 2009
Location: Reading, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the replies.

I tried

Quote:
pass on $ext_if proto { tpc, udp } from any to any port { nfsd, lockd }
I got the same error message i quoted in my first post.

You say i can allow all ports from known to be "secure" hosts?

How do i go about doing this?
Reply With Quote
  #6  
Old December 9th, 2009, 12:53
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,522
Thanks: 422
Thanked 607 Times in 475 Posts
Default

Well... this is probably not good... but for desktop...
I created list of hosts ip addresses.
In my case I created sh script that extracted ftp addresses from ports tree [I need ftp to install ports ]

Code:
table <ftp_ports_ip_w_list> const file "/etc/ftp_ports_wlist"
...
...
# enable passive ftp
pass out log on $ext_if inet proto tcp from { $ext_ip, <jail_ip_list> } port >1023 to <ftp_ports_ip_w_list> port { ftp, >1023 } group wheel keep state
pass out log on $ext_if inet proto tcp from { $ext_ip, <jail_ip_list> } port >1023 to <ftp_ip_w_list> port { ftp, >1023 } group { users, wheel } keep state
this is from my pf.conf
Reply With Quote
  #7  
Old December 9th, 2009, 13:56
dennylin93 dennylin93 is offline
Member
 
Join Date: Dec 2008
Posts: 784
Thanks: 34
Thanked 103 Times in 71 Posts
Default

Quote:
Originally Posted by SirDice View Post
NFS is somewhat tricky to firewall. RPC uses different ports each time.
This might help: nfs_reserved_port_only="YES"?
Reply With Quote
  #8  
Old December 9th, 2009, 14:37
hollis2507 hollis2507 is offline
Junior Member
 
Join Date: Sep 2009
Location: Reading, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by dennylin93 View Post
This might help: nfs_reserved_port_only="YES"?
Where does this go? rc.conf?
Reply With Quote
  #9  
Old December 9th, 2009, 14:42
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,522
Thanks: 422
Thanked 607 Times in 475 Posts
Default

from rc.conf:
Code:
     nfs_reserved_port_only
                 (bool) If set to “YES”, provide NFS services only on a secure
                 port.
answer: yes
Reply With Quote
  #10  
Old December 9th, 2009, 17:16
phoenix's Avatar
phoenix phoenix is offline
Moderator
 
Join Date: Nov 2008
Location: Kamloops, BC, Canada
Posts: 3,141
Thanks: 43
Thanked 701 Times in 579 Posts
Default

If you control the NFS server, then you can tell all of the NFS utilities to listen to specific ports (search for _flags in /etc/defaults/rc.conf and look at nfs, rpcbind, lockd, statd, and so on).

Then you only have to allow TCP/UDP traffic through on those ports.

For example, on one NFS server, we use the following:
Code:
mountd_enable="yes"                     # Run mountd (or NO).
mountd_flags="-r -h 192.168.0.186 -p 32000"    # Flags to mountd (if NFS server enabled)
rpc_lockd_enable="yes"                  # Run NFS rpc.lockd needed for client/server.
rpc_lockd_flags="-h 192.168.0.186"     # Flags to rpc.lockd (if enabled).
rpc_statd_enable="yes"                  # Run NFS rpc.statd needed for client/server.
rpc_statd_flags="-p 32001"              # Flags to rpc.statd (if enabled).
rpcbind_enable="yes"                    # Run the portmapper service (YES/NO).
rpcbind_flags="-h 192.168.0.186"
nfs_server_enable="yes"                 # This host is an NFS server (or NO).
nfs_server_flags="-u -t -n 4 -h 192.168.0.186"         # Flags to nfsd (if enabled).
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #11  
Old December 9th, 2009, 17:30
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,522
Thanks: 422
Thanked 607 Times in 475 Posts
Default

There's another option... [this is how I solved pf+torrents problem]
create jail with aliased IP run NFS in jail....
allow all traffic to/from that IP....

I wonder what others think about this [perhaps it's totally bad]
Reply With Quote
  #12  
Old December 9th, 2009, 17:56
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,694
Thanks: 47
Thanked 2,021 Times in 1,860 Posts
Default

Quote:
Originally Posted by killasmurf86 View Post
There's another option... [this is how I solved pf+torrents problem]
create jail with aliased IP run NFS in jail....
allow all traffic to/from that IP....

I wonder what others think about this [perhaps it's totally bad]
That's not entirely going to work. IIRC it's mountd that you can't bind to a specific address. Which means it will listen on all addresses, including the ones belonging to other jails and the host itself.
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #13  
Old December 9th, 2009, 22:25
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,820
Thanks: 30
Thanked 1,883 Times in 1,329 Posts
Default

I think allowing {sunrpc nfsd-status nfsd-keepalive nfsd lockd } should be enough. I normally use {sunrpc nfsd lockd }, which appears to be enough. Note two other things:

1. use no-df (pf.conf(5)) on nfs traffic
2. make sure your nfs host/client can resolve one another correctly (DNS or /etc/hosts)
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #14  
Old December 10th, 2009, 00:52
phoenix's Avatar
phoenix phoenix is offline
Moderator
 
Join Date: Nov 2008
Location: Kamloops, BC, Canada
Posts: 3,141
Thanks: 43
Thanked 701 Times in 579 Posts
Default

Quote:
Originally Posted by SirDice View Post
That's not entirely going to work. IIRC it's mountd that you can't bind to a specific address. Which means it will listen on all addresses, including the ones belonging to other jails and the host itself.
See my post above. You can set everything to it's own IP, and even lock in the port that most of the NFS-related services can use.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #15  
Old December 10th, 2009, 01:55
J65nko J65nko is offline
Member
 
Join Date: Nov 2008
Location: Budel, Netherlands
Posts: 285
Thanks: 1
Thanked 73 Times in 63 Posts
Default

You see which packets are being blocked with
Code:
block log all
The blocked packets will show up on the pflog0 device. Run tcpdump on pflog0 to see the blocked stuff.

BTW If your firewall is a corporate firewall, then the general consensus is to not allow NFS through the firewall. NFS = No File Security
Reply With Quote
  #16  
Old December 17th, 2009, 03:59
johnblue johnblue is offline
Member
 
Join Date: Jan 2009
Location: O-o-o-o-o-o-o-klahoma
Posts: 176
Thanks: 11
Thanked 17 Times in 15 Posts
Default

Quote:
Originally Posted by J65nko View Post
Run tcpdump on pflog0 to see the blocked stuff.
Agreed. Not that I am an expert by any means, but to get a quick snap shot of what is going on I like to use:

tcpdump -n -i pflog0

There are additional switches that you can add to the command and then you can it pipe to grep or whatever you want to do with the output.
Reply With Quote
  #17  
Old December 18th, 2009, 03:41
honk honk is offline
Member
 
Join Date: Dec 2008
Posts: 134
Thanks: 6
Thanked 13 Times in 13 Posts
Default

rc.conf on the nfs-server:
Code:
## NFS-Server
rpcbind_enable="YES"
nfs_server_enable="YES"
mountd_flags="-p 789"

pf.conf on the firewall:
Code:
pass log quick proto {udp tcp} from 172.16.1.0/24 to 172.16.3.2 port {111 789 2049} keep state
And then mount the nfs with tcp as transport protocol:
Code:
mount_nfs -o tcp,rw 172.16.3.2:/data /mnt
Works for me (nfs3).

To explain:
At first the nfs-client contacts the portmapper on the server. The portmapper always runs on port 111 udp and tcp (actually only udp is used). The Client then asks the portmapper on which port the mountd is listening. This port is normally dynamically chosen, but you can force mountd to register always on a specific port and this step is important if you have a (stupid) firewall, because you have to allow this port in the ruleset too. Therefore you have to configure your mountd on the server to always use a specific port (in my case 789). As the next step, the client asks the portmapper for the nfsd. Nfsd's port could be also dynamically chosen, but usually only port 2049 is used (tcp or udp, depends on how you mount!). So for the minimal setup you need at least 111, one port for mountd (789) and one port for nfsd (2049). And if you mount_nfs with tcp you will become less trouble with dropped packets (because of congestion on fast links and/or packet drops on the firewall because of fragmentation).

Hope that helps!
cheers,
honk

Last edited by honk; December 18th, 2009 at 03:55.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
enable unicode estellnb General 11 March 18th, 2010 12:10
[Solved] enable sound ccc Multimedia 6 August 2nd, 2009 16:20
[Solved] mount iso file register88 General 14 June 23rd, 2009 14:28
How to enable PF? Trojan Firewalls 19 May 19th, 2009 23:53
How to enable tar? ing0dz General 7 January 17th, 2009 18:43


All times are GMT +1. The time now is 19:52.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0