Как проследовать маршрут в power shell

Understanding computer networks might seem difficult, but tools like Tracert make it easier to fix problems and have a smooth time online.

In this guide, we’ve explained Tracert, making it easier to understand network issues. Now, you can fix problems with confidence. Enjoy using Tracert!

When your internet isn’t working right, knowing how your data travels can be useful. Tracert, also called traceroute, is a helpful tool on your computer. In this article, we’ll show you How to Use the Tracert (Traceroute) Command in Windows in simple steps, without any confusing terms. Let’s get started.

Connectivity has become crucial to our daily lives, from a consultation on a website, the transaction or authorization in a transaction, to the real-time view of inventoriesor product delivery. Behind all this is the operation of the network, so it is important to have tools and knowledge to understand what may be causing problems in its operation.

In Windows CMD, we can use either the tracert or pathping commands to perform a traceroute. These two commands are also available in PowerShell; however, PowerShell has its own method for performing traceroutes.

Related Commands

In PowerShell, you can perform a traceroute with either Test-Connection or Test-NetConnection. While Test-NetConnection offers superior speed, Test-Connection provides more detailed information.

Using Test-Connection to Traceroute

Here’s the command syntax in PowerShell for using Test-Connection to perform a traceroute:

Test-Connection -TargetName <Computer-Name/IP-Address> -Traceroute
Test-Connection -TargetName example.local -Traceroute

The result will be a detailed table showing the route taken by the packets:

How to Traceroute in PowerShell
Traceroute using the Test-Connection command.
Test-Connection -TargetName 192.168.1.1, 192.168.1.10 -Traceroute

While tracert automatically resolves hostnames, Test-Connection doesn’t by default. However, you can enable name resolution by adding the -ResolveDestination switch.

Test-Connection -TargetName example.local -Traceroute -ResolveDestination

You can also change the output format by redirecting the output to the Format-List command:

Test-Connection -TargetName 192.168.1.1 | Format-List

Using Test-NetConnection to Traceroute

Test-NetConnection -ComputerName <Computer-Name/IP-Address> -TraceRoute

This example maps the network path to the example.local domain using Test-NetConnection:

Test-NetConnection -ComputerName example.local -TraceRoute
Traceroute using the Test-NetConnection command.
Traceroute using the Test-NetConnection command.

Not only is the response significantly faster than Test-Connection, but it also shows the IP address of the local interface that data is flowing out from. This can be very useful if your computer has multiple network interfaces.

An MTR clone for PowerShell.

Written by Tyler Applebaum.

Runs a traceroute to a specified target; sends ICMP packets to each hop to measure loss and latency.

Big shout out to Team Cymru for the ASN resolution.

Thanks to DrDrrae for a bugfix on PowerShell v5

Input must be in the form of an IP address or FQDN. Should be compatible with most TLDs.

Specifies the number of ICMP packets to send per hop. Default is 10.

An optional parameter to specify a different DNS server than configured on your network adapter.

PSObject containing the traceroute results. Also saves a file to the desktop.

PS C:\> Get-Traceroute 8.8.4.4 -b 512

Runs a traceroute to 8.8.4.4 with 512-byte ICMP packets.

PS C:\> Get-Traceroute amazon.com -s 75.75.75.75 -f amazon.com -h 45

Runs a traceroute to amazon.com using 75.75.75.75 as the DNS resolver and saves the output as amazon.com.txt.

Increase max hop count from default of 30 to 45.

Default to 10 pings per hop; minimum of 5, maximum of 100

Default to 32 bytes of data in the ICMP packet, maximum of 1000 bytes

Add some values so the array isn’t empty when first checked.

Reset to null each time

Reset to null each time

Don’t waste a lookup on RFC1918 IPs

Check for array;

Object found

Check for string; normal case.

String found

Current object:

Keep “ASNOwnerArr.ASN” in double quotes so it will be treated as a string and not an object

ASN not previously resolved; performing lookup

Check the previous lookups before running this unnecessarily

Check for array;

Object found

Check for string; normal case.

String found

Add our new value to the cache

We get to use a cached entry and save Team Cymru some lookups

