Ports are great things, they let you connect to machines.
You ever wonder if you got one or more open?
You ever wonder who’s listening?
I’m going to show you how to figure it out in Windows,
coming up now.
Hello, everybody, my name is Adam Gordon,
an edutainer here at ITProTV,
coming back at you with another exciting episode
about how to optimize your Windows server admin
and usage experiences,
and we’re going to talk about something very common,
often misunderstood.
How the heck do I know if I have an open port,
and more importantly, what does it mean if I do?
Well, open ports are very simple;
they’re just ways that people connect remotely to your machine,
so they can consume services,
they want to grab a file and use it remotely,
they want to browse your machine and see some resource,
maybe you’ve got a printer connected to it
and they want to print
and they’ve got to connect to your machine
to get to the printer,
or maybe you’re doing something like browsing the web
and you’re sending traffic out and receiving traffic back in,
any and all of those things,
things we all do every day, sending emails,
browsing the internet, printing documents,
working locally on a document,
not even thinking we’re connected,
but saving it and it saves back to a remote location.
Any and all those things require
the use of one or more ports
in order to do those things successfully,
and those ports have to be opened,
and you might or might not be aware
of the fact that they are.
I’m going to show you a really simple, easy way
to figure out those ports are open.
We’re going to do this, join me if you will,
in Server 2019, running as a virtual machine,
but this is the really cool part,
we can do this on Server 2016, Server 2019,
and/or Server 2022 the same, exact way.
And as a matter of fact,
this works on all versions of Windows
going all the way back to Windows NT 4.0,
using the same tool I’m about to show you,
the same exact way.
So, this is something that has been around
forever and ever, and ever,
regardless of what version of Windows you love,
what version of Windows you use,
or version of Windows you are thinking of using,
it’s going to work the same way,
you’re going to go to the same place,
and you’re going to do the same things.
Now, we can do this
from two distinctly different Command line interfaces.
Whether you choose to use PowerShell,
whether you choose to use the good old fashioned
built-in Windows Command line,
it’s going to work the same way, the command is the same,
and it’s going to look the same way when we’re done.
We’re going to use the NetStat command,
short for Network Statistics,
and we’re going to see how that works right now.
I’m going to go down to the Start menu, right here,
I’m going to click on it,
we’ll bring it up just so you can see it,
and I can open up the Windows Command line right from here,
and/or I can access PowerShell further from here,
it’s really up to you to decide.
I’ve got PowerShell pinned right up here under Windows Server.
I’m going to load that and run that as an administrator,
just bring that up so you can see that.
Let’s start in PowerShell, I’m going to type in netstat,
you can see the command right there.
Now, I can type -a, that’s going to give me
all of the open ports that are available
for both the TCP and the UDP protocol,
so we’re going to do that,
depending on the number of ports we have open,
things that are going on,
you’ll notice on my taskbar
I don’t really have any programs open,
connected to the outside world,
but that doesn’t mean I don’t have open ports,
it just means I don’t have as many.
So, it can take maybe anywhere from 15 to 20,
maybe 30 seconds or longer.
It will start by returning a pretty quick list,
I’ve done this right before we started filming this episode,
so I know it will be a little quicker than it would be normally,
and I can see, as I scroll back up here,
that I have both TCP and UDP,
two protocols commonly used to be able to drive
almost all of the traffic that we use on our system,
and I can see that I’ve got a bunch of ports
that are available, port 135, 443, 445, et cetera,
you can see all sorts of different ones.
It tells me the machine that may be connected
and/or using that port, and the current state of the port,
is it listening, is it established, is it waiting,
so I can see a lot of information about the IP address,
the inbound/outbound traffic flow,
and, of course, the port being used.
And as I scroll down, I can see the same thing for UDP.
I see a list of ports at the end of the IP address
or the IPV6 address listing right there,
and I can see exactly what’s open,
and I can just simply go through
and see all those ports one at a time,
or scan through the list, finding as many as I need.
I can do the exact same thing, run it the same exact way
from the Windows Command line,
let’s quickly take a look at that while we’re here.
We’re going to go down,
we just have to search for the Windows Command line.
We’re going to come in here
under Windows System, right there,
and we just scroll down,
and you’ll see the Windows Command Prompt is right there.
I can actually go to the Run line
and type CMD and bring it up, as well.
And we’re going to go ahead we’re just going to make sure
that we use our Run as Administrator option
by right clicking on that, also.
We’ll bring that up,
you’ll see it’s running as an administrator, right there,
and we’ll type in netstat, again -a,
give that a moment.
I didn’t preload it here,
so it takes just about as long as you can see, either way.
We get the same exact listing,
other than the background color and color of the command,
it is the same, same command,
works the same way in both tools,
and by the way, as I suggested,
you can go all the way to the earliest versions of Windows
and use this tool,
it’s been built in and available that long
and it will work the same across
all those versions of Windows.
Of course, the number of open ports
and the number inbound connections will vary by machine,
so yours may look a little bit different than mine,
but ultimately the output for the command will be the same,
you’ll see the open ports
and you’ll see the current state of those ports.
As you look at your machine,
you can do this at any point in time.
Now, this is built into Windows,
there are a number of tools you can download,
some are free, some you have to pay for,
that will monitor inbound connections
either through the command line as port listeners,
or in a graphical interface,
and they will show you this certainly same information
and probably a great deal more.
We’re not going to talk about those tools here,
but you’ve got a variety of different ways
of getting the same information,
so it’s just a matter of what makes the most sense for you.
But, whether you want to do it on Server 2016, Server 2019,
or indeed, Server 2022, the results are the same.
Netstat is the tool,
and all you have to do is open a command line
or PowerShell as an administrator, type it in,
and wait for the results to come up on the screen.
I will be back with new and innovative ways for you
to continue optimizing your Windows server experiences,
but until I come back with another episode,
I’m going to say goodbye for now,
I wish you happy windowing, and I’ll see you soon.