Hey and welcome back.
So in this video we are going to see how you can
display the listening TCP and UDP
ports and the corresponding programs which
have been using the sports.
Now this is a very very helpful command and
utility which is going to help you in all
the distributions, which is either Macos Linux
or Windows.
Now with this you can identify that what
are your ports which services are
running on them if the connection state
is open closed or established and
what are the ongoing currently open
or closed ports?
Alright, so let's quickly see how can you identify this
for this the command that we are going to use is
netstat. Now, I have already done
a setup between this OS which
is the Mac OS and I have been running.
a Debian OS into my virtual machine
as you can see over here.
the IP address of this machine by
the command I have config can be
seen over here is 192 168 241.3
And on this machine I have started a NC connection,
which is a netcat connection as you can see over here on port
number 44463. All
right. So let's come back to our
Mac OS and on this system, you can see I have
config and I'm trying to see
my IP address basically so on this system. Basically,
I'm establishing a connection to
the Linux Debian machine, which
we have seen currently using the command, which is NC the
IP address of the machine that we have seen, which
is exactly the same IP address that we
are connecting to and the port number on which the
connection has started as you can see over here.
So this machine is listening on this port number
and we are trying to connect to that machine. Once we
are successfully connected you can see we got
a connect request from the IP address,
which is this.
Using the port number five double one eight
four and you can see we I was able
to type a message which was we are connected now anything that
we type here on this terminal we're
able to see onto our next machine. For
example, let's see this works.
And let's go inside and see it works.
As we can see that both these machines are connected and they
are able to communicate with each other.
Alright, let's come back to netstat now. So
we are going to see the connections that have been
opened in this computer and to see if they are
communicating with any other host or service. And
what is the state? Is it established
open or closed for that? You can see over
here. I have typed the command which is netstat. And
this is the output. Let me just scroll up
and here we go.
You can see netstat hyphen a to see all the
connection requests including TCP ureb.
And now if you notice over here.
This is the connection that we have successfully
established.
And you can see the IP address which is 192.168 241
dot one which is
this machine which you can see over here and the
port of this machine which is 51184, which
is been used. This is the foreign
address the remote machine to whom
which we are connected on the port number four four six
three. So this is the local address as you
can see over here. This is the foreign address to whom we
are connected on this specific port and
we can confirm from here. This is the same port
and this is the local machine through
which we have got the connection from this port number and we
can verify this using the next step command.
Now you can see over here. The state is established which
means both the machines are currently
in a established state and
are communicating with each other.
So this is it for this video? I hope you guys understood you
can also see there are plenty of other services which
have been running in the background. Now, most of
this services are being run by the system
commands in which they try to frequently get
connected to the servers for security
patches or updates Etc or in
case if you're running any system level applications or
NTS and background they all so frequently connect to
their service for frequent updates.
So this is it for this video? I hope you guys understood in
case you have any doubts or queries you can you can
always ask it into the Q&A. Thank you.