And hello!
Welcome to our demonstration,
where we're going to be working on our AlmaLinux 8.5 system,
and this is going to be the NFS server.
We'll be working on Ubuntu 20.04 as well,
and we're going to use this as our NFS client.
We're going to be creating then or exporting our shares on
AlmaLinux and mounting them on the Ubuntu system.
Here we are then working on AlmaLinux 8,
and I think we've become accustomed to this now.
It's a good friend of us.
Well, let's go through, take a look at our NFS packages.
On our Red Hat system, it's nfsutils.
And using yum list, we can see, ah, we've already got it installed.
Having it installed, though, isn't necessarily going to have the service running,
and we need to make sure that it's running.
When we look at our open ports, it's relatively quiet at the moment.
We've got port 22, our SSH server,
and we've got our port‑mapper service running on port 111,
but we certainly don't have NFS running.
If we go through and start this up, so we know to use systemctl and start,
and the service name is our nfs‑server,
now when we go back and look at our open ports,
we can see the huge difference that we've made.
So many, many ports are open.
And that's predominantly because we're supporting a
lot of legacy‑based NFS servers.
We can go through and disable many of these services,
and with Red Hat Enterprise Linux 8, we have a command,
nfsconf, that allows us to write to our configuration file.
Now we can either write to the configuration file,
or we could use the NFS configuration tool.
We're going to use the NFS configuration tool because it's new,
so we're going to use it.
Although, of course, you might prefer just to write to the configuration file,
and we'll take a look at that in a few moments.
So with nfsconf, I'm running as root, so we can run it straight off.
We can go through using ‑‑set.
And then the header that we want to write to in the files are nfsd,
and then our key and value.
Now, version 4 will be enabled,
but we want to enforce it to be enabled the same way
TCP transport will be enabled, but we want version 4 and TCP,
but that's pretty much all that we want.
So we can go through and specify to disable UDP connections.
They would be based around version 3.
And we can disable the complete version 3 protocol by using
then our vers3 and setting that to no.
Version 2 is already disabled by default.
Now, with that done, we've written through to the /etc/ and nfs.conf.
We can go through and open it up by taking a look at it with our less command,
and then as we page through, we want to be looking for that header,
nfsd, so we can page through our file.
We can see nfsd at the bottom now, so we're in the right header.
Let me just page down once more,
and we can see then the uncommented sections that I've made,
and the default that are shown with the comments.
So we've got the configuration settings that we need.
There are probably more services that we could disable,
but this is good to begin with.
Now, we've started our NFS server.
What we can do is go through and stop all of our services that start,
let's say, nfs*.
And then as we go through then and start our NFS server again,
we should have a reduced amount of ports that are opened this time.
As we go through now and look at our ss ‑ntl,
now we still have then a few ports, but certainly we've missed quite a few off,
and we can certainly trim down a lot more,
but we only need TCP port 2049 now.
If I go back and look with ss, and if we go through and remove the option ‑n,
we see the port names, and we only need the NFS ports name open.
Obviously, we need things like SSH to come through,
but we don't really need anything else open.
So when we're looking at firewalling this to allow our NFS traffic through,
we'd only need TCP port 2049.
Now, if I go through and take a look inside of my data directory,
I don't have a huge amount of data there,
but we've got a couple of pages,
so we can go through and share this out or export it,
as it's known as far as the NFS server is concerned.
So I can go through and edit the /etc/exports file,
but preferably,
we open up the .d directory and create our own .exports file inside of that.
So I'm creating the data.exports.
We're sharing out the /data directory.
Now we can use asterisks to share to everyone,
but if I know that I only want to share it out to my private network,
so 192.168.33.*, then that's to whom I'm sharing it.
The parentheses then describe any of the properties that I want to set.
I want to make this read write, and we can turn on the sync attribute as well,
so when a client writes, it's written through to disk straightaway.
Now, that's all I need to do.
So I can then go through and Escape and save my changes.
I can see my current exports by using the exportfs command.
So if I just use exportfs without any options,
it will print the current exports.
We haven't read it in yet.
So ‑r will allow me to read my exports file in,
so now exportfs shows me the /data is shared to the 192.168.33 system.
If I check my IP address for that network, I'm the .11 host.
So now moving out to my Ubuntu system,
we can make sure that our cache metadata is up to date.
So sudo apt update.
So this is just making sure the list of packages that we know
about from the Ubuntu repositories is up to date.
And then I can go ahead and use apt install.
So we have yum install, apt install, and zypper install,
depending on which operating system we are working.
Similarly, with all of the other packaging tools,
we get shown a list of packages that will go ahead and we can accept it,
or we can use the ‑y in installing it, and now our NFS client is ready to go,
so we can run our sudo and mount.
The IP address of our NFS server, or the host name if we had it configured,
colon, and then the export name, /data,
and we're going to mount to our directory /mnt,
and now, of course,
I'm going to see those two web pages when I list the mount directory out.
So there you go. We've seen our clients and server up and running.