Netstat - What is your computer connecting to?


image
jcwarnerdev
published: April 23, 2023, 2:27 p.m. | last modified: April 23, 2023, 2:32 p.m.
binder ipinfo jupyter notebook google maps netstat

no image

jcwarnerdev Blog Title: Netstat - What is your computer connecting to?

Have you ever taken a look at netstat? It'll provide info on what systems and networks your pc is connected to. This IONOS guide will bring you up to speed.


While netstat will tell you what IPs you computer is connected to, it will not provide any enriching info. To understand why your machine is connect to those IPs a good place to start is looking at ownership and location.


I built a notebook to help with that problem. It doesn't replace antivirus or network defense tools, but can give the user a quick view at current and recent connections.



The enrichment requires two API Keys. I took mine out so you'll need to get your own.


IP location and ownership info is pulled from ipinfo.io. A free tier account gets you 50K lookups per month. Your netstat looks way different than mine if you plan on exceeding that!


IP locations are plotted to a map using the Google Maps api. When I first signed up for Google billing I was given a $300 credit to explore their services with. Each map generated by this notebook costs something like two thousandths of a cent. So even if it's coming out of pocket it won't be much.


Steps that require user input in the notebook have instructions. Otherwise just run each cell by either clicking the play button or shift+enter.


type below command into windows terminal:

netstat -n | clip


Paste result into the notebook input cell:



The next cell parses the netstat you pasted into a readable table:


After that private IPs are removed and the count of remote connections is printed:


Each remote IP is queried using the ipinfo api:


The locations obtained from ipinfo are passed to the Google maps api for location plotting:


Ownership and location details are presented in the ip info dataframe:



Login to post comments below.


All Comments (0)