Passa ai contenuti principali

Linux CentOS 7 - NFS configuration

Linux CentOS 7 - NFS Configuration

Setup:

2 systems, sysmtem1 and system2 in the example.com domain;
IP address of interface ens33 on system1: 192.168.189.140/24
IP address of interface ens33 on system2: 192.168.189.141/24

CentOS version 7.6

Export a public directory on system1 with read-only access to system2.example.com

On system1.example.com:

yum install nfs* -y

vim /etc/sysconfig/nfs

       RPCNFSDARGS="-V4.2"

systemctl enable nfs-server
systemctl start nfs-server

firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --reload

mkdir /public
chmod 777 /public

getsebool -a | grep nfs (no changes required on default settings)

semanage fcontext -a -t public_content_t '/public(/.*)?'
restorecon -RFv /public

vim /etc/exports

/public *.example.com(ro,sync)

exportfs -var

systemctl restart nfs-server

showmount -e localhost

On system2.example.com:

yum install -y nfs-utils

vim /etc/sysconfig/nfs

        RPCNFSDARGS="-V4.2"

mkdir /mnt/public

vim /etc/fstab

192.168.189.141:/public     /mnt/public   nfs   defaults 0 0

Verify results

1) on system1:
touch /public/123

on system2:
ll /mnt/public

should show file 123

2) on system2:

touch /mnt/public/456
should give an error

If you experience any problem with this configuration, please let me know.



Commenti

Post popolari in questo blog

Linux CentOS 7 - Mounting the iso file as a CD-ROM

Linux CentOS 7 - Mounting the iso file as a CD-ROM in a repo Mount the iso file as a CD-ROM in a repository. Provided your iso file contains the complete operative system, this allows you to disable the default repositories and mirrors and install all required packages without downloading them from the internet. In other words you can work off-line. On system1 and/or system2 Edit the repo file vim /etc/yum.repos.d/CentOS-CD.repo [CentOS-CD] name =  CD ROM baseurl = file:///media/CentOS gpgcheck = 0 enabled = 1 Mount the iso file as a CD-ROM in a repository. Make a mount point mkdir /media/CentOS Edit the fstab file /dev/cdrom     /media/CentOS   iso9660   loop 0 0 mont -a Verify df -Th it must return the /dev/loop0 disk yum repolist it must show the repositories contained in the iso file.

Linux CentOS 7 - Configuring a cache-only DNS

Linux CentOS 7 - Configuring a cache-only DNS Configure a cache only DNS server which forwards requests to the well known Google DNS server. On system1 Install the unbound package # yum install -y unbound Enable and start the service # systemctl enable unbound && systemctl start unbound Adjust the configuration file # vim /etc/unbound/unbound.conf interface: 0.0.0.0                       ## all interfaces access-control: 0.0.0.0/0 allow ## from all networks forward-zone      name: "."                              ## from any domain      forward-addr: 8.8.8.8           ## DNS server towards which all requests will be forwarded Check configuration  # unbound-checkconf Modify the DNS server on the interface configuration # vim /etc/sysconfig/network-scripts/ifc...

Linux CentOS 7 - Basic scripting

Linux CentOS 7 - Basic scripting Configure a bash script called  foo.sh; this script reads an input parameter: if the input is "A", it returns "B"; if the input is "B", it returns "A"; otherwise it shows the message "usage foo.sh A|B" On system1 Edit the file: # vim /root/foo.sh #!/bin/bash if [ "$1" == "A" ]; then echo "B" elif [ "$1" == "B" ]; then echo "A"             e lse echo "/root/foo.sh A|B" fi Change the permissions to make it executable by all; # chmod a+x foo.sh Test it: # ./foo.sh A B Configure a script called makeusers.sh which reads a list of users from a file and creates those users with the /bin/false shell;   On system 1 Edit the script vim makeusers.sh #!/bin/bash if [ $# = 0 ]; then echo "usage makeusers.sh <users file>" exit 1 elif [ -f $1 ]; then for i in `cat $1`; do usera...