Network Routing Overview

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:01
>> Hello Cybarians and welcome back to
00:01
the Linux plus course here in Cybrary,
00:01
I'm your instructor, Rob Geils,
00:01
and in today's lesson we're going to
00:01
be discussing network routing.
00:01
Upon completion of today's lesson,
00:01
you're going to be able to explain network routing,
00:01
know how to use the route,
00:01
and ip commands, and also set a persistent route.
00:01
Routing is simply sending data from point to another.
00:01
We're sending data from one point
00:01
to another through a gateway.
00:01
The gateway is an important thing
00:01
to consider here because that's
00:01
what's connecting two different networks together.
00:01
Routing can be very straightforward,
00:01
but there are a lot of
00:01
different ways to work with routing in Linux,
00:01
and that's what makes it complicated.
00:01
At left, there are three different routing commands,
00:01
all of them display routing information,
00:01
so this is where it starts to get complicated.
00:01
Route and netstat-r display a routing table.
00:01
Route-n displays the destination numerically.
00:01
So in other words, it's not going to convert
00:01
the ips into our host names,
00:01
just going to display the ip addresses.
00:01
Netstat-r displays a different column
00:01
info than the other ones,
00:01
and then finally, ip route show is more
00:01
of a collapsed output of routing.
00:01
Now what we can generally see is all of
00:01
these have a destination column,
00:01
at least the first three.
00:01
That shows the destination network or host,
00:01
and the gateway column shows
00:01
the gateway that is used by the network or host
00:01
to get connected to something
00:01
else to go through to hop to the next network.
00:01
The flags column that we see in the first
00:01
three of these commands can indicate a few things,
00:01
and it depends on the flag.
00:01
U means the host is up,
00:01
G means use gateway, and H,
00:01
we don't really see here, but H indicates that
00:01
the target we're trying to get
00:01
>> through is a host itself.
00:01
>> The metric column shows
00:01
the distance to the target and hops.
00:01
So how many hops?
00:01
How many connection points do you need to
00:01
go through to get to the target?
00:01
An interface column specifies
00:01
the interface that will handle traffic for this route.
00:01
In this case, on
00:01
this system that was the abundant system,
00:01
I took screenshots from my own system.
00:01
You can see the interface is all the same.
00:01
But if we had a system
00:01
rather that was connected to
00:01
>> multiple different networks,
00:01
>> we might have different interfaces for
00:01
different networks on different networks,
00:01
and you would see the different interfaces
00:01
>> here to route
00:01
>> things between different networks
00:01
depending upon the interface that is going out of.
00:01
Now the route command in
00:01
Linux is specifically built for routing.
00:01
If you use it with no options,
00:01
it's just going to give you a routing table,
00:01
and you can add or delete a route
00:01
using route add or route delete.
00:01
So route add,
00:01
the target you want to go to,
00:01
the gateway you're going to use,
00:01
and the ip address,
00:01
and then the same thing for route delete.
00:01
Route delete target gateway ip address, however,
00:01
the changes with the route command are not persistent.
00:01
Now, you can also do
00:01
network routing using the ip command.
00:01
Again, the ip command we talked about previously,
00:01
very versatile, you'll use it a lot.
00:01
ip command can be used and we can just use
00:01
ip route by itself to give us a collapsed
00:01
>> routing table.
00:01
>> You can add or delete a route by using;
00:01
ip route add, target,
00:01
via gateway device interface.
00:01
Then we can delete one here more simply,
00:01
we can just do ip route delete and specify the target.
00:01
But just as we saw previously with this,
00:01
the changes with using any ip command or
00:01
the route command, are not persistent.
00:01
This is just something that you could do.
00:01
If you felt that you had a route issue,
00:01
you would just go ahead and maybe set up
00:01
a route here to see if that would fix your issue,
00:01
and then if it did, you could go ahead and create it
00:01
persistently in another place.
00:01
The place to do that in CentOS is to
00:01
do a gateway line in the interface file.
00:01
You can enter into etc,
00:01
sysconfig network scripts, ifconfig interface.
00:01
In our case, AMPA is 0S3,
00:01
we can enter into that a gateway line that indicates
00:01
the gateway we're going to go out
00:01
for that specific network on the interface,
00:01
or we can also create a route file.
00:01
We can do etc's sysconfig network
00:01
scripts route dash interface,
00:01
and create a route file that contains
00:01
the routes that are going to use
00:01
that interface to get out.
00:01
Now if you're in Ubuntu,
00:01
you have two options for persistence as well.
00:01
One is to enter a routes section
00:01
into the net plan YAML config,
00:01
and we remember netplan is configured an etc netplan,
00:01
the name of the interface,
00:01
so the name of the connection dot YAML.
00:01
Or you can also modify the interface
00:01
using nmcali or nmtui,
00:01
those two commands we covered in the previous lesson.
00:01
But with that being said, in this lesson,
00:01
we covered network routing in Linux.
00:01
We talked about how to use the route command,
00:01
and we talked about how ip
00:01
and netstat commands can be used for routing,
00:01
and how to set up a persistent route.
00:01
Thanks so much for being here and I look
00:01
forward to seeing you in the next lesson.
Up Next