ASN Owner found in cache

ASN Owner lookup not performed – RFC1918 IP found or hop TimedOut

Increment the count for the progress bar

Hop =

Check for array first; sometimes resolvers are stupid and return NS records with the PTR in an array.

If Resolve-DNS brings back an array containing NS records, select just the PTR

Object found

Normal case. One PTR record. Will break up an array of multiple PTRs separated with a comma.

In the case of multiple PTRs select the first one

String found

Check for null last because when an array is returned with PTR and NS records, it contains null values.

If there’s no PTR record, set name equal to IP

:/>  Комбинация клавиш отменить удаление

HopNameArr apparently empty for

Resolving PTR Record

Looking up , Hop # of

If the hop times out, set name equal to TimedOut

Hop =

Store all RTT values per hop

Clear the array each cycle

Advance the count

Reset x for the next hop count. X tracks packet loss percentage.

Send the UTF-8 letter “a”

Normal case, attempt to ping hop

Send the packet with a 1 second timeout

Add RTT to HopRTT array

Testing Packet Loss to Hop # of

Sending ICMP Packet of to – Result: ms

End for loop

Remove zeros from the array

100% loss, but name resolves

End main ping loop

Hop TimedOut – no ping attempted

End TimedOut condition

Add the object to the array

What is Tracert or Traceroute?

Availability on Windows, GNU/Linux and Mac operating systems.

Now, Tracert and Traceroute are pretty much the same thing: Tracert is the command used for Windows environments; while Traceroute, is used on GNU/Linux and Mac.

Troubleshooting with Tracert Traceroute

Tracert Traceroute isn’t just about tracking data; it’s a strong tool for identifying and fixing network problems.

  • Finding Slow Connections: If a certain step takes a long time in Tracert, it’s like finding a traffic jam on the internet highway. This helps you know where the problem might be and fix it.
  • Spotting Network Breaks:

Using Tracert traceroute in these ways makes fixing internet issues much easier!

Funciones Principales de Traceroute

  • Diagnosing problems in home or business networks.
  • Identification of points of error in the Internet connection.

Traceroute has two main functions:

Diagnosis of problems in home or business networks, through the analysis of the results obtained after the execution of this tool, as it allows us to analyze the sequence of hops that it takes from the source to the IP destination.
This allows us to find out information about the topology of the network that packets go through and which devices are involved in routing them.
Identification failure points in the Internet connection,by detecting the sections where delays or losses of data packets take place, since the response times of each hop can be displayed throughout the route. Tracks with congested links or where it is taking too long to respond can be identified. This helps you find out where a configuration update or adjustment might be needed for best performance. It also allows you to detect disconnection points when data packets do not reach the final destination, displaying an error message or an asterisk line.

Beyond identifying problems in the network or failure points, Traceroute also helps to anticipate possible network degradations in the network, so that the IT team can take preventive actions that guarantee stability and the constant and efficient information flow.

Traceroute FAQs

Are Traceroute and Tracert the same?

What is the difference between ping and traceroute?

Traceroute Usage

  • Run from Command Prompt or Windows PowerShell.
  • Basic command: `tracert`.

On Windows

Open run by pressing the windows + R key, type cmd and click OK.

Как проследовать маршрут в power shell

A command pop-up window opens in which to type tracert, the domain and then press Enter. In case of not typing the domain, the configuration options that you may use will come out:

Как проследовать маршрут в power shell

  • -d :Save hops by not converting IPs to server names.
  • -h :Followed by a number, will be the maximum hops allowed (by default it is 30).
  • -j :List of allowed hosts (only on one IP).
  • -w :Maximum waiting time in milliseconds to determine if a point is not working.
  • -R :It follows the return path, it is used with IPv6.
  • -S :The Source address is followed by the source address in IPv6.
  • -4 :It forces only the IPv4 path to be followed.
  • -6 :It forces only the IPv6 path to be followed.

For routine use, the command is executed, with the domain and enter. A window will appear showing each hop, the timeout of each of the packets and the IP or server name, along with the IP of each point on the network.

