Network File System (NFS) is useful to share space on other computers.
In this scenario we are going to configure NFS server on 10.1.1.15 host and NFS client on 10.1.1.17 machine.
1. Prerequisites
Install nfs-common package on both NFS client and NFS server using following command.
$ sudo apt-get install nfs-common
Additionally we need to install extra package on NFS server (10.1.1.15)
$ sudo apt-get install nfs-kernel-server
This package is the actual NFS daemon listenning on both UDP and TCP 2049 ports. And portmap should be waiting for instructions on a port 111.
2. Create NFS Share on NFS Server (10.1.1.15)
Create a directory to share on NFS server(10.1.1.15).
Run following command on NFS server.
$ mkdir /home/kailas
3. Apply Access Control Rules
In our scenario we want only 10.1.1.17 to access the nfs share.
Therefore, open /etc/exports file in any text editor (such as vi, gedit, or emacs) on NFS server (10.1.1.15).
Add following line in (/etc/exports) file.
A. Read/Write Permissions
/home/kailas/ 10.1.1.17(rw,sync)
Above line specifies that export /home/kailas directory for host with IP 10.1.1.17 with read, write permissions, synchronized mode.
B. Only Read Permissions
If you don't want to give write permission and only want to give read permission to client (10.1.1.17) then instead of above line use following line.
/home/kailas/ 10.1.1.17(ro,sync)
C. Read/Write + Root privileges
/home/kailas/ 10.1.1.17(rw,sync,no_root_squash)
Above line in "/etc/exports" file will export /home/kailas directory for host with an IP address 10.1.1.17 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
D. Read/Write Privilege to all computers on network
/home/kailas/ *(rw,sync)
Above line indicates, export /home/kailas directory for any host with read, write permissions and synchronized mode.
E. Read Privilege to All computers on network
/home/kailas/ *(ro,sync)
Above line indicates, export /home/kailas directory for any host with read only permissions and synchronized mode.
3. Restart NFS daemon
Use following command on Ubuntu to restart NFS service.
$ sudo /etc/init.d/nfs-kernel-server restart
Note: After any modification you will made in "/etc/exports" file please restart NFS service to reflect your changes.
4. Mount NFS directory on client (10.1.1.17) machine
NFS client needs portmap service, simply install nfs-comman package on client (10.1.1.17)
$ sudo apt-get install nfs-common
Make sure portmap service is running:
$ sudo service portmap status
Sample outputs:
portmap start/running, process 4193
If not just start it:
$ sudo service portmap start
Create a mount directory on Client (10.1.1.17)
$ sudo mkdir /nfs
$ sudo mount 10.1.1.15:/home/kailas /nfs/
To see the content of the directory use following command.
$ ls /nfs
5. Configure automount
To make this completely transparent to end users, you can automount the NFS file system every time a user boots a Linux system. Simply edit "/etc/fstab" to mount system automatically during a system boot. You can use your favorite editor and create new line like this within /etc/fstab:
10.1.1.15:/home/kailas /nfs/ nfs defaults 0 0
6. Appendix
If above steps doesn't work then please try to stop iptables or configure iptable rules to allow nfs communication.
# service iptables stop
In this scenario we are going to configure NFS server on 10.1.1.15 host and NFS client on 10.1.1.17 machine.
1. Prerequisites
Install nfs-common package on both NFS client and NFS server using following command.
$ sudo apt-get install nfs-common
Additionally we need to install extra package on NFS server (10.1.1.15)
$ sudo apt-get install nfs-kernel-server
This package is the actual NFS daemon listenning on both UDP and TCP 2049 ports. And portmap should be waiting for instructions on a port 111.
2. Create NFS Share on NFS Server (10.1.1.15)
Create a directory to share on NFS server(10.1.1.15).
Run following command on NFS server.
$ mkdir /home/kailas
3. Apply Access Control Rules
In our scenario we want only 10.1.1.17 to access the nfs share.
Therefore, open /etc/exports file in any text editor (such as vi, gedit, or emacs) on NFS server (10.1.1.15).
Add following line in (/etc/exports) file.
A. Read/Write Permissions
/home/kailas/ 10.1.1.17(rw,sync)
Above line specifies that export /home/kailas directory for host with IP 10.1.1.17 with read, write permissions, synchronized mode.
B. Only Read Permissions
If you don't want to give write permission and only want to give read permission to client (10.1.1.17) then instead of above line use following line.
/home/kailas/ 10.1.1.17(ro,sync)
C. Read/Write + Root privileges
/home/kailas/ 10.1.1.17(rw,sync,no_root_squash)
Above line in "/etc/exports" file will export /home/kailas directory for host with an IP address 10.1.1.17 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
D. Read/Write Privilege to all computers on network
/home/kailas/ *(rw,sync)
Above line indicates, export /home/kailas directory for any host with read, write permissions and synchronized mode.
E. Read Privilege to All computers on network
/home/kailas/ *(ro,sync)
Above line indicates, export /home/kailas directory for any host with read only permissions and synchronized mode.
3. Restart NFS daemon
Use following command on Ubuntu to restart NFS service.
$ sudo /etc/init.d/nfs-kernel-server restart
Note: After any modification you will made in "/etc/exports" file please restart NFS service to reflect your changes.
4. Mount NFS directory on client (10.1.1.17) machine
NFS client needs portmap service, simply install nfs-comman package on client (10.1.1.17)
$ sudo apt-get install nfs-common
Make sure portmap service is running:
$ sudo service portmap status
Sample outputs:
portmap start/running, process 4193
If not just start it:
$ sudo service portmap start
Create a mount directory on Client (10.1.1.17)
$ sudo mkdir /nfs
$ sudo mount 10.1.1.15:/home/kailas /nfs/
To see the content of the directory use following command.
$ ls /nfs
5. Configure automount
To make this completely transparent to end users, you can automount the NFS file system every time a user boots a Linux system. Simply edit "/etc/fstab" to mount system automatically during a system boot. You can use your favorite editor and create new line like this within /etc/fstab:
10.1.1.15:/home/kailas /nfs/ nfs defaults 0 0
6. Appendix
If above steps doesn't work then please try to stop iptables or configure iptable rules to allow nfs communication.
# service iptables stop
No comments:
Post a Comment