NFS & NIS

NFS Server on Ubuntu 24.04

  1. apt update -y && apt upgrade -y
  2. apt install nfs-kernel-server -y
  3. vi /etc/hosts
    (Add the IP address of MyClient)
  4. mkdir /home1
  5. vi /etc/exports
    /home1 MyClient(ro,sync,no_subtree_check)
  6. /usr/sbin/exportfs -a

NFS Client

  1. apt install nfs-common
  2. vi /etc/hosts
    (Add the IP address of MyServer)
  3. ping -c 5 MyServer
  4. On MyServer,
  5. On MyClient,
  6. On MyServer
    1. Edit /etc/exports. Change the option "ro" to "rw".
    2. exportfs -a
    3. chmod 777 /home1
  7. Now MyClient can write files into that directory:
  8. Your client would certainly want to mount the file system at a permanent mounting point instead of /mnt.

NIS Server

  1. apt install nis -y
  2. vi /etc/default/nis
    NISMASTER=MyMaster # MyMaster is defined in /etc/hosts
  3. vi /etc/yp.conf
    domain OLYMPUS server MyMaster
  4. domainname OLYMPUS
  5. vi /etc/defaultdomain
    OLYMPUS
  6. vi /etc/ypserv.securenets
          #0.0.0.0                0.0.0.0
          #::/0
          255.255.255.0   10.100.111.0
  7. systemctl start ypserv yppasswdd ypxfrd
  8. systemctl enable ypserv yppasswdd ypxfrd
  9. /usr/lib/yp/ypinit -m
  10. reboot

Add a group or a user

  1. groupadd -g 1000 spain # Notice the GID must be >= 1000
  2. useradd -u 2000 -g spain -s /bin/bash -d /home1/alice -m alice
  3. useradd -u 2001 -g ncnu -d /home1/bob -s /bin/bash -m bob
  4. echo 'bob:0492915225' | chpasswd
  5. cd /var/yp; make

NIS Client

  1. server-world.info/en/note?os=Ubuntu_22.04&p=nis&f=2
  2. apt update -y && apt upgrade -y
  3. apt install nis -y
  4. vi /etc/hosts
    (Add the IP address of MyServer)
  5. ping -c 5 MyServer
  6. vi /etc/yp.conf
    domain OLYMPUS server MyServer
  7. vi /etc/nsswitch.conf
    Append " nis" at the end of lines about "passwd", "shadow", "group", "hosts".
  8. vi /etc/defaultdomain
    OLYMPUS
  9. systemctl restart rpcbind nscd ypbind
  10. systemctl enable rpcbind nscd ypbind
  11. ypcat group
  12. ypcat passwd
  13. You can log into both MyServer and MyClient as "bob", with the same password.
  14. If you create a file, bob can see it on both hosts.
  15. On MyClient, bob may change his password by "yppasswd". After that, logging into MyServer also be authenticated by the new password.