# how to force mount to use a specific port in nfs?

## DaggyStyle

I have my portage defined as nfs on my server, when I want to mount the nfs on my laptop so I can sync, for some reason, the client uses random and different ports, that is a problem because the firewall blocks the packets.

I've tried adding port=port to fstab but it doesn't matters...

how can I force the client to use a specific port?

----------

## richard.scott

From googling this up:

 *Quote:*   

> port=num — Specifies the numeric value of the NFS server port. If num  is 0 (the default), then mount queries the remote host's portmapper for the port number to use. If the remote host's NFS daemon is not registered with its portmapper, the standard NFS port number of TCP 2049 is used instead

 

I would assume that you would have to re-configure your nfs server to listen on that port. Also, you need to allow portmapper through your firewall to allow connections. Perhaps your firewall is miss-configured rather than the NFS setup being a problem

?

Where is the firewall that is causing problems? on the server, on the laptop or in between?

Is it possible to put the laptop on the same network as the NFS server (without firewall) and test?

----------

## fangorn

 *Quote:*   

> , for some reason

 

The reason is design.  :Wink: 

NFS up to version 3 uses multiple daemons. Responsible for this behaviour is portmap. AFAIK you cannot fix NFS v3.x to a specific port. 

NFS v4 AFAIK has the ability to specify a port and protocol for the connection - amongst multiple other changes/improvements/annoyances  :Twisted Evil: 

In short: 

If you have to go through a firewall, you are better off using Samba.

----------

## DaggyStyle

 *richard.scott wrote:*   

> From googling this up:
> 
>  *Quote:*   port=num — Specifies the numeric value of the NFS server port. If num  is 0 (the default), then mount queries the remote host's portmapper for the port number to use. If the remote host's NFS daemon is not registered with its portmapper, the standard NFS port number of TCP 2049 is used instead 
> 
> I would assume that you would have to re-configure your nfs server to listen on that port. Also, you need to allow portmapper through your firewall to allow connections. Perhaps your firewall is miss-configured rather than the NFS setup being a problem
> ...

 

sadly, I've seen this but it is no go...

 *fangorn wrote:*   

>  *Quote:*   , for some reason 
> 
> The reason is design. 
> 
> NFS up to version 3 uses multiple daemons. Responsible for this behaviour is portmap. AFAIK you cannot fix NFS v3.x to a specific port. 
> ...

 

samba is mainly for windows... I don't want to refrain from that. both machines are linux

----------

## depontius

 *DaggyStyle wrote:*   

> 
> 
>  *fangorn wrote:*    *Quote:*   , for some reason 
> 
> The reason is design. 
> ...

 

Can you move to NFS V4?  It sounds as if it has the port specification capability you need.  In addition, since you appear to be talking about a non-LAN connection to the laptop, NFS V4 also supports CacheFS.  (I run NFS V4 on my home LAN, though I haven't gotten around to CacheFS, yet.)

----------

## DaggyStyle

 *depontius wrote:*   

>  *DaggyStyle wrote:*   
> 
>  *fangorn wrote:*    *Quote:*   , for some reason 
> 
> The reason is design. 
> ...

 

what's a non lan laptop?

----------

## depontius

 *DaggyStyle wrote:*   

> 
> 
> what's a non lan laptop?

 

I got (somehow?) the impression that your laptop was an NFS client, but it was going to be routed to your NFS server instead of plugged into the same immediate network.  I guess others talked about firewalls and port filtering, not you.  But it left me with the impression of having a laptop on the road, wanting to VPN into your home NFS server.  (But then again, if you're using a VPN to get in, you're in, and you don't have to worry about port numbers.)

----------

## DaggyStyle

 *depontius wrote:*   

>  *DaggyStyle wrote:*   
> 
> what's a non lan laptop? 
> 
> I got (somehow?) the impression that your laptop was an NFS client, but it was going to be routed to your NFS server instead of plugged into the same immediate network.  I guess others talked about firewalls and port filtering, not you.  But it left me with the impression of having a laptop on the road, wanting to VPN into your home NFS server.  (But then again, if you're using a VPN to get in, you're in, and you don't have to worry about port numbers.)

 

I'll try to keep is simple.

I have a desktop which is a binhost.

I have a laptop which has no portage tree, I use nfs to mount the tree when updating the laptop.

problem is that mount nfs uses random ports.

----------

## depontius

Then the question becomes, "What freedom do you have to configure the machines?"

I'm presuming the problem here is that the desktop is running a firewall, and you want to keep it that way. 

From the man page :

```
       port=n         The  numeric value of the server's NFS service port.  If

                      the server's NFS service is not available on the  speci-

                      fied port, the mount request fails.

                      If  this  option  is  not specified, or if the specified

                      port value is 0, then the NFS client uses the  NFS  ser-

                      vice port number advertised by the server's rpcbind ser-

                      vice.  The mount request fails if the  server's  rpcbind

                      service  is  not  available, the server's NFS service is

                      not registered with its rpcbind service, or the server's

                      NFS service is not available on the advertised port.

       mountport=n    The  numeric  value of the server's mountd port.  If the

                      server's mountd service is not available on  the  speci-

                      fied port, the mount request fails.

                      If  this  option  is  not specified, or if the specified

                      port value is 0, then  the  mount(8)  command  uses  the

                      mountd  service  port  number advertised by the server's

                      rpcbind  service.   The  mount  request  fails  if   the

                      server's  rpcbind service is not available, the server's

                      mountd service is not registered with its  rpcbind  ser-

                      vice, or the server's mountd service is not available on

                      the advertised port.

                      This option can be used  when  mounting  an  NFS  server

                      through a firewall that blocks the rpcbind protocol.
```

Presuming you can tweak the nfs server, tweak the client, and tweak the firewall to match, does this do what you need?

----------

## DaggyStyle

mmm, I've missed the mountport thingie, thanks will try later but it will take time as I won't be home for the next two weeks due to holiday.

----------

