• Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
No Result
View All Result
Home Tutorials

How To Install NFS on CentOS 8 & Ubuntu 20.04+: Network Shared Folder Between VPS/Server

by Sick Codes
May 17, 2020 - Updated on June 24, 2020
in Tutorials
0

NFS allows you to share a directory with another server/client. It’s awesome.

This works great for VPC, or virtually connected servers, like Vultr Private Networking NFS.

In this tutorial we are connecting a CentOS 8 to an Ubuntu 18.04

I will show you how to do it both directions!

Note we are ALSO installing the client and server on BOTH. Kind of like a loop!

/mnt/share is the place we are going to read from
/opt/share is the place we are going share from

Add both server IP’s to the /etc/hosts on both machines. Use the internal IP’s if you are doing Private Networking.

# CentOS/RHEL 8 
yum install epel-release -y
yum install nfs-utils nfs4-acl-tools -y
# Ubuntu
apt-get install nfs-kernel-server nfs-common -y

Then we need to have both of their IP’s on the hosts files.

# on both machines
echo << EOF >> /etc/hosts
11.11.11.11 centos.guy
22.22.22.22 ubuntu.guy
EOF

Now, have to pick one to share and which one to receive.

In this example I am sharing Ubuntu’s disk.
Then at the bottom I have another example of the opposite direction.

Share an Ubuntu 18.04 Drive via NFS

# Exporting server (Ubuntu 18.04)
mkdir /opt/share
chown nobody:nogroup /opt/share
chmod 755 /opt/share
cat << EOF >> /etc/exports
/opt/share           22.22.22.22(rw,sync,no_subtree_check)
EOF

exportfs -r

# open firewall to 11.11.11.11, or the IP that is going to read my drive
ufw allow proto any from 11.11.11.11

CentOS will read it.

Read a CentOS 8 Drive via NFS

# Mounting server (CentOS 8)

mkdir /mnt/share
mount -t nfs 11.11.11.11:/opt/share /mnt/share

Share a CentOS 8 Drive via NFS

Doing the opposite (Share CentOS drive and read on Ubuntu)

# Exporting server (CentOS 8)
mkdir /opt/share
chown nobody:nobody /opt/share
chmod 755 /opt/share
cat << EOF >> /etc/exports
/opt/share           11.11.11.11(rw,sync,no_subtree_check)
EOF

exportfs -r

# open firewall to 22.22.22.22, or the IP that is going to read my drive
firewall-cmd --zone=home --add-rich-rule='rule family="ipv4" source address="22.22.22.22" accept'
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload

# start the server
systemctl enable --now nfs-server

Read an Ubuntu Drive via NFS

# Mounting server (Ubuntu 18.04)
mkdir /mnt/share
mount -t nfs 22.22.22.22:/opt/share /mnt/share

The only difference between the two sets of commands above are the following:

On CentOS you must chown the sharing folder as nobody:nobody
On Ubuntu you must chwon the sharing folder as nobody:nogroup

On CentOS you must run systemctl enable –now nfs-server
On Ubuntu you dont need to start the server

On CentOS 8, firewall-cmd is used to allow incoming connections.
On Ubuntu 18.04+, ufw is used to allow incoming connections.

Next Post

Linux Lenovo WiFi Card Linux Not Working, rtl8821ce, Slow Boot Process, A Job is running 1 minute 30 seconds.

TUN/TAP Deleted/Broken Linux: qemu-system-x86_64: could not open /dev/net/tun: Permission denied

How To Install Kubernetes on CentOS 8 (Easy Way) + Docker.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training

© 2017-2021 Sick.Codes

@sickcodes

@sickcodes

@sickcodes

Discord Server

sickcodes.slack.com

t.me/sickcodeschat

./contact_form