Hey guys and welcome back. So now what we're going to talk about is relating to networking.
So obviously networking is a very, very important concept with respect to systems administration.
Networking is how different devices can communicate with one another. And naturally that ability
to communicate, well it's indispensable therefore we as Linux engineers, we have to understand
how basic networking actually operates as well as what tools we can use to help us configure
some basic networking settings. And we also want to have a decent grasp of the theory
of networking so that when something goes wrong we are adequately able to troubleshoot
that problem. So we will be talking about some of the theory behind networking so we
can do such a thing, we can troubleshoot these issues and we will be looking at some of the
tools and utilities that we can use to help us along the way. So the very first thing
that I want to talk to you about is all about interfaces. Now when we are talking about a
network interface, all we are talking about is a point of interconnection between one
device and another device. So simply put we may have one computer here and a second one
here. We would have a cable attached connecting them, this would be something called like
an ethernet cable. And where you would actually plug this ethernet cable would be on the
interface of this device and the interface of this device. Now these interfaces actually
need to have very particular settings in order for this communication to work. Say for example
if you want to be able to communicate over IP then these interfaces would have to have
things like an IP address. Similarly the interface would also have to have a MAC address and
it's been able to understand these concepts and know the tools that we can use to inspect
this information as well as correct it if we happen to run into any problems. This is
what we are going to be talking about. Now the very first command that I want to talk
to you about is actually a command that is deprecated. Meaning that it is no longer supported
but the reality is for the LPIC2 examination this is still something we will be quizzed
on. This is still something we have to have a good awareness of. Now quite honestly I
am a little sad that this command is deprecated because it has been an old favourite of mine
for many many years. And the command I am talking about is one called IFconfig. So let's
now explore this command then shall we. So what I will do is if you type IFconfig notice
that it says here that this command is no longer found again this plays into the fact
that it now is deprecated. So some systems that you install may be still have this tool
automatically installed but typically nowadays what you are going to have to do is to manually
install a Vita package called netTool. So that is exactly what we will do. First we
will say sudo apt install net hyphen tools and if I hit enter I will put in my passwords
and to enter we will now begin pulling this information just give it a little moment for
the download to complete. Perfect so what I will do is I will go into the man page for
IFconfig and we can see here this command is used to configure a network interface. Now
you will be able to see here all of these different options and we will get to look
at what some of those are but for now I will press Q to quit and I will just issue this
command IFconfig. Now if I hit enter this is the output that we are going to see. Now
depending on the type of device you happen to be operating the output might look a little
bit different. For example here what I am seeing is ENP0S3. Now this might look a little
bit confusing so let me just tell you what this means the EN portion this tells us that
this is an ethernet based interface. The P0 tells us the bus number for this interface
and S3 happens to be our slot number. Now it may transpire that your output might read
ETH0. This again tells us that we have an ethernet port and it is ethernet0 the very
first available port. So notice that on the very left hand side it tells us the type of
interface that we have. Again we may have different formats and below here we have this
one called LO. This is the look back address or rather look back interface should I say
not the look back address the look back interface. Now what a look back interface is it is quite
simply a logical interface meaning that it is an interface which belongs in software it
is not actually a physical port that exists. So you can actually plug anything physical
into this interface. It is purely virtual but you can assign things like IP addresses
to this virtual interface and primarily this is actually used for testing purposes but
if you happen to be a network engineer you will know that there are far more use cases
for a look back interface other than simple testing. But for the general purposes this
is what we are going to see but realistically for the purposes of the examination the output
here what we want to know is on the left hand side we can see the actual interface type.
LO denotes look back which is not a physical interface it is a logical virtual interface
and with respect here this is an ethernet physical interface similar if you happen to
see eth0. Now what about all this other stuff that we see here. So the first part here we
are going to look at is this section flags and that is denoted right here okay. All
this is is a whole bunch of different parameters that have been set in accordance with this
actual interface. So let's look at what some of these flags are as well as the other common
ones which were not actually seen here. The first one which is a super important one is
this up flag. This might be intuitively well evident to you what this means. This just means
that the interface is up i.e. the interface is active. So if the interface is up the flag
will be up. The next one here is the flag broadcast. Now with respect to broadcasts what they are
is when a particular communication on a network let's maybe say we have a device here and one
here and one here and one here so four devices on the network and we have like say a network
switch connecting all of these devices together as opposed to this device here talking to this
device directly for example. What this device can do is actually send a broadcast to everyone
on the network. So no matter who is on that network segment they will all receive this
broadcast message. Now when we happen to see the broadcast flag set this means that the broadcast
address has actually been set for this particular interface. So you may notice here that in the
case of the ethernet connection we do have a broadcast address set and you may actually be
able to spot within the output that the broadcast actually has an IP address right here of 192.1680.255
and this address would actually be the same for all devices on the same network. Whereas if we
happen to look at the look back interface we do not have the broadcast flag set therefore as we can
see we do not have any such broadcast address to where we have on our ethernet connection this
does not exist right here and we can easily spot that because the broadcast flag is not set. Now
when we're talking about being able to send a message to absolutely everyone on your network
segments well this is what we mean when we broadcast a message sending that message to
absolutely everyone. What if we want to be a little bit more selective and we only want to send a
message to a particular group of devices on our network so not absolutely everyone. Just a few
people who have tuned in so to speak to a particular address you can kind of conceptualize this as
tuning into your radio station. If you tune in to a particular frequency then you will get that radio
message that is being sent across all of the airwaves. Similar effect right here some devices
can tune into particular messages via something called a multicast address. So if you happen to
see the flag multicast in this output then you know this particular interface is engaged in
multicast communication. Now another flag you may see is the promisc flag. What this actually tells
you is if the interface is behaving promiscuously or not simply put the normal behavior for an
interface is quite simply just to tune in and listen to IP packets that are actually sent to its
own address. Now if you happen to set your interface to act in a promiscuous mode what that
interface will actually do it will actually listen for all the network traffic very very different.
Now you might be wondering why on earth you would want to set such a thing this sounds like
almost too much of a headache to listen to all the different traffic. Well think about this
if you want to analyze the traffic on your network. This is exactly the mode that you would want to
configure your interface to be and of course you could see that this had been set on an interface
by just quickly scanning the flags that are set and if you see that promisc flag you know
the interface is behaving promiscuously and listening for all that traffic. Now here is an
important one the MTU and it says here the value is 1500. The MTU tells us the maximum transmission
units so what does that mean then simply put this is the maximum unit of data that can actually
traverse the physical link. Now the value here is 1500 this means it's 1500 bytes and this happens
to be a very very common MTU setting. Now of course this does not mean that the maximum amount of
data you can send over this link is 1500 in total this is the maximum unit of data i.e the size of
the actual data packets of which there are many many many. Okay so the next one we want to know
about is iNet. When we see iNet this is telling us what our IP address is for that particular
interface so we can see here that the IP address is 192.168.0.65 that is the IP address for this
interface and if we look down here we can see the IP address which is 127.0.0.1 for the lookback
interface which by the way which by the way is going to be an address you see all over the place
this is a default lookback interface address so you could have a hundred devices on the same
network the lookback address for all those devices is going to be 127.001. The net mask relates to the
network mask now if you happen to recall what we talked about in the lpik one the network mask is
how we can determine which part of the IP address relates to the network itself and which part of
the address tells us about the host on the network we can see here that the address for the ethernet
one is 225.225.225.0 this is otherwise known as a slash 24 mask whereas on the lookback
it is 225.0.0.0 again this is a slash eight mask now when we see iNet 6 it should probably be pretty
intuitive to you that if the iNet keyword denotes the IP address the iNet 6 keyword actually tells us
the ipv6 address ipv6 if you do recall is a more modern implementation of ip addressing but even
though it is more modern it has much more address space and is ultimately more secure quite honestly
because of its perceived complexity it still is nowhere near as common as ipv4 but nevertheless
you will see networks which are running on ipv6 only so you definitely do want to be able to
interpret this information and we can see here this is the ipv6 address here and you'll notice
that being much longer and using hexadecimal characters this complexity is why many people
rather avoid it and stick with ipv4 now when we see the prefix len keyword followed by 64 in this case
and prefix len followed by 128 in the case of the lookback this is ultimately the net mask for ipv6
what we're talking about here in the case of the ethernet is a slash 64 mask and in the case of the
lookback we're talking about the slash 128 mask again telling us how to separate the network
address from the actual hosts on the network now a very important one we definitely want to be
remembering is this keyword here called ether this tells us right here and again this is more
hexadecimal we're looking at oh and i just drew all over the values now whilst this is a hexadecimal
address it's not an ipv6 address this is your mac address otherwise known as the hardware address
now you will notice here that the physical interface does have a mac address i.e a hardware address
but the virtual non physical address and the lookback does not have this value the next value
we want to be aware of is the txqlen which is a bit of a mouthful what this is is actually the
transmit q length what we're talking about here is ultimately the speed at which the data can
actually be transmitted so in this case here we see the value of 1000 what we're actually seen here
is that this device right here is capable of transmitting data at 1000 megabits per second
now we can see the rx packets the rx packets ultimately tell us statistics relating to how
many packets have been received think of that r and not just received but received correctly i.e
without error so this is what we like conversely if we want to see packets which were received in
error we would look at the rx error outputs see this right here so in my case here my rx errors
are zero none of them contained any errors now you can probably imagine what the next two are
tx packets similar to rx packets but instead of talking about packets which were received we're
talking about packets we actually transmitted and again this is how many packets that were
transmitted correctly without error if we want to see packets that were transmitted with an error
then we would be looking at the tx error value in this case here i have not transmitted any packets
with an error since the value happens to be zero if we want to actually make configuration changes
using the ifconfig command we can absolutely do such a thing so what i will do here so i'll just
clear the screen now let's say i wanted to change the ip address of this interface right here so i'll
just copy this here okay and i will say sudo ifconfig and now what i want to do is to specify the name
of the interface which i want to modify so i'll just paste in this value right here this is the
interface i want to target and now i'll type in the ip address so right now i think my ip address
is 0.68 i'll just maybe make it 0.50 so it's something different and then i will say net mask
so i can specify my subnet mask i will still keep it at the same value of a slash 24 i.e 255.255.255.255.0
so if i hit enter i'll have to type in my password and of course i've just realized what this will
do this is going to change the ip address and i am connecting remotely to this device so my
connection is going to drop so what i'll actually do here is i'll go to the actual device itself on
the virtual machine so i'll minimize this and i'll just log in here instead of my ssh session
i'll go to my terminal emulator i will say ifconfig and lo and behold we can actually see the i net
value has changed i.e the ip address has actually changed now i could also make additional changes
say for example if i wanted to make this interface promiscuous and set that flag
i could say sudo ifconfig and then the name of the interface so enp0s3 and i will just say
promisc so if i hit enter type in my password and i do an ifconfig notice now we have now set
the promisc flag and now this interface is listening promiscuously to all traffic on the
network again the type of setting we would want to do if we wanted to conduct some type of packet
analysis or by the way if we were maybe doing some malicious hacking this is also something you
may actually do in order to listen to that traffic and potentially invoke some attacks against the
network and if we want to reverse that action because they sudo ifconfig enp0s3 and then they
could do minus promisc if i now hit enter and i do an ifconfig suddenly that flag has now been
removed now if you happen to go through the man page you'll get to see that we have
additional flags that we could use say for example ifconfig dash a this is going to show us all of
our interfaces now this happens to look like the exact same output we just saw before and in this
case it is but the difference is if we happen to have an interface that was down say for example
ifconfig with sudo of course and i did enp0s3 down such that i do ifconfig notice with my
general ifconfig because my ethernet interface is disconnected ifconfig shows me nothing about
this interface however if i do ifconfig with the dash a flag we once again actually see the output
for this interface even though we do not see the up flag because like i say this interface
actually is down so again we can bring it back up by saying up and to enter that we'll now re-establish
it and we can just use ifconfig and our interface is back in the upstate once again okay so i know
that was a lot to cover with respect to the ifconfig command but the reality is understanding the
output of this rather simple command is very very useful for you understanding what is actually
happening on your network how your interfaces are configured and how you can make the relevant
changes to your network interfaces if they do require to be changed okay docks so that is us
for looking at the ifconfig command for now i hope this has been informative for you and i'd like to
thank you for viewing