Mapping the internet

28 Jun, 2023

Every domain has an IP address a domain is linked to. There are commandlets we can use in PowerShell like Test-NetConenction or to get the IP a website is hosted at. There are also geo location services, like you can use to find a general location of where the IP resides and by who.


To try this out we can run the following:

Test-NetConnection -ComputerName

ComputerName           :
RemoteAddress          :
InterfaceAlias         : Local Area Connection
SourceAddress          :
PingSucceeded          : True
PingReplyDetails (RTT) : 72 ms

The Remote address is the IP the website resolves to to host the web content. If we go to and look up, we'll see it is located in Seattle, Washington.

Tracing the route

With command prompt we would run a tracert to see the hops and jumps your connection is taking to reach it's destination. This was helpful in troubleshooting network issues locally and across the globe with the internet. PowerShell built this into Test-NetConenction with an argument -TraceRoute and can now do two things with one command, ping and trace the route. One other neat addition is the -Port argument to test a connection to a specific port on the remote host.

Test-NetConnection -ComputerName -TraceRoute
ComputerName           :
RemoteAddress          :
InterfaceAlias         : Ethernet 5
SourceAddress          :
PingSucceeded          : True
PingReplyDetails (RTT) : 13 ms
TraceRoute             :

The hops or relaying conenctions are listed in the TraceRoute part of the generated object. With this we can see our source IP, hops to the external routes to reach the destination. The are all hops where the provider did not respond with who they are. This is pretty common at the different network levels as well.

Putting the locations together

With each of the IPs in the TraceRoute object we can loop through them and query the API for or other provider.

(Invoke-WebRequest "").Content | ConvertFrom-Json
ip       :
hostname :
anycast  : True
city     : Seattle
region   : Washington
country  : US
loc      : 47.5413,-122.3129
org      : AS16509, Inc.
postal   : 98108
timezone : America/Los_Angeles

Now that we have gotten all the IPs between me and the remote website, we can loop through the TraceRoute object items and query each for location information and build out visual trace, or map to the remote destination. I've added a custom function to Test-PrivateIP so we can skip local IPs as our geo location service only has knowledge of external IP addresses.

$trace = Test-NetConnection -ComputerName $domain -TraceRoute | Select-Object TraceRoute

$starting = (Invoke-WebRequest "").Content | ConvertFrom-Json
"# Running Trace for $domain" | Show-Markdown
Write-Host "Starting from: $($starting.ip)"
Write-Host "$($starting.ip) : $($, $($starting.region)"

$trace.TraceRoute | ForEach-Object {
    if((Test-PrivateIP -IP $_) -eq $False){
        $location = (Invoke-WebRequest "$($_)?token=API-KEY-HERE").Content | ConvertFrom-Json
        Write-Host "$_ : $($, $($location.region)"

Starting from: : El Centro, California : Dallas, Texas : Fort Worth, Texas : Irving, Texas : Dallas, Texas : Seattle, Washington


I've always enjoyed DNS and seeing how the internet works. Seeing where your traffic is being routed to as well is pretty nice to know as well. Have fun creating a map of the internet!

I'm publishing this as part of 100 Days To Offload. You can join in yourself by visiting

Tags: powershell, 100DaysToOffload


If there are replies, they will show below.

Found an issue? Edit on Github

← Back home