[No audio]
Network files and commands. There are
many network files and commands that
needs to be used in order to configure
your machine and bring it online or
bring it to the network, so it could
communicate from one machine to another.
It should have an interface, an interface detection.
[No audio]
Assigning an IP address to the system is
very important when you bring up a
system and you need to have it on the
network. The interface configuration
files are the first one is /etc/nsswitch.conf file
This file is located in
every Linux distribution. In fact, all
these files that I'm going to talk about
all of them are and will be in your
Linux system. So the first one is nsswitch.conf,
which tells the
system where is where it should resolve
its hostname to IP address. So let's
look at our Linux machine and then we
will find out how to read these files.
[No audio]
Let's clear the screen.
[No audio]
Okay, the first file that we're going to look at
it's /etc/nsswitch. So just do cat
on /etc/nsswitch.conf file.
You will see it starting with host let's
let's do more on it instead of just cat.
So this will read the file page by
page. Okay, so all these stuff, anything
that starts with pound, it means it's
just a comment. Anything that you want
to have it in effect, just remove the
comment. So let's go through it. Let's
go to the point where you don't see the
comment. So here it's starting from this
page on it says a passwd file. So the
first thing is telling you to look for
the passwd file in the files. Don't go
anywhere, there is no active directory,
there is no other NIS service that's
running that's going to give you the
passwd, so it look for /etc/passwd.
Shadow is also /etc/shadow, that's local,
group is also /etc/group. And when you
come down to host right here, it's going
to tell you the the host information of
your system is located in the files. And
that is /etc/host. And then it's gonna
say if you can't find it, then go to DNS.
DNS is an other service that is
installed on a Linux machine or it can
be installed in Windows machine. We'll
cover that later on. But for now, this
is what the nsswitch file looks like, and if
you want your host to be resolved with
DNS first, you switch DNS here to here
and file comes the second. So this is
the nsswitch file. You're going to be
seeing this configuration of this file
many times while you're doing system
administration. Next one we're going to
look at is /etc/hosts. /etc/hosts file is
where you define your system IP address
and system hostname. So if my system IP
address is ifconfig, it's 192.168.1.14,
I could go into that /etc/file but
by becoming root.
[No audio]
vi the file, and I
could go at the bottom and I could put
192.168.1.14. And the host
name of my machine is, forgot, let me save
it, and there you go, MyFirstLinuxOS. So
let's do it again.
[No audio]
My, it doesn't matter
uppercase, lowercase myfirstlinuxos.
[No audio]
myfirstlinuxos. So now if you ping myfirstlinuxos,
it's going to ping your
IP address. You see right here, the one
that you specified in the /etc/ file. So
that's what /etc/ file does. It's a
small, very tiny version of DNS that's
sitting in your machine. The next one we
have /etc/sysconfig/network file. This file,
[Author typing]
sorry, this it's network I believe.
[No audio]
No, network, probably, yup I'm right. So this
is the file where you specify your host
name as well. Right now it's empty
because we have hardcoded the hostname,
but if you want to change it, you could
modify it here and a certain other
parameters can be set to, of course, you
are more than welcome to look it up more
on the network file.
[No audio]
The next file that we're going to be
covering is actually the file, that's
where you specify your IP address on all
the network, all the subnet mask, and
gateway. And when you are in the
directory, /etc/sysconfig/network-scripts,
I want you to do ls -ltr,
and the last file you're going to see
is ifcfg-enp0s3. And
what is, this last one, it's actually
your interface. If you go if config, and
you will see right here, this is the
name of your interface. So remember,
every time all those interfaces files
always start with ifcfg-, and the
interface name. So when you vi that
file, here you will see the BOOTPROTO
is defined as dhcp. You could change
that at here as static and then you
could define the IP address, you could
define subnet mask, gateway, and this way
your IP address becomes prominent in
your machine and does not change. So
these are a few few of the files that I
really want you to understand and
memorize it because if you are going to
go into Linux jobs and you're going to
be applying for it. Oftentimes, you're
going to get questions on these where
these files are, what the files do,
where they're located, and so on. So
let's exit out of this file. The last
file I have is /etc/resolve.conf.
/etc/resolve.conf specifies your
DNS server. DNS server is again once
again, it actually resolve hostname to IP,
IP to hostname, and hostname to hostname.
So if you define it here, every time you
go to www.google.com and hit enter, it
knows Google is, I have to go into this
as my gateway, I have to go to my
gateway, which is right now acting as a
DNS server, I'm going to go to my DNS
server and ask where is Google and how
to translate Google to IP address. And it
has translated, and this is the IP
address of Google. Let's go back to our
lesson. The next one, we have the
network commands. The network commands,
we have learned ping already. If you
wanted to ping a server, let's say ping
the www.hotmail.com, that's the server
outside that command that you will run
is ping. ifconfig tells you what your
interfaces are in the system. We have
right now three interfaces, the local
one does not count as an interface. And
other one, you can ignore it, the only
one that I have is just one and it's
this right there. And it's telling me my
IP is configured this. Then you have ifup or
ifdown. If you want to bring down
this interface, if you don't want to
network, you could type ifup sorry, ifdown,
or if you want to bring it back up
your type ifup. Then the next one, we
have netstat. netstat, you can run with
different options, I run usually with rnv.
This one tells you your gateway, how
your traffic is flowing from which
interfaces it's going from. And the last
one we're going to cover is tcpdump.
tcpdump is actually traces every single
transactions that are leaving your
machine and coming into your machine.
The command to run is simply tcpdump.
You have to specify i with the
interface, which interface you are
sniffing. It's basically a sniffing
tool. And then you run it and you will
see every listening coming in
going out, it's actually listed here. So
that's how you actually run this TCP
command, that's how you run all these
commands and please memorize it. Please
run a man command on each and every one
of them and familiarize yourself how
these network commands and files work.
[No audio]