At the end, the text “Trace Complete” is printed to indicate that the destination was reached. In case of error, three different messages are generated in the IP column or in the times with an asterisk:

  • Asterisk in times column:It indicates that at this network point the waiting time was exceeded and that packet will no longer be sent. It may happen one, two or all three times.
  • Timeout exceeded for this request:When the time is up for the 3 packets, this message will come out on the right, also indicating that no packet exceeded this point in the network. In these cases, the command retries it up to the maximum number of hops (30, by default).
  • Destination network unreachable:Packets reached a point that does not exist or there is an error.
:/>  Имя типа окна windows и 19. Концепция окна в графическом интерфейсе Windows. виды окон. оконная конструкция

Как проследовать маршрут в power shell

Let’s see some screens as an example of what the tracert command throws:

1. Showing IP address and hostname if resolved:

Как проследовать маршрут в power shell

2. Showing IP address only:

Как проследовать маршрут в power shell

On Linux

Как проследовать маршрут в power shell

After the domain, you may add requests that adjust the command settings:

  • -I : It switches from UDP packets to ICMP packets (which are the ones used by Windows).
  • -n : It displays the results without the server name, only the IP.
  • -q : After the number of packets, to send a number of packets other than 3.
  • -d : Enable socket-level debugging.
  • -m : Followed by a number to indicate the maximum number of hops, which is 30 by default.
  • -w : Followed by a number that is the milliseconds of maximum wait.
  • -r : It avoids normal routing and sends packets more directly.
  • -p : Followed by the port, to change the default query port.
  • -g : Followed by an IP address, to send the packets indicating a specific source IP.

For a Mac, you’ll need to use Terminal. The command specifications are identical to those you indicated for Linux.

Let’s look at some sample screens of running the traceroute command on Linux/Mac:

1. Showing IP address and hostname if resolved

2. Showing IP address only

3. Visualización de la dirección IP real del dominio.

4. Listado de nodos y routers con direcciones IP y latencia.

Как проследовать маршрут в power shell
Как проследовать маршрут в power shell

Traceroute Practical Applications

Diagnosis of website connection problems

Identification of connection loss in local networks

For the local network, Traceroute can identify where bottlenecks, potential routing issues, or network configuration issues are located.

Understanding the Basics of Tracert

In the big world of the internet, data packets travel through a series of routers before reaching their destination. Tracert traceroute is a command that allows you to trace this path, providing valuable insights into your network connection.

What is Tracert?

Tracert, short for traceroute, is like a digital detective. It traces the route taken by your data, revealing each hop (router) it encounters and the time it takes to reach it. This information is crucial for diagnosing network issues.

Step-by-Step Guide

1. Open the Command Prompt

Simply type ‘cmd’ in the search bar and hit Enter. The Command Prompt window will open.

2. Execute the Tracert Command

For instance, ‘tracert www.geeksforgeeks.org‘. Hit Enter, and Tracert will start its journey, displaying a list of hops and the time taken for your data to reach each one.

What Do the Results Mean?

After running the Tracert command, you’ll be presented with a list of hops, each showing the time taken for your data to travel.

  • IP Addresses: The series of numbers represents the routers your data passes through.
  • Response Times: The time displayed (in milliseconds) indicates how long it took for your data to reach each router. Higher times might indicate network congestion or other issues.

How Traceroute Works?

1. Use of ICMP (Internet Message Control Protocol)

2. Time To Live (TTL) field in the IP header

Traceroute works by sending a series of packets with increasing Time-To-Live (TTL) values and tracking the response of each intervening device along the route. The function of TTL is to limit the lifespan of a package. In case of network problems, TTL prevents packets from being trapped in a network indefinitely. The initial TTL value is set to one and incremented with each new packet sent. As the packet goes through the network, each router decreases the TTL value by one. This is because for each router the packet goes through, its TTL drops to 0 and sends the sender an ICMP timeout message.

3. Sending messages to specific nodes for information

For receiving more specific information, you may limit the number of hops to be made, in order to limit the search in a specific part of the route or network.
In operating systems such as Linux, it is also possible to specify the outbound network interface for sending packets, or even the destination port if you are sending UDP packets.

