{"id":460,"date":"2025-10-13T01:19:00","date_gmt":"2025-10-13T01:19:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=460"},"modified":"2025-10-13T01:19:00","modified_gmt":"2025-10-13T01:19:00","slug":"list-linux-networking-troubleshooting-and-commands-beginners","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=460","title":{"rendered":"17 Best Linux Networking and Troubleshooting Commands"},"content":{"rendered":"<p>Network configuration, diagnostics and general <strong>Linux troubleshooting <\/strong>are<strong> <\/strong>essential parts of System administration. Even for a developer who works with Linux systems, knowledge about <strong>Linux networking commands<\/strong> is an added advantage.<\/p>\n<p>Specifically, if you want to <a href=\"https:\/\/devopscube.com\/become-devops-engineer\/\" rel=\"noreferrer noopener\">become a DevOps engineer<\/a> or be part of SRE, it is essential to know all the <strong>Linux troubleshooting commands<\/strong> as they will be part of your day-to-day activities.<\/p>\n<p>Also, in real-world production systems, knowing how to diagnose DNS failures, slow connections, or blocked ports is very important. <\/p>\n<p>This post will cover the important<strong> linux networking and troubleshooting commands<\/strong> that are natively available in Linux systems.<\/p>\n<h2 id=\"what-are-the-best-linux-networking-and-troubleshooting-commands\">What are the best Linux Networking and Troubleshooting Commands?<\/h2>\n<p>Following is the list of natively available troubleshooting commands.<\/p>\n<p><!--kg-card-begin: html--><\/p>\n<table class=\"auto-wrap\" style=\"width: 100%;\">\n<tbody>\n<tr>\n<td><strong>Command <\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td><code><strong>hostname<\/strong><\/code><\/td>\n<td>To check and set the hostname of the server.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>host<\/strong><\/code><\/td>\n<td>To get host DNS details<\/td>\n<\/tr>\n<tr>\n<td><code><strong>ping<\/strong><\/code><\/td>\n<td>Checks if the remote server is reachable using <a aria-label=\"ICMP protocol (opens in a new tab)\" href=\"https:\/\/en.wikipedia.org\/wiki\/Internet_Control_Message_Protocol?ref=devopscube.com\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">ICMP protocol<\/a>. It also shows the round trip time of packets.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>curl<\/strong><\/code><\/td>\n<td>A cross-platform utility that is used to transfer data. It can be used for troubleshooting several network issues.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>wget<\/strong><\/code> <\/td>\n<td>Utility to download files. Can be used for troubleshooting proxy connections and connectivity.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>ip<\/strong><\/code><\/td>\n<td>A replacement for <code>ifconfig<\/code>. Can be used to configure and retrieve information about systems network interfaces<\/td>\n<\/tr>\n<tr>\n<td><code><strong>arp<\/strong><\/code><\/td>\n<td>Utility to view and manage <a aria-label=\"arp cache (opens in a new tab)\" href=\"https:\/\/en.wikipedia.org\/wiki\/ARP_cache?ref=devopscube.com\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">arp cache<\/a>. <\/td>\n<\/tr>\n<tr>\n<td><code><strong>ss\/netstat<\/strong><\/code><\/td>\n<td>Primarily used to check the connections and PID on ports and Unix sockets.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>traceroute<\/strong><\/code><\/td>\n<td>This utility uses the ICMP protocol and finds the hops involved in reading the destination server. It also shows the time it takes between hops.  <\/td>\n<\/tr>\n<tr>\n<td><code><strong>mtr<\/strong><\/code><\/td>\n<td>mtr is a mix of <code>ping<\/code> and <code>traceroute<\/code>. It also provides additional information like intermediate hosts and responsiveness.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>dig<\/strong><\/code><\/td>\n<td>Helps you get the DNS records associated with a domain name.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>nslookup<\/strong><\/code><\/td>\n<td>Command similar to dig.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>nc<\/strong><\/code><\/td>\n<td>utility to debug TCP\/UDP sockets.<\/td>\n<\/tr>\n<tr>\n<td><code><strong>telnet<\/strong><\/code><\/td>\n<td>It can be used to test remote connectivity on ports<\/td>\n<\/tr>\n<tr>\n<td><code><strong>route<\/strong><\/code><\/td>\n<td>Helps you get all the route table information<\/td>\n<\/tr>\n<tr>\n<td><code><strong>tcpdump<\/strong><\/code><\/td>\n<td>This utility helps you to capture network packets and analyze them for network issues.<\/td>\n<\/tr>\n<tr>\n<td><strong><code>lsof<\/code><\/strong><\/td>\n<td>list all the open files and the process information that opened it<\/td>\n<\/tr>\n<tr>\n<td><strong><code>resolvectl<\/code><\/strong><\/td>\n<td>Checks DNS configuration and status<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--kg-card-end: html--><\/p>\n<p>Let&#8217;s understand each command and see how we can use it to troubleshoot Linux.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udccc<\/div>\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Important Note:<\/strong><\/b> Every command\/utility mentioned in this post has many options and flags. <\/p>\n<p>Every command has a man page and you can use it to identify the flags and options that are required for your use case. <\/p>\n<p>For example, for <code spellcheck=\"false\" style=\"white-space: pre-wrap;\">ip<\/code> command, you can just type it <code spellcheck=\"false\" style=\"white-space: pre-wrap;\">man ip<\/code> in the terminal to get all the details about that command.<\/div>\n<\/div>\n<h3 id=\"1-hostname\">1. hostname<\/h3>\n<p>Hostname command is used to view the hostname of the machine and to set the hostname.<\/p>\n<pre><code class=\"language-bash\">hostname<\/code><\/pre>\n<p>You can use the hostname command to set a new hostname for the machine. For example,<\/p>\n<pre><code class=\"language-bash\">sudo hostname temp.com<\/code><\/pre>\n<p>If you set the hostname using &#8220;<code>hostname<\/code>&#8221; command, when you restart the machine, the hostname will change to the name specified in the hostname file ( eg: \/etc\/hostname).<\/p>\n<p>So if you want to change the hostname permanently, you can use the <code>\/etc\/hosts<\/code> file or relevant hostname file present on the server.<\/p>\n<ol>\n<li>For ubuntu machines, you can change it in the <strong><code>\/etc\/hostname<\/code><\/strong> file.<\/li>\n<li>For RHEL, CentOS and Fedora you can change it in the <strong><code>\/etc\/sysconfig\/network<\/code><\/strong> file.<\/li>\n<\/ol>\n<h3 id=\"2-host\">2. host<\/h3>\n<p>Host command is for the reverse lookup of IP or a DNS name.<\/p>\n<p>For example, If you want to find a DNS attached with an IP you can use the host commands as follows.<\/p>\n<pre><code class=\"language-bash\">host 8.8.8.8<\/code><\/pre>\n<p>You can also do the reverse to find the IP address associated with the domain name. For example,<\/p>\n<pre><code class=\"language-bash\">host devopscube.com<\/code><\/pre>\n<h3 id=\"3-ping\">3. ping<\/h3>\n<p>The ping networking utility is used to check if the remote server is reachable or not. It is primarily used for checking the connectivity and troubleshooting the network.<\/p>\n<p>It provides the following details.<\/p>\n<ol>\n<li>Bytes sent and received<\/li>\n<li>Packets sent, received, and lost<\/li>\n<li>Approximate round-trip time (in milliseconds)<\/li>\n<\/ol>\n<p>Ping command has the following syntax.<\/p>\n<pre><code class=\"language-bash\">ping &lt;IP or DNS&gt;<\/code><\/pre>\n<p>For example,<\/p>\n<pre><code class=\"language-bash\">ping devopscube.com<\/code><\/pre>\n<p>To ping IP address<\/p>\n<pre><code class=\"language-bash\">ping 8.8.8.8<\/code><\/pre>\n<p>If you want to limit the ping output without using ctrl+c, then you can use the &#8220;-c&#8221; flag with a number as shown below.<\/p>\n<pre><code class=\"language-bash\">ping -c 1 devopscube.com<\/code><\/pre>\n<h3 id=\"4-curl\">4. curl<\/h3>\n<p>Curl utility is primarily used to transfer data from or to a server. However, you can use it for network troubleshooting.<\/p>\n<p>For network troubleshooting, <code>curl<\/code> supports protocols such as <code>DICT<\/code>, <code>FILE<\/code>, <code>FTP<\/code>, <code>FTPS<\/code>, <code>GOPHER<\/code>, <code>HTTP<\/code>, <code>HTTPS<\/code>, <code>IMAP<\/code>, <code>IMAPS<\/code>, <code>LDAP<\/code>, <code>LDAPS<\/code>, <code>MQTT<\/code>, <code>POP3<\/code>, <code>POP3S<\/code>, <code>RTMP<\/code>, <code>RTMPS<\/code>, <code>RTSP<\/code>, <code>SCP<\/code>, <code>SFTP<\/code>, <code>SMB<\/code>, <code>SMBS<\/code>, <code>SMTP<\/code>, <code>SMTPS<\/code>, <code>TELNET<\/code> and <code>TFTP<\/code><\/p>\n<p>For example, <code>curl<\/code> can check connectivity on port 22 using telnet.<\/p>\n<pre><code class=\"language-bash\">curl -v telnet:\/\/192.168.33.10:22<\/code><\/pre>\n<p>You can check the FTP connectivity using curl.<\/p>\n<pre><code class=\"language-bash\">curl ftp:\/\/ftptest.net <\/code><\/pre>\n<p>You can troubleshoot web server connectivity as well.<\/p>\n<pre><code class=\"language-bash\">curl http:\/\/devopscube.com -I<\/code><\/pre>\n<h3 id=\"5-wget\">5. wget<\/h3>\n<p>The <code>wget<\/code> command is primarily used to fetch web pages.<\/p>\n<p>You can use <code>wget<\/code> to troubleshoot network issues as well.<\/p>\n<p>For example, you can troubleshoot <a href=\"https:\/\/devopscube.com\/setup-and-configure-proxy-server\/\" rel=\"noreferrer noopener\">proxy server<\/a> connections using wget.<\/p>\n<pre><code class=\"language-bash\">wget -e use_proxy=yes http_proxy=&lt;proxy_host:port&gt; http:\/\/externalsite.com<\/code><\/pre>\n<p>You can check if a website is up by fetching the files.<\/p>\n<pre><code class=\"language-bash\">wget www.google.com<\/code><\/pre>\n<h3 id=\"6-ip-ifconfig\">6. ip (ifconfig)<\/h3>\n<p><strong><code>ip<\/code><\/strong> command is used to display and manipulate routes and network interfaces. <strong>ip<\/strong> command is the newer version of<strong> <code>ifconfig<\/code>.<\/strong> ifconfig works in all the systems, but it is better to use ip command instead of ifconfig.<\/p>\n<p>Let&#8217;s have a look at a few examples of <code>ip<\/code> command.<\/p>\n<h4 id=\"display-network-devices-and-configuration\">Display network devices and configuration<\/h4>\n<pre><code class=\"language-bash\">ip addr<\/code><\/pre>\n<p>You can use this command with pipes and grep to get more granular output like the IP address of the eth0 interface. It is very useful when you work on <a href=\"https:\/\/devopscube.com\/devops-tools-for-infrastructure-automation\/\" rel=\"noreferrer noopener\">automation tools<\/a> that require IP to be fetched dynamically.<\/p>\n<p>The following command gets the IP address of <code>eth0<\/code> network interface.<\/p>\n<pre><code class=\"language-bash\">ip a | grep eth0  | grep \"inet\" | awk -F\" \" '{print $2}'<\/code><\/pre>\n<p>Get details of a specific interface<\/p>\n<pre><code class=\"language-bash\">ip a show eth0<\/code><\/pre>\n<p>You can list the routing tables.<\/p>\n<pre><code class=\"language-bash\">ip route\nip route list<\/code><\/pre>\n<h3 id=\"7-arp\">7. arp<\/h3>\n<p>ARP (<strong>Address Resolution Protocol<\/strong>) shows the cache table of local networks&#8217; IP addresses and MAC addresses that the system interacted with.<\/p>\n<pre><code class=\"language-bash\">arp<\/code><\/pre>\n<p>Example output,<\/p>\n<pre><code class=\"language-bash\">vagrant@dcubelab:~$ arp\nAddress                  HWtype  HWaddress           Flags Mask            Iface\n10.0.2.3                 ether   52:54:00:12:35:03   C                     eth0\n192.168.33.1             ether   0a:00:27:00:00:00   C                     eth1\n10.0.2.2                 ether   52:54:00:12:35:02   C                     eth0<\/code><\/pre>\n<h3 id=\"8-ss-netstat\">8. ss (netstat)<\/h3>\n<p>The <code>ss<\/code> command is a replacement for <code>netstat<\/code>. You can still use the <code>netstat<\/code> command on all systems.<\/p>\n<p>Using <code>ss<\/code> command, you can get more information than <code>netstat<\/code> command. ss command is fast because it gets all the information from the kernel userspace.<\/p>\n<p>Now let&#8217;s have a look at a few usages of <code>ss<\/code> command.<\/p>\n<h4 id=\"listing-all-connections\">Listing all connections<\/h4>\n<p>The &#8220;<code>ss<\/code>&#8221; command will list all the TCP, UDP, and Unix socket connections on your machine.<\/p>\n<pre><code class=\"language-bash\">ubuntu@devopscube:~$ ss\nNetid  State      Recv-Q Send-Q   Local Address:Port       Peer Address:Port\nu_str  ESTAB      0      0                    * 7594                  * 0\nu_str  ESTAB      0      0      @\/com\/ubuntu\/upstart 7605                  * 0  \nu_str  ESTAB      0      0                    * 29701                 * 0\nu_str  ESTAB      0      0      \/var\/run\/dbus\/system_bus_socket 29702                 * 0\ntcp    ESTAB      0      400      172.31.18.184:ssh         1.22.167.31:61808<\/code><\/pre>\n<p>The output of the <code>ss<\/code> command will be big so you can use &#8221; <code>ss | less<\/code> &#8221; command to make the output scrollable.<\/p>\n<h4 id=\"filtering-out-tcp-udp-and-unix-sockets\">Filtering out TCP, UDP and Unix sockets<\/h4>\n<p>If you want to filter out TCP , UDP or UNIX socket details, use &#8220;-t&#8221; &#8220;-u&#8221; and &#8220;-x&#8221; flag with the &#8220;ss&#8221; command. It will show all the established connections to the specific ports. If you want to list both connected and listening ports using &#8220;a&#8221; with the specific flag as shown below.<\/p>\n<pre><code class=\"language-bash\">ss -ta\nss -ua\nss -xa<\/code><\/pre>\n<h4 id=\"list-all-listening-ports\">List all listening ports<\/h4>\n<p>To list all the listening ports, use &#8220;-l&#8221; flag with ss command. To list specific TCP, UDP or UNIX socket, use &#8220;-t&#8221;, &#8220;-u&#8221; and &#8220;-x&#8221; flag with &#8220;-l&#8221; as shown below.<\/p>\n<pre><code class=\"language-bash\">ubuntu@devopscube:~$ ss -lt\nState      Recv-Q Send-Q      Local Address:Port          Peer Address:Port\nLISTEN     0      128                     *:ssh                      *:*\nLISTEN     0      50                     :::http-alt                 :::*\nLISTEN     0      50                     :::55857                   :::*\nLISTEN     0      128                    :::ssh                     :::*\nLISTEN     0      50                     :::53285                   :::*\nubuntu@devopscube:~$\n<\/code><\/pre>\n<h4 id=\"list-all-established\">List all established<\/h4>\n<p>To list all the established ports, use the <code>state established<\/code> flag as shown below.<\/p>\n<pre><code class=\"language-bash\">ss -t -r state established<\/code><\/pre>\n<p>To list all sockets in listening state,<\/p>\n<pre><code class=\"language-bash\">ss -t -r state listening<\/code><\/pre>\n<h3 id=\"9-traceroute\">9. traceroute<\/h3>\n<p>If you do not have a <code>traceroute<\/code> utility in your system or server, you can install it from the native repository.<\/p>\n<p><code>traceroute<\/code> is a network troubleshooting utility. Using traceroute you can find the number of hops required for a particular packet to reach the destination. You can essentially trace the path of the packet from your server to the remote host.<\/p>\n<p>For example,<\/p>\n<pre><code class=\"language-bash\">traceroute google.com<\/code><\/pre>\n<p>Here is the output.<\/p>\n<pre><code class=\"language-bash\">traceroute to google.com (173.194.33.163), 30 hops max, 60 byte packets\n 1  ec2-50-112-0-84.us-west-2.compute.amazonaws.com (50.112.0.84)  1.974 ms  1.895 ms  1.899 ms\n 2  100.64.1.247 (100.64.1.247)  1.414 ms 100.64.1.137 (100.64.1.137)  1.127 ms 100.64.1.97 (100.64.1.97)  1.313 ms\n 3  100.64.0.198 (100.64.0.198)  1.443 ms 100.64.0.62 (100.64.0.62)  2.160 ms 100.64.0.60 (100.64.0.60)  2.116 ms\n10  66.249.94.214 (66.249.94.214)  6.313 ms  7.104 ms 209.85.249.34 (209.85.249.34)  5.986 ms\n11  209.85.244.65 (209.85.244.65)  6.157 ms  6.341 ms  6.574 m.\n.\n12  sea09s18-in-f3.1e100.net (173.194.33.163)  6.302 ms  6.517 ms  6.071 ms\nubuntu@devopscube:~$<\/code><\/pre>\n<p>The above output shows the hop count (12) to reach google.com from devopscube AWS ec2 server.<\/p>\n<p>This utiltity comes in handy when you want to troubleshoot issues related to network packets not reaching the host.<\/p>\n<h3 id=\"10-mtr\">10. mtr<\/h3>\n<p>The <code>mtr<\/code> utility is a network diagnostic tool to troubleshoot the network bottlenecks. It combines the functionality of both <code>ping<\/code> and <code>traceroute<\/code><\/p>\n<p>For example, the following command shows the <code>traceroute<\/code> output in real-time.<\/p>\n<pre><code class=\"language-bash\">mtr google.com<\/code><\/pre>\n<p>Here is the output.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/mtr-output-min-2.png\" class=\"kg-image\" alt=\"mtr network diagnostic tool\" loading=\"lazy\" width=\"988\" height=\"509\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/mtr-output-min-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/mtr-output-min-2.png 988w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h4 id=\"mtr-report\">mtr report<\/h4>\n<p>You can generate a report using the &#8211;report flag. When you run the mtr report, it sends 10 packets to the destination and creates the report.<\/p>\n<pre><code class=\"language-bash\">mtr -n --report google.com<\/code><\/pre>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/mtr-report-min-2.png\" class=\"kg-image\" alt=\"network troubleshooting with mtr report\" loading=\"lazy\" width=\"853\" height=\"431\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/mtr-report-min-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/mtr-report-min-2.png 853w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h3 id=\"11-dig\">11. dig<\/h3>\n<p>If you have any task related to DNS lookup, you can use &#8220;<code>dig<\/code>&#8221; command to query the DNS name servers.<\/p>\n<h4 id=\"get-all-dns-records-with-dig\">Get all DNS records with dig<\/h4>\n<p>The following command returns all the DNS records and TTL information of a twitter.com<\/p>\n<pre><code class=\"language-bash\">dig twiter.com ANY<\/code><\/pre>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/dig-output-min-2.png\" class=\"kg-image\" alt=\"all DNS records with dig\" loading=\"lazy\" width=\"749\" height=\"679\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/dig-output-min-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/dig-output-min-2.png 749w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Use <code>+short<\/code> to get the output without verbose.<\/p>\n<pre><code class=\"language-bash\">dig google.com ANY +short<\/code><\/pre>\n<h4 id=\"get-specific-dns-record-with-dig\">Get Specific DNS Record with dig<\/h4>\n<p>For example, If you want to get the <code>A record<\/code> for the particular domain name, you can use the dig command.  <code>+short<\/code> will provide the information without verbose<\/p>\n<pre><code class=\"language-bash\">dig www.google.com A +short<\/code><\/pre>\n<p>Similarly, you can get the other record information separately using the following commands.<\/p>\n<pre><code class=\"language-bash\">dig google.com CNAME +short\ndig google.com MX +short\ndig google.com TXT +short\ndig google.com NS +short\n<\/code><\/pre>\n<h4 id=\"reverse-dns-lookup-with-dig\">Reverse DNS Lookup with dig<\/h4>\n<p>You can perform a reverse DNS lookup with dig using the following command. Replace <code>8.8.8.8<\/code> with the required IP<\/p>\n<pre><code class=\"language-bash\">dig -x 8.8.8.8<\/code><\/pre>\n<h3 id=\"12-nslookup\">12. nslookup<\/h3>\n<p><strong>Nslookup <\/strong>(Name Server Lookup) utility is used to check the DNS entries. It is similar to dig command.<\/p>\n<p>To check the DNS records of a domain, you can use the following command.<\/p>\n<pre><code class=\"language-bash\">nslookup google.com<\/code><\/pre>\n<p>You can also do a reverse lookup with the IP address.<\/p>\n<pre><code class=\"language-bash\">nslookup 8.8.8.8<\/code><\/pre>\n<p>To get all the DNS records of a domain name, you can use the following.<\/p>\n<pre><code class=\"language-bash\">nslookup -type=any google.com<\/code><\/pre>\n<p>Similarly, you can query for records like <code>mx<\/code>, <code>soa<\/code> etc<\/p>\n<h3 id=\"13-nc-netcat\">13. nc (netcat)<\/h3>\n<p>The <code>nc<\/code> (netcat) command is known as the swiss army of networking commands.<\/p>\n<p>Using <code>nc<\/code>, you can check the connectivity of a service running on a specific port.<\/p>\n<p>For example, to check if <code>ssh<\/code> port is open, you can use the following command.<\/p>\n<pre><code class=\"language-bash\">nc -v -n 192.168.33.10 22<\/code><\/pre>\n<p><code>netcat<\/code> can also be used for data transfer over TCP\/UDP and port scanning.<\/p>\n<p>Port scanning is not recommended in cloud environments. You need to request the cloud provider to perform port scanning operations in your environment.<\/p>\n<h3 id=\"14-telnet\">14. telnet<\/h3>\n<p>The telnet command is used to troubleshoot the TCP connections on a port.<\/p>\n<p>To check port connectivity using telnet, use the following command.<\/p>\n<pre><code class=\"language-bash\">telnet 10.4.5.5 22<\/code><\/pre>\n<h3 id=\"15-route\">15. route<\/h3>\n<p>The &#8220;<code>route<\/code>&#8221; command is used to get the details of the route table for your system and to manipulate it. Let us look at a few examples for the route command.<\/p>\n<h4 id=\"listing-all-routes\">Listing all routes<\/h4>\n<p>Execute the &#8220;<code>route<\/code>&#8221; command without any arguments to list all the existing routes in your system or server.<\/p>\n<pre><code class=\"language-bash\">ubuntu@devopscube:~$ route\nKernel IP routing table\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\ndefault         ip-172-31-16-1. 0.0.0.0         UG    0      0        0 eth0\n172.17.0.0      *               255.255.0.0     U     0      0        0 docker0\n172.31.16.0     *               255.255.240.0   U     0      0        0 eth0\nubuntu@devopscube:~$<\/code><\/pre>\n<p>If you want to get the full output in numerical form without any hostname, you can use &#8220;-n&#8221; flag with the route  command.<\/p>\n<pre><code class=\"language-bash\">ubuntu@devopscube:~$ route -n\nKernel IP routing table\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\n0.0.0.0         172.31.16.1     0.0.0.0         UG    0      0        0 eth0\n172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0\n172.31.16.0     0.0.0.0         255.255.240.0   U     0      0        0 eth0\nubuntu@devopscube:~$<\/code><\/pre>\n<h3 id=\"16-tcpdump\">16. tcpdump<\/h3>\n<p>The <code>tcpdump<\/code> command is primarily used for troubleshooting network traffic.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> To analyze the output of <code spellcheck=\"false\" style=\"white-space: pre-wrap;\">tcpdump<\/code> command requires some learning, so explaining it is out of the scope of this article.<\/div>\n<\/div>\n<p><code>tcpdump<\/code> command works with the network interfaces of the system. So you need to use administrative privileges to execute the command.<\/p>\n<h4 id=\"list-all-network-interfaces\">List all network interfaces<\/h4>\n<p>Use the following command to list all the interfaces.<\/p>\n<pre><code class=\"language-bash\">sudo  tcpdump --list-interfaces<\/code><\/pre>\n<h4 id=\"capture-packets-on-specific-interface\">Capture Packets on Specific Interface<\/h4>\n<p>To get the dump of packets on a specific interface, you can use the following command.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> press <code spellcheck=\"false\" style=\"white-space: pre-wrap;\">ctrl + c <\/code>to stop capturing the packets.<\/div>\n<\/div>\n<pre><code class=\"language-bash\">sudo tcpdump -i eth0<\/code><\/pre>\n<p>To limit the packet capturing, you can use the <code>-c<\/code> flag with the number.<\/p>\n<p>For example,<\/p>\n<pre><code class=\"language-bash\">sudo tcpdump -i eth0 -c 10<\/code><\/pre>\n<h4 id=\"capture-packets-on-all-interfaces\">Capture Packets on All Interfaces<\/h4>\n<p>To capture packets on all the interfaces, use the <code>any<\/code> flag as shown below.<\/p>\n<pre><code class=\"language-bash\">sudo tcpdump -i any<\/code><\/pre>\n<h3 id=\"17-lsof\">17. lsof<\/h3>\n<p><code>lsof<\/code> is a command that would used in day to day linux troubleshooting. This command is equally important for anyone working with Linux systems.<\/p>\n<p>To list all open files, execute the <code>lsof<\/code> command.<\/p>\n<pre><code class=\"language-bash\">lsof<\/code><\/pre>\n<p>One of the common error face by developers &amp; DevOps engineers is &#8220;<strong>Bind failed error: Address already in use<\/strong>&#8220;. You can find the process ID associated with a port using the following command. The you can kill the process to free up the port.<\/p>\n<pre><code class=\"language-bash\">lsof -i :8080<\/code><\/pre>\n<h3 id=\"18-resolvectl\">18. resolvectl<\/h3>\n<p>With resolvectl you can checks DNS configuration and status in systems using <code>systemd-resolved<\/code>.<\/p>\n<pre><code class=\"language-bash\">$ resolvectl query devopscube.com\n\ndevopscube.com: 151.101.67.7                   -- link: enp1s0\n                151.101.3.7                    -- link: enp1s0\n                151.101.195.7                  -- link: enp1s0\n                151.101.131.7                  -- link: enp1s0\n                2a04:4e42:600::775             -- link: enp1s0\n                2a04:4e42::775                 -- link: enp1s0\n                2a04:4e42:400::775             -- link: enp1s0\n                2a04:4e42:200::775             -- link: enp1s0\n\n-- Information acquired via protocol DNS in 82.9ms.\n-- Data is authenticated: no; Data was acquired via local or encrypted transport: no\n-- Data from: network<\/code><\/pre>\n<p>It basically replaces the older \/etc\/resolv.conf   based checks in modern systems<\/p>\n<h2 id=\"bonus-tools-for-devopssre\">Bonus Tools for DevOps\/SRE<\/h2>\n<p>There are more networking troubleshooting command-line utilities available from third-party solutions.<\/p>\n<p>You need to install them separately and use them for your troubleshooting purposes. Due to security compliance reasons, not every organisation will allow you to do it.<\/p>\n<p>However, if you have to option to use third-party tools, you can explore them.<\/p>\n<p>We have organized some tool information under different categories in the following table.<\/p>\n<p><!--kg-card-begin: html--><\/p>\n<table>\n<thead>\n<tr>\n<th>Category<\/th>\n<th>Open-Source Tools<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>Network Scanners<\/strong><\/td>\n<td>Nmap, Zenmap (GUI for Nmap)<\/td>\n<\/tr>\n<tr>\n<td><strong>Packet Analyzers<\/strong><\/td>\n<td>Wireshark, Tcpdump<\/td>\n<\/tr>\n<tr>\n<td><strong>Bandwidth Monitors<\/strong><\/td>\n<td>BandwidthD, Cacti<\/td>\n<\/tr>\n<tr>\n<td><strong>Port Scanners<\/strong><\/td>\n<td>Nmap, Masscan<\/td>\n<\/tr>\n<tr>\n<td><strong>Ping\/Traceroute Tools<\/strong><\/td>\n<td>MTR (My Traceroute)<\/td>\n<\/tr>\n<tr>\n<td><strong>Wireless Network Analyzers<\/strong><\/td>\n<td>Wireshark (for wireless), Kismet<\/td>\n<\/tr>\n<tr>\n<td><strong>Network Simulators<\/strong><\/td>\n<td>GNS3, Mininet<\/td>\n<\/tr>\n<tr>\n<td><strong>DNS Performance<\/strong><\/td>\n<td>DNSperf, dnstop<\/td>\n<\/tr>\n<tr>\n<td><strong>Network Performance Testing<\/strong><\/td>\n<td>iperf3, netperf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--kg-card-end: html--><\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>In this article, we have covered the important Linux command-line utilities for <strong>network troubleshooting and configuration.<\/strong><\/p>\n<p>If you are getting started with system administration, DevOps, or SRE roles, it is essential to learn about these utilities to support the projects you are working on.<\/p>\n<p>Each utility has many functionalities, and you can explore further to meet your requirements.<\/p>\n<p>If you think we missed any important commands,  let us know in the comments section.<\/p>\n<p>Also, if you want to learn shell scripting, check out our guide on <a href=\"https:\/\/devopscube.com\/linux-shell-scripting-for-devops\/\" rel=\"noreferrer noopener\">how to learn shell scripting<\/a>. If you are developers, check out my guide on <a href=\"https:\/\/devopscube.com\/list-of-linux-commands-every-developer-should-know\/\" rel=\"noreferrer noopener\">Linux Commands <\/a>every Developer should know.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/list-linux-networking-troubleshooting-and-commands-beginners\/\" target=\"_blank\" rel=\"noopener noreferrer\">17 Best Linux Networking and Troubleshooting Commands \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/list-linux-networking-troubleshooting-and-commands-beginners\/<\/p>\n","protected":false},"author":1,"featured_media":461,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-460","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=460"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/460\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/461"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}