NFS Server & Client

Steps to create an NFS Server and mount the remote directory. My lab server IP is “192.168.1.72”.

Server

  1. Install the nfs utilities.

    sudo dnf install nfs-utils -y
    
  2. Start the nfs-server daemon.

    sudo systemctl enable --now nfs-server
    
  3. Verify the listener.

    rpcinfo -p | grep nfs
    
  4. Create the directory, set the owner, and permissions.

    sudo mkdir -p /mirror/nfs
    sudo chown -R nobody: /mirror/nfs
    sudo chmod -R 777 /mirror/nfs
    
  5. Restart the nfs utilities.

    sudo systemctl restart nfs-utils
    
  6. Update “/etc/exports”.

    Note

    Set the subnet to match your requirements. In this example I’m allowing all clients on subnet “192.168.1.0/24” access to the mount.

    echo "/mirrro/nfs 192.168.1.0/24(rw,sync,no_all_squash,root_squash)" | sudo tee -a /etc/exports
    
  7. Export and check mount.

    sudo exportfs -arv
    sudo exportfs -s
    
  8. Update firewall to allow nfs.

    sudo firewall-cmd --add-service=nfs --permanent
    sudo firewall-cmd --reload
    sudo firewall-cmd --list-all
    

    Note

    For older nfs clients you may need to open the following ports

    sudo firewall-cmd --add-service={nfs3,mountd,rpc-bind} --permanent
    sudo firewall-cmd --reload
    

Client

  1. Install the nfs utilities.

    sudo dnf insatll nfs-utils -y
    
  2. Create the mount directory.

    sudo mkdir -p /mnt/nfs
    
  3. Mount the remote nfs directory.

    sudo mount -t nfs 192.168.1.72:/mirror/nfs /mnt/nfs
    
  4. Verify nfs mount.

    mount | grep -i nfs