Now we're going to drop out to Ubuntu 20.04 and take a look at Netplan.
Now Netplan will have a whole load of YAML files that we will be
able to find underneath the /etc/netplan directory.
Some of the commands that we can use is that we can go through
and take a look at our DHCP lease that's coming in from
enp0s3. Again, on Ubuntu by default,
we're using the naming of our network card based upon its hardware location.
If we take a look at the netplan and 50‑vagrant.yaml file, it is this
file that has the IP address, the static IP address configuration, for
our second network interface, so that's enp0s8.
If we want to, we can go and add in a second IP address to our list. This
is adding it into the back end so it won't show as an IP address once
we've added it in. We can apply the configuration in a temporary format
with netplan and try. By default, there is a timeout of 120 seconds, so
we can allow this 120 seconds to run through. If we haven't pressed Enter
in the time, the setting won't be applied.
If we have allowed the timeout to be implemented,
we would have lost our configuration. It's still in our file though.
If we are happy for it to be applied,
we can run netplan apply, and it will, of course, apply the configuration.
Come on,
let's find Ubuntu and take a look at configuring our network with netplan.
So here we are on our Ubuntu system.
Let's gain some administrative privileges.
So again, I'm just doing sudo ‑i, pretty much as we've seen then on the
other systems. Again, I can go through and do my ip ‑4 and a and s for
enp0s8. So this is the second network card, and we can see here that
we've got the address of 33.13.
Now using netplan, our storage is as YAML files.
These YAML files we're going to be able to find
listed in the /etc/netplan directory.
Now here we've got two, one we can see comes from
cloud‑init and one from vagrant.
When we take a look at the cloud‑init,
this will be for our first network card, which is really the Vagrant
network card that we use with our vagrant ssh. We can see that this is
then our enp0s3 and is a DHCP‑assigned address.
If we take a look at the second one, so 50‑vagrant, this is the additional
network card that I added in in the Vagrant file and is on our private
network, and we can see that we've got a statically assigned address at the
moment of 33.13 on that 192.168.33 network.
So this gives us a little idea of how the configuration
is set or where it's coming from.
But we also have the netplan command, and I can go
through and take a look at my DHCP leases,
so netplan ip leases for my network card,
enp0s3. And we can see the IP address that we've been
given. I can see, obviously, the netmask,
the default gateway,
the server that gave me the IP address. We've also got the
timeout, so our lease lasts for a day,
86,400 seconds. But we try and renew that lease at half
the lease period, so that's 43,200.
But if we are unable to renew at that time, we will
try again where the lease is 75,600.
So we can see some of our information and where we can read that information.
But of course, we can also go through and make changes to our configuration.
We're going to go through and add in a static IP address to our
Vagrant file, so where we've got the .13 address. Now this is a
YAML list. YAML is space‑sensitive, so make sure that we are
aligning using spaces, not using tabs.
A list item starts with a dash, and then we're putting in 172.16.1.3 on
a 16‑bit network, so this then corresponds to the addresses that we've
been using before. Now if I go through and display the address, it won't
have changed anything at the moment because our memory resident IP
addresses won't have been loaded with the information from the back end
configuration.
Now we can do this with our netplan apply,
but if you want to test the configuration,
which might be a good idea if we are remoting in, then we can use netplan
and try. The idea of this is that we can then revert. The default period
or timeout is 120 seconds. Now I could do that, but I don't really want to
wait the 120 seconds or 2 minutes, so I'm going to specify my own custom
timeout, and let's see if I can get everything that I need to get done in
this period.
So if I use ‑‑timeout=15, then that gives me a 15‑second period where the
configuration is made. It will revert after that 15 seconds.
So we've made the configuration change. Now the IP address will be
applied. Moving back out to my Red Hat system,
the Alma 8,
I should be able to ping then 172.16.1.3. So we still have the IP address
assigned on the Alma Linux system, but we can see now we've lost the IP
address. The timeout has been applied. So if I move back to Ubuntu, we can see
there that our timeout had applied and we reverted.
If I was happy with that and it was all working,
then I can go through and just use netplan apply, and it just then
applies the configuration. And as I return now to Alma 8, we're able
to see then that we're getting our ping response coming back again as
the IP address has fired up.
So there you go.
There's a little bit about the back end systems that manage the IP configuration within Ubuntu.