NFS server configuration in RedHat operating system.

In article below you will find information how to enable NFS server service on RedHat Enterprise OS.

1.  Check server configuration:

– if any fs/directory are already exported:

# cat /etc/exports

# exportfs -v

– if nfs server services are enabled:

# rpcinfo -p
program vers proto   port
100000    2   tcp    111  portmapper
100000    2   udp    111  portmapper
100024    1   udp    954  status
100024    1   tcp    957  status

# service portmap status
portmap (pid 3294) is running…

# service nfs status
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped

# service nfslock status
rpc.statd (pid 3319) is running…

We saw that no fs/directory are shared nor NFS server services are enabled however protmap and nfslock are running.

2. Enable NFS server.

– starting nfs server and checking status:

# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

# service nfs status
rpc.mountd (pid 7559) is running…
nfsd (pid 7556 7555 7554 7553 7552 7551 7550 7549) is running…
rpc.rquotad (pid 7524) is running…

– enabling nfs autostart after reboot

# chkconfig nfs on

# chkconfig –list nfs
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

– checking if nfs services started working:

# rpcinfo -p
program vers proto   port
100000    2   tcp    111  portmapper
100000    2   udp    111  portmapper
100024    1   udp    954  status
100024    1   tcp    957  status
100011    1   udp    917  rquotad
100011    2   udp    917  rquotad
100011    1   tcp    920  rquotad
100011    2   tcp    920  rquotad
100003    2   udp   2049  nfs
100003    3   udp   2049  nfs
100003    4   udp   2049  nfs
100021    1   udp  50488  nlockmgr
100021    3   udp  50488  nlockmgr
100021    4   udp  50488  nlockmgr
100003    2   tcp   2049  nfs
100003    3   tcp   2049  nfs
100003    4   tcp   2049  nfs
100021    1   tcp  47549  nlockmgr
100021    3   tcp  47549  nlockmgr
100021    4   tcp  47549  nlockmgr
100005    1   udp    952  mountd
100005    1   tcp    956  mountd
100005    2   udp    952  mountd
100005    2   tcp    956  mountd
100005    3   udp    952  mountd
100005    3   tcp    956  mountd

3. Share directory.

– listing already exported resources:

# showmount -e localhost
Export list for localhost:

– creating entry for folder /test

vi /etc/exports

# cat /etc/exports
/test 10.10.10.8(rw,sync,root_squash)

– exporting new configuration:

# exportfs -r

– checking if new shared resource is visible on serwer:

# showmount -e localhost
Export list for localhost:
/test 10.10.10.8

or

# exportfs -v

/test           10.10.10.8(rw,wdelay,root_squash,no_subtree_check,anonuid=65534,anongid=65534)

4. Mount shared directory on client side.

– checking if client see exported resource:

# showmount -e 10.10.10.7
Export list for 10.10.10.7:
/test 10.10.10.8

– creating folder for mount point

# mkdir /mnt/remote

– mounting resource

# mount 10.10.10.7:/test /mnt/remote

– checking if it is visible:

# df -h /mnt/remote
Filesystem            Size  Used Avail Use% Mounted on
10.10.10.7:/test      5.8G  3.4G  2.1G  62% /mnt/remote

5. NFS server on firewalled systems.

To use NFS with firewall we need to force nfs services  to use static ports not those assigned randomly by portmap.

In file /etc/sysconfig/nfs we need to add following lines:

MOUNTD_PORT=”4002″

STATD_PORT=”4003″

LOCKD_TCPPORT=”4004″

LOCKD_UDPPORT=”4004″

RQUOTAD_PORT=”4005″

STATD_OUTGOING_PORT=”4006″

Then restart nfs service:

# service nfs restart
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

and check if new settings were applied:

# rpcinfo -p
program vers proto   port
100000    2   tcp    111  portmapper
100000    2   udp    111  portmapper
100024    1   udp    954  status
100024    1   tcp    957  status
100011    1   udp   4005  rquotad
100011    2   udp   4005  rquotad
100011    1   tcp   4005  rquotad
100011    2   tcp   4005  rquotad
100003    2   udp   2049  nfs
100003    3   udp   2049  nfs
100003    4   udp   2049  nfs
100021    1   udp   4004  nlockmgr
100021    3   udp   4004  nlockmgr
100021    4   udp   4004  nlockmgr
100021    1   tcp   4004  nlockmgr
100021    3   tcp   4004  nlockmgr
100021    4   tcp   4004  nlockmgr
100003    2   tcp   2049  nfs
100003    3   tcp   2049  nfs
100003    4   tcp   2049  nfs
100005    1   udp   4002  mountd
100005    1   tcp   4002  mountd
100005    2   udp   4002  mountd
100005    2   tcp   4002  mountd
100005    3   udp   4002  mountd
100005    3   tcp   4002  mountd

Then we need to add new rules to our firewall and restart iptables service.

Rules  need to be added in /etc/sysconfig/iptables file:

-A CLASS-RULES -s 10.10.10.0/24 -p tcp –dport 111 -j ACCEPT

-A CLASS-RULES -s 10.10.10.0/24 -p udp –dport 111 -j ACCEPT

-A CLASS-RULES -s 10.10.10.0/24 -p tcp –dport 4002:4005 -j ACCEPT

-A CLASS-RULES -s 10.10.10.0/24 -p udp –dport 4002:4005 -j ACCEPT

-A CLASS-RULES -s 10.10.10.0/24 -p tcp –dport 2049 -j ACCEPT

-A CLASS-RULES -s 10.10.10.0/24 -p udp –dport 2049 -j ACCEPT

# service iptables restart

One Response to “NFS server configuration in RedHat operating system.”

  1. guest says:

    How to access this folder from Client

Leave a Response