FAQs on How to Use the Tracert (Traceroute) Command in Windows

1. Can Tracert Traceroute be used for both websites and IP addresses?

Absolutely! Whether you’re troubleshooting a website or an IP address, Tracert can trace the path your data takes, providing valuable insights into network performance.

2. What Should I Do if a Hop Doesn’t Respond?

3. Why Do Some Hops Have Longer Response Times?

Longer response times at specific hops might indicate network congestion or slower connections at those points. These insights can help you pinpoint and address the issue effectively.

4. Can Tracert Command Identify Wi-Fi Problems?

While Tracert can’t specifically diagnose Wi-Fi issues, it can identify network problems affecting your overall internet connection. If you suspect Wi-Fi problems, consider checking your router, signal strength, or contacting your ISP.

5. Is Tracert Command Safe to Use?

Absolutely! Tracert is a non-intrusive diagnostic tool commonly used by IT professionals and enthusiasts. It only traces the route data packets take and doesn’t interfere with your network’s operation.

Different Commands & Options for Tracert Traceroute in Windows

Basic Tracert Command

Displays the list of hops (routers) and the time taken for data packets to reach each hop.

Tracert with Maximum Hops

Limits the number of hops in the route to the specified value.

Tracert with Timeout Setting

Adjusts the time Tracert waits for a response from each router.

Tracert with Resolve IP Addresses

Displays only the IP addresses of routers, not their hostnames.

Tracert with Timestamps

Displays the time when data packets reach each router.

Tracert with IPv6

Traces the route using IPv6, the latest version of the Internet Protocol.

Tracert with Detailed Information

It provides a list of available options, commands, and their descriptions.

:/>  Как сравнить две таблицы в Excel, чтобы найти разницу и совпадения

Problem diagnosis with Pandora FMS

Tools such as traceroute help us identify possible problems in the network, asymmetric paths or with substantial delays, among others. However, this is not the most important tool or the only one that can help us solve problems on the network. Here are some of the tools available to Pandora FMS to solve your network problems:

  • SNMP network interface monitoring.
  • Latency time monitoring (ICMP).
  • TCP port monitoring.
  • Packet loss monitoring.
  • Viewing routes (via traceroute).
  • Hop count (via traceroute). Through a plugin from our library, which counts the number of hops from one point to another.

Как проследовать маршрут в power shell

Considerations and Limitations

As in any IT tool or resource, there are limitations and considerations that must be taken into consideration in order not to degrade network performance or expose equipment security:

Time Limitations

Asymmetric paths

The command displays the path of a data packet from a device to the destination, but does not guarantee that the return path will be the same. This is because flexible routing systems exist and the results obtained may not represent the full path.

Safety Limitations

The Traceroute command reveals information about devices and servers en route to the destination, resulting in a privacy issue, especially if the command is used on public networks or servers store sensitive information.

Equipment limitations

It should be noted that some computers on the network may be configured not to respond to tracert messages. If so, you will surely receive a timeout message instead of actual replies.

Как проследовать маршрут в power shell

Как проследовать маршрут в power shell

Devices may also be limited in the amount of ICMP traffic allowed, resulting in incomplete responses along the route. It should also be noted that, in some networks that use NAT, you could only see the IP address of the last router before the data packet reaches the final destination. This happens because NAT rewrites IP addresses in packets as they move through the network.

Finally, if you do not use a host listing, it is likely that automatic routing will be used, and the response to the command could vary, resulting in inconsistencies between different times or from different locations, as you can see if we compare the captures we saw above in Windows and Linux.

Как проследовать маршрут в power shell

Traceroute Conclusions

Connectivity means communication that is required immediately and without friction due to the impact on the business operation, the productivity of the company’s collaborators, the employee’s response to internal customers (other business units) and external customers (end customer, suppliers and business partners). So solving and anticipating network problems has become a very important task. The Tracert or Traceroute command is a fundamental part in diagnosing the network state, identifying connectivity problems between the source and the destination, as well as failures at specific points. Likewise, Traceroute allows you to take preventive actions by identifying the sections where the links are congested or where the response time is longer than expected.