Network diagnostics Archives - ClouDNS Blog https://www.cloudns.net/blog/tag/network-diagnostics/ Articles about DNS Hosting and Cloud Technologies Tue, 17 Sep 2024 09:52:34 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.6 Traceroute command and its options https://www.cloudns.net/blog/traceroute-command-tracert/ https://www.cloudns.net/blog/traceroute-command-tracert/#respond Tue, 17 Sep 2024 04:53:00 +0000 https://www.cloudns.net/blog/?p=656 The Traceroute command is one of the easiest yet most effective ways of troubleshooting network issues. It is great software for checking the route from a computer to a hostname or an IP address. Almost every operating system includes it, so you can use Traceroute regardless of the kind of computer you are using. What …

The post Traceroute command and its options appeared first on ClouDNS Blog.

]]>
The Traceroute command is one of the easiest yet most effective ways of troubleshooting network issues. It is great software for checking the route from a computer to a hostname or an IP address. Almost every operating system includes it, so you can use Traceroute regardless of the kind of computer you are using.

What is the Traceroute command?

The Traceroute command (Tracert on Windows) is a small network diagnostic software that you have built-in on your device and servers for tracing the route, hop by hop to a target.
Many network administrators use the Traceroute command daily. It is a convenient tool that you can use under different operation systems – Windows (Tracert), macOS, Linux (Traceroute), and even on mobile (Android and iOS).
To access the traceroute, you will need to use the Terminal (Linux and macOS) or the Command Prompt (Windows).
You can use the Traceroute and see the full route that the packets take to their destination (domain or IP address). Apart from that, you will see the hostnames and IPs of the routers on the way and the latency, the time it takes for each device to receive and resend the data.
You can see which gateway is discarding your data, and later you can fix it.

How does it work?

When you run a traceroute, you send an IP packet containing the source and destination addresses and the time to live (TTL) for each hop. TTL in packets decreases with each hop. This is to avoid server looping issues. Furthermore, when the TTL is reached, the packet expires and is discarded. When this occurs, Traceroute returns to the sender ICMP Time Exceeded messages (RFC 792). Because small TTL settings cause packets to expire quickly, traceroute forces all routers in a packet’s path to produce the ICMP messages that identify the router.

To better visualize the traceroute’s working mechanism, you can look at the following chart.

Why use the Traceroute or the Tracert command?

The benefits of using the traceroute command or its alternative for Windows called tracert command are:

  • Complete route list. You will see all the routers on the way, with their IP addresses and the time it took. You can better understand the network.
  • Route timing. See how much time does it take to finish the query. Is it ok for you? What can you do to speed it up? You can have a starting point for improvements.
  • It is built-in. You don’t need to install additional software, and its use is free.
  • Check if you can reach a target. See if there is a connection between your device and the hostname or IP address you put in the command.
  • See problematic slow router. You can see how much time it took in each hop. So you can see a spot that significantly slows your network. You can fix the problem or add more presence in the area.

When will you need it?

Here are several scenarios where using a traceroute to diagnose a problem you are having can be necessary.

  • Sluggish site

Run a traceroute from your computer to your website if you find it is operating slowly. With it, you will check for networking issues between your location and the server.

  • Customer timeouts for email

Run a traceroute to assess the quality of the connection to the mail server if you have problems with your mail connection. In addition, you can find your mail server IP by running the following command: “ping smtp.server.com”. It will return the IP address of the Simple Mail Transfer Protocol (SMTP) server that you need for Traceroute purposes.

How to use the Traceroute command?

Use the Traceroute command by writing the command “traceroute + domain.com / IP address” or, in the Terminal on Linux and macOS or “tracert + domain.com / IP address” in the Command Prompt on Windows.

Traceroute (Linux and macOS)

traceroute domian.com or traceroute 12.23.34.45

Tracert (Windows)

tracert domian.com or tracert 12.23.34.45

On macOS, you can also use the Traceroute utility. Press the command button + space. Then write Network Utility. Inside it, navigate to Traceroute. Write the hostname or IP address and press enter. It will show you the result.

*You can change the domain.com with another domain you want to probe, and the same goes for the IP address.

Some differences between the Traceroute command, and the Tracert exist. Check the options below.

Traceroute command vs Tracert command

Apart from the small difference between typing traceroute and the Tracert, the fact that the first works on Linux and macOS, and the second on Windows, the other significant differences are the syntax and the options.

Syntax of the traceroute and Tracert commands

traceroute [options] host_Address [pathlength] (Linux)

traceroute [options] host [packetsize] (macOS)

tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name (Windows)

Example of Traceroute (Tracert on Windows)

The name of Traceroute on Windows is Tracert. It works very similar to the version on the other operating systems.
Traceroute

