Now, for our first demonstration, we're going to treat
you to something absolutely amazing.
We're going to be working with both openSUSE and Alma Linux. So fire
those two bad boys up, and we're going to be taking a look at how we can
investigate using the command, ip. Now the reality is, it doesn't matter
so much which system we are working on because we have a little bit of
standardization here.
If I use the command ip and then address show, we can see, well,
would you believe it, our IP addresses. Now many people who have
been working with Linux for a little while might be used to the
ifconfig command. When we take a look though, in most distributions,
ifconfig is no longer here.
We could probably find packages that contained it, but the idea
is that we can use the one tool pretty much to display
everything. Now I ran it longhand before, so the command is ip,
and then we've got subcommands,
address. But I can abbreviate this so long as the subcommand is
going to be uniquely identified, so I can use ip a. I don't need
the show because the show is the default option for the address,
so I can just go ip a.
Now sticking with this, I can do an ip r to look at my route
table. I can look at ip n for neighbor show. With our neighbor
show, we're looking at our ARP cache.
So as I communicate through to IP addresses, we have to
convert an IP address to its logical link layer address, its
lladr, if it's on the same network.
So we actually communicate with a MAC address when we're on the same network as
another IP address. When I go through and, again, just take a look at my IP
address, I can change this just to IPv4 addresses.
So we can then drill down just to see the IPv4 address.
Now I've got two network cards, eth0 and eth1.
If I want to see those network cards,
I can run an ip link or ip l. I'll move that to the top so we can see that a
little bit clearer, and we can see then the eth0 and eth1.
Of course, we've got the loopback, the local interface as well.
When I take a look at the IP address, so I can do ip ‑4 a s for
eth1, I have to put the extra option show so they realize then that
eth1 is an argument to show and not to address. Now on the second or
the eth1 Ethernet card that we're looking at, I've added them to the
192.168.33 network.
I should be able to then ping through to 192.168.33.11, which
is the IP address of my Alma Linux system.
Just do a Ctrl+C just to stop that.
What I can also do, if I do an ip a a, and this is where we get really
good, and let's do, let's say, 172.16.1.1, and we can have, let's say, a
16‑bit network, so we're on the network 172.16 and we're node 1.1, and
we're going to add this to dev eth1.
Now when we look at this, I'm able to see my IP address and
display information as a standard user, but I'm not allowed to
change the configuration, so I can run a sudo !!. Now if I do an
ip, let's just go and up arrow key,
we can see that I've got the 172 address assigned to that as well.
So if I do a Ctrl+C, move out to my Vagrant system,
paste this in, don't want to execute the command because I need to change
the IP address, but let's put this to the IP address 2.
Now we're looking here. It's saying we don't have that device.
Well, let's go through and just take a look, ip link. So we've detected the
network cards in a different manner here, so that's okay.
We can up arrow key, and we can then go through an add in enp0s8.
So it's looking at the hardware address of the network card.
And now when I do an ip ‑4 a s for that last argument, we can
see that we've got the two IP addresses.
If I do an ip r s, we know about all of the networks that we
are connected to, so we see the 192 network,
the 172 network, and the 10 network.
I should be able to now go through and ping 172.16.1.1, the openSUSE
system where we added in the IP address before. Now we may also remember
that we have the neighbor show or our ARP cache.
So if I go through now and take a look at ip n, I can see that I've got
entries in for the 172.16.1 system, the 192.168.33.12 system.
These are all devices that I have communicated with.
We can see that the .12 system has become stale, as I haven't
communicated recently. But as I've just connected through to the
192.168.1.1 system with that ping, we're able to see it now in my ARP
cache because remember, if we're on the same network, then we are
communicating via the MAC address and not actually the IP address. The
IP address is a network layer address, and we need to drop down to our
logical link layer address.
There you go, there's something for you.
But at least we've got consistency with our IP command,
being able to manage everything pretty much as far as our networking is concerned.