7 Linux Commands to Check Network Connectivity

Use these command-line commands to display and troubleshoot network connectivity and performance issues on Windows or Linux systems.

7 Commands to Check Network ConnectivitySuppose you just completed deploying a new network device. Maybe it's a Linux server, Windows workstation or Raspberry Pi device. You need to verify its network connectivity and perhaps evaluate the connection's quality. What kinds of tests could you run? And what commands and graphical tools display this kind of information?

Use the following basic network troubleshooting or identification methods to find network connectivity information:

  1. Check the IP address configuration
  2. Confirm basic connectivity
  3. Display the network path to a remote system
  4. Check the quality of the network path

 

Advance your career with what employers want. CompTIA's Linux+ certification

Start Today

Many administrators find it easier to use command-line commands for these tests, but graphical tools are also available. The following table contains some basic network commands for Linux and Windows:

 Tool

 Operating System

 Function

 ipconfig

 Windows

 Display IP address configuration

 ip addr

 Linux

 Display IP address configuration

 ping

 Windows and Linux

 Test connectivity

 tracert

 Windows

 Trace the path to a remote destination

 traceroute

 Linux

 Trace the path to a remote destination

 pathping

 Windows

 Display the quality of a path to a remote destination

 mtr

 Linux

 Display the quality of a path to a remote destination

Note that many of the Linux commands will also work on macOS.

Troubleshooting Tasks

Check basic configuration and connectivity information before concerning yourself with network performance information. The following are common steps to confirm connectivity or troubleshoot network issues.

Check the IP Address Configuration

The most fundamental network troubleshooting step is confirming the local system's current configuration. The key values to check are the IPv4 address, subnet mask, default gateway and DNS server configurations. You can also display the system name using the hostname command.

On a Windows device, open a command prompt or PowerShell window and type the following command:

ipconfig

ipconfig

Figure 1: The Windows ipconfig command.

Use the/all switch to display even more detail:

ipconfig /all

ipconfigall

Figure 2: The Windows ipconfig /all command


On your Linux box, type this command to display the IP address configuration:

ip addr

ipaddr

Figure 3: The Linux ip addr command

The network ID for the IP address should match the range specified for your network. Verify the subnet mask is accurate. The default gateway (router's IP address) and DNS server IP addresses must also be correct.

Tip: If the IP address begins with 169.254.x.x, the system is trying to lease an IP address from a DHCP server, but the process is failing. Troubleshoot this by ensuring the system can reach the DHCP server. Don't forget to confirm the DHCP server has addresses available to lease.

Confirm Basic Connectivity

Assuming the IP address settings are correct, test basic connectivity using the ping command, which relies on the ICMP protocol. This tool is mostly the same on Windows and Linux, though Windows automatically limits ping to four attempts, and Linux sends continuous pings by default.

Ping a remote host at 192.168.2.200:

ping 192.168.2.200

The ping command sends an Echo Request message. You should receive an Echo Reply with network performance information from the specified IP, indicating a successful response.

By default, Linux systems send continuous pings. Use the -c option to specify the number of pings to send. Three or four is usually sufficient.

ping -c 3 192.168.2.200

Or ping by hostname or domain name, such as:

ping -c 3 comptia.org

linuxping

Figure 4: The ping command

To narrow the scope of a network problem, ping the remote destination by IP and hostname:

  • If the ping by IP succeeds and the ping by hostname succeeds, you have connectivity and name resolution
  • If the ping by IP succeeds, but the ping by hostname fails, you have connectivity but no name resolution
  • If the ping by IP fails, you have a network connection problem

Display the Network Path to a Remote System

The ping utility indicates whether you have connectivity, but it does not tell you by what path that connectivity is established. In a complex network, this path could span multiple segments and routers. Ping doesn't indicate how it verified connectivity, just that it did.

The traceroute tool reports the path through routers to the remote system. If the trace is successful, network connectivity is functional, so you could use it instead of ping. It is more time-consuming, however.

On Windows, type:

tracert comptia.org

tracert

Figure 5: The Windows tracert command

On Linux, use:

traceroute comptia.org

traceroute

Figure 6: The Linux traceroute command

Note that the connectivity test traversed nine hops to reach the destination.

Check the Quality of the Network Path

The ping command tells you connectivity exists, and traceroute reports the connectivity path, but neither gives much detail about the quality of the path. Windows and Linux use different tools to provide this information.

At the Windows command prompt, type:

pathping comptia.org

The results below display the performance information from pathping.

pathpingresults

Figure 7: The Windows pathping command

Note that pathping can take a fairly long time to run (often several minutes), so be patient. Like traceroute, you'll see the network path. You'll also see performance information, including dropped packets. This packet loss data is useful for troubleshooting routers and failing network interface cards (NICs).

The My TraceRoute (mtr) utility provides a real-time look at network performance on a Linux system. Use Ctrl+C to interrupt it when you're done monitoring. Look at the mtr man page for options on saving results to a file.

To see mtr results in real-time, enter:

mtr comptia.org

mtr

Figure 8: The Linux mtr command

Select Ctrl+C when you're done.

GUI Network Information Tools

Today's administrators are usually comfortable at the command line, but graphical tools are available to show connectivity and performance information, including the NIC's workload.

One effective Windows network performance tool is Task Manager. There are several ways of accessing Task Manager. I right click the taskbar and select Task Manager from the context menu.

taskmgr

Figure 9: The Windows Task Manager console

Notice the performance graph indicating traffic sent and received by the NIC.

Linux has various graphical user interfaces, but most distributions provide a utility to display network information. Here is an example from a CentOS Linux system:

networkmonitor

Figure 10: The Linux network monitor console

It provides the same kind of information as the Windows Task Manager.

Get Comfortable With Command Line Interfaces

This tutorial helps you recognize and use these tools to confirm network connectivity after deploying a new workstation, server or even a virtual machine. They are the same utilities you would use when troubleshooting a network issue as a desktop support technician or help desk team member. These tools are a great way to get more comfortable with the command line interfaces on both Windows and Linux (and macOS).

Learn the skills you need with CompTIA CertMaster Learn. Sign up today for a free trial today!

Email us at blogeditor@comptia.org for inquiries related to contributed articles, link building and other web content needs.

Read More from the CompTIA Blog

Leave a Comment