And this is how the Traceroute command looks on Linux and macOS:

Traceroute command Linux

Traceroute options for Linux

If you are a Linux user (Ubuntu, Linux Mint, Manjaro, Red Hat, Debian, etc.), you can specify your traceroute command with the following options:

Option

Description

–help

Information about the command.

-d

This command enables debugging on Linux.

-F

Forbid fragmentation.

-f first_ttl

Put the first TTL value of the packet.

-g gateway

Define a loose source route gateway.

-i interface

Set the interface for the probes.

-m max_ttl

The TTL in traceroute means the maximum amount of hops.

-N

The number of probes that are sent at the same time (simultaneously).

-n

Stop the resolving of the IP addresses.

-p port

Define the port for the query.

-t

Set the type-of-service in probes.

-w waittime

Maximum waiting time for each of the replies.

-q nqueries

Set the number of queries. The default value is 3.

-r

Bypass the routing tables and send them to the host directly (on an attached network only).

-S srcaddr

IPv6 only – source address.

-e

Show ICMP extensions.

-A

AS lookups enable for each hop.

-V

Show version.

-U

Use a particular UDP port. The default value is 53.

-UL

Use the UDPLITE for the query.

-P protocol

Send packets of a specified IP protocol.

-I

Use the ICMP echo for the requests.

-T

Use the TCP SYN for the requests.

-4

Use only IPv4 addresses

-6

Use only IPv6 addresses

rDNS explained in detail

Traceroute options for Windows

You can use the Tracert command with various options to perform more precise tests. The following options work on Windows Vista, Windows 7, Windows 8, and of course, Windows 10.

Option

Description

-d

Do not resolve addresses to hostnames.

-h aximum_hops

Maximum number of hops to search for target. You can put higher than 30, if you want to query a very remote target.

-j host-list

Loose source route along host-list (IPv4-only). Show only IPv4 addresses.

-w timeout Wait timeout milliseconds for each reply. Inscrease it, to see more about slower routers.

-R

Trace round-trip path (IPv6-only).

-S srcaddr

Source address to use (IPv6-only).

-4

Force using IPv4.

-6

Force using IPv6.

Traceroute options for macOS

While the Traceroute command on macOS is very similar to its Linux version, there are small differences in their options.

Option

Description

-a

AS# lookups enable for each hop.

-d

Socket level debugging.

-D

When an ICMP response to our probe datagram is received, print the differences between the transmitted packet and the packet quoted by the ICMP response.

-e

Mode – Firewall evasion. The ports for UDP and TCP will be fixed and won’t increase with each hop.

-f first_ttl

Put the first TTL value of the packet.

-F

Forbid fragmentation.

-g gateway

Define a loose source route gateway.

-i iface

Set the interface for the probes.

-I

Use the ICMP echo for the requests.

-M first_ttl

Same as -f.

-m max_ttl

Set the maximum amount of hops. By default, it is set to 30.

-n

Show the hop addresses numerically.

-P proto

Send packets of a specified IP protocol.

-p port

Define the port for the query.

-q nqueries

Put a specific number of queries. The default value is 3.

-r

Bypass the routing tables and send them to the host directly (on an attached network only).

-S srcaddr

IPv6 only – source address.

-S

Summary of unanswered probes.

-t

Set the type-of-service in probes.

-v

Verbose output.

-w

Set waiting interval (in seconds) for a response. The default value is 3.

-x

Toggle IP checksums.

-z

Set a pause (in seconds) between the probes. The default value is 0.

Save Traceroute results for later analysis

Traceroute outputs can be long and detailed, especially when diagnosing complex networks. Saving the results for future analysis helps document network issues, allowing users to track changes, compare routes, or share the data with colleagues or support teams.

To save traceroute results to a file, simply redirect the output into a text file using the following syntax:

For Linux/macOS:

traceroute example.com > traceroute_results.txt

For Windows:

tracert example.com > tracert_results.txt

This command captures the entire output of the traceroute (or tracert) command and saves it in a file called traceroute_results.txt in the current directory. You can then review or share this file at any time, making it easier to troubleshoot ongoing network issues without needing to rerun the command.

The TTL and Traceroute

Each packet that you send contains a TTL (time to live). It is not a time but a limit of hops it can do before getting the result.

Usual limit is 30, but it can be more like 64 for example. This limit stops your data after a certain amount of hops so it won’t go forever. The IP packet will follow until it gets “time exceeded” or “port unreachable” when it gets to the host.

Starting at 30, on the next hop, it will drop to 29 and so on. If it can’t find the domain or IP that you wanted it will display a message where did it fail, so you will know where the problem is.

Distinction between Ping and Traceroute

Both Ping and Traceroute are tools for analyzing networks. However, the Traceroute is a little more advanced. For example, ping will check the connectivity between two hosts but does not reveal the route between them. On the opposite, the Traceroute shows every stop between the source and the final destination. This can be helpful when connectivity is patchy, such as when only 50% of ping attempts between two places are thriving.

So, to sum up, the Traceroute command can be used to identify connectivity issues, while ping is a quick approach to determine whether a host is reachable over a network. Both of these commands are beneficial to be aware of because knowing how they operate and what their output denotes can be very valuable when analyzing network connectivity issues.

Traceroute’s Restrictions

  • It establishes the route at the interface level rather than at the router level.
  • The Traceroute may not respond after crossing the maximum number of hops if there are firewalls between the source and destination routers that prevent the probe packets from being sent. Furthermore, despite the hops IP address, the router will display * (asterisk) if no response is received. Therefore, using a traceroute under these circumstances is not suggested.
  • Based on the IP headers, load balancing routers can route the traffic via a number of different paths. Therefore, if we execute a traceroute in this case, it will give us an incorrect path between the origin and the goal. Accordingly, it is not advisable to employ traceroutes in this circumstance either.

Are there alternatives to the traceroute command?

Yes, there are various alternatives to the traceroute commands like MTR command, Dig command, Open Visual Traceroute, Nmap.

MTR command (Linux and macOS)

mtr domain.com

The MTR command is an improved traceroute command that can give more statistics and data for lost packets (percentage).

Dig command (Linux and macOS)

dig +trace domain.com

If you already use the Dig command, you can use it for tracing the route too.

Open Visual Traceroute (Linux, macOS, and Windows)

This one is for people who want a visual interface. It is heavier, but it can show you, in a graphical way, the route of the queries and also get Gantt graphs.

Nmap (Linux, macOS, Windows, BSD, and more)

nmap –traceroute domain.com

The results are very similar to the traceroute command.

Conclusion

By using the newly collected data, you can see if there is any problem on the route (not responsive server or very slow one) and later focus your attention to fix it. If you want to see few more tools you can check one of our previous article Тools – DNS trace, Ping, Traceroute, Nslookup, Reverse lookup.

The post Traceroute command and its options appeared first on ClouDNS Blog.

]]>
https://www.cloudns.net/blog/traceroute-command-tracert/feed/ 0
Linux dig command, how to install it and use it https://www.cloudns.net/blog/linux-dig-command-install-use/ https://www.cloudns.net/blog/linux-dig-command-install-use/#respond Thu, 14 Mar 2024 09:54:00 +0000 https://www.cloudns.net/blog/?p=1070 This article will show you how to use the dig command on Linux. You can apply the knowledge to Windows or MacOS.

The post Linux dig command, how to install it and use it appeared first on ClouDNS Blog.

]]>
Dig command (Domain Information Groper) is one of the most popular DNS testing tools. You can use it to troubleshoot your DNS and make sure everything works fine. You can try it on Linux, Mac OS, and Windows. For this demonstration, we will use a random old laptop with the latest version of Linux Mint (19.1). Linux Mint is based on Ubuntu Linux. Many old laptops can get a new life as a diagnostic tool.

How does Dig Command work?

Dig Command works the same way as a typical DNS query. Let’s take an A record request. If you want to see the A record, you want to know the IP address of a particular domain. The request will first check if your router has the information of many sites’ addresses in its cache. If it doesn’t have it, the request must be answered from another recursive server. The common solution is that your query will be responded from the recursive servers of your internet provider. It is possible that it doesn’t know it either. No problem, your query will go on a search for the root server. The request will go to the top-level domain like .COM or .EU, and in the end you will get the IP address from the authoritative server for the domain you were checking. 

Dig Command Syntax

Understanding the syntax of the dig command is crucial for effectively utilizing it for DNS troubleshooting and queries. The basic syntax of the dig command is as follows:

dig [@server] [name] [query type] [options]

  • [@server]: Specifies the DNS server to query. If omitted, dig uses the default server specified in your system’s resolver configuration (usually defined in /etc/resolv.conf).
  • [name]: This is the domain name or IP address you want to query. For example, cloudns.net.
  • [query type]: This specifies the type of DNS record you are interested in. Common types include A, MX, SOA, TXT, PTR etc. If this is left out, dig defaults to querying the A record.
  • [options]: Dig offers a wide range of options to modify its behavior and output. For example, +short displays only the answer section of the query. Other options include +trace for tracing the path of the query across DNS servers, +noall +answer to show only the answer section, and many more.

How to install the dig command on Linux?

First, let’s check if you already have the dig command installed. You can do that by opening the terminal and writing dig -v. If you have it, your computer will show a message similar to this one:

DiG 9.11.3-1ubuntu1.7-Ubuntu.

Many new Linux distros have it pre-installed. In case you don’t have it, you will get the following message:

dig command not found

For Linux Mint, Ubuntu and other Ubuntu-based Linux distributions you can use the following command:

sudo apt install dnsutils

If you are using Fedora or CentOS you should use:

sudo yum install bind-utils

And for Arch Linux users:

sudo pacman -S bind-tools

Understanding the dig command

Let’s start with a simple example to understand it. We will use google.com for the testing. You can try it directly with your domain, by simply replacing google.com with your domain.

dig google.com

dig command

The first line will inform you about the version of the dig command and the second about the global option.

After that, you will get technical information provided by the DNS nameserver. The header shows you what did you do and was it successful. If there is “NOERROR” that there was no problem.
You will see the answer for the EDNS.
Following line shows that by default you are requesting the A record.
You will get the answer for the A record – the correspondent IP address and you will get statistic about the query.

10 Most used Dig commands

More dig command examples:

dig google.com +short

dig command + short

This will show you just the IP address without any additional information. Quick and easy to use the answer that is basically the answer of an A record. 

dig google.com MX

dig command MX

You can query different types of records like the mail exchanger ones. MX records show the responsible mail server for accepting emails. You can see if all of the servers are working the right way and if they are responding too slowly.

dig google.com SOA

dig command SOA

SOA – the start of authority, shows the authoritative DNS server. In this record, you see valuable information about the zone. There is only one SOA per zone. 

dig google.com TTL

dig command TTL

TTL – time to live. It shows how long the data should be kept. You can read more about TTL HERE. People usually leave longer TTL, and that way, they lower the DNS servers’ load. When you are creating records, you can set it to a low value, if you like. Also, it is possible to set different TTL for different DNS records.  

dig google.com +nocomments +noquestion +noauthority +noadditional +nostats

dig command no stats

Only answer query. Use it if you don’t want to receive extra information. A clear and short answer that will evade the extra statistics that you might want to skip. 

dig google.com ANY +noall +answer

Query all types of DNS records. It will show all the different types of DNS records. This will give you an overview of the domain. Later you can use the dig command for the exact DNS records that you want. 

dig -x 172.217.1.142

dig command ptr

Reverse DNS lookup. You can also do the opposite and check the IP address. The rDNS is used for verification. The result will be a PTR record that verifies the nameserver. It is needed that a PTR record exists. Otherwise, this revers checking can’t give an answer.

dig @8.8.8.8 +trace google.com

dig command trace

Trace DNS Path. It will show the whole route that a DNS query takes. Every hop from a server to server. It can show you where exactly server is not working. You might be surprised how far does your query travels. Check it from different locations, and you might see where in the world you need a new point of presence to reduce the latency for the users there.

11 dig -p 5300 google.com

dig command port

Specify Port Number. If you have changed the standard port 53 to another for increased security, you can make a dig command to check if it is working correctly. And of course, you can check if you have closed the standard ports, and you don’t have any “open doors” for attackers. 

dig _sip._udp.YOURDOMAIN.com SRV

Another record that you can check with this command is the SRV. The SRV records are often used in VoIP. In this example, we are checking the SIP service, and we will use the UDP protocol. The answer will show you the time for response and the server’s IP responsible for the SIP service. 

dig google.com TXT

To see all of the TXT records, use this command. TXT records can be used for verifications and can have different variations. For example, it can be a DMARC record. To see a particular one, you can use the following command and change the “dmarc” with the one you need. 

dig _dmarc.google.com TXT

Now you know the basics of the dig command on Linux. You can start experimenting by yourself.

We can recommend you a few more tools that can be useful for your DNS diagnostic Nslookup, Traceroute, MTR, Host, and Ping.

Conclusion

The dig command is an indispensable tool for DNS troubleshooting and analysis. Its flexibility and powerful options make it a preferred choice for network administrators and IT professionals. By understanding how to install and use the dig command, as well as mastering its syntax, you can efficiently diagnose and solve DNS-related issues. Whether you’re checking DNS records, performing reverse DNS lookups, or tracing the path of DNS queries, dig provides you with the insights needed to ensure your domain’s DNS is functioning correctly. Remember, practice is key to becoming proficient with the dig command, so don’t hesitate to experiment with different queries and options. With this knowledge, you’re well-equipped to tackle any DNS challenges that come your way.

The post Linux dig command, how to install it and use it appeared first on ClouDNS Blog.

]]>
https://www.cloudns.net/blog/linux-dig-command-install-use/feed/ 0