Troubleshoot and Monitor Your Internet Connection with These Easy Steps

A step-by-step guide to check network connection on Raspberry Pi using the command line interface. …


Updated August 16, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


A step-by-step guide to check network connection on Raspberry Pi using the command line interface. When you’re working with a Raspberry Pi, it’s important to ensure that your device is connected to the internet so that you can use various applications and services. In this article, we will explore how to check the network connection on your Raspberry Pi using the command line interface. This will help you troubleshoot any issues and monitor your network performance.

Step 1: Checking the IP Address

To begin with, let’s see if your Raspberry Pi is assigned an IP address by the DHCP server on your local network. Open a terminal window and type in the following command:

hostname -I

This will display all the IP addresses assigned to your device. If you see an output like 192.168.1.10 or similar, then your Pi is connected to the network and has been assigned an IP address.

Step 2: Checking DNS Resolution

Next, we will check if your Raspberry Pi can resolve domain names into IP addresses. Open a terminal window and type in the following command:

ping -c 4 google.com

This will send four packets to google.com and report back if any were successful or not. If you see output similar to this:

PING google.com (172.217.30.68) 56(84) bytes of data.
64 bytes from lga25s59-in-f68.1e100.net (172.217.30.68): icmp_seq=1 ttl=57 time=16.2 ms
64 bytes from lga25s59-in-f68.1e100.net (172.217.30.68): icmp_seq=2 ttl=57 time=15.9 ms
64 bytes from lga25s59-in-f68.1e100.net (172.217.30.68): icmp_seq=3 ttl=57 time=15.9 ms
64 bytes from lga25s59-in-f68.1e100.net (172.217.30.68): icmp_seq=4 ttl=57 time=16.6 ms

Then your Pi can resolve domain names and connect to the internet. If you see ping: google.com: Name or service not known, then it’s likely that DNS resolution is not working correctly. In this case, you may need to update your /etc/resolv.conf file with correct DNS servers, such as Google’s public DNS (8.8.8.8.8 and 8.8.4.4.4).

Step 3: Checking Connectivity to a Specific Service

If you want to check connectivity to a specific service or application, you can use the curl command in the terminal window. For example, if you want to see if you can access the Raspberry Pi Foundation’s website, type in the following command:

curl -I https://www.raspberrypi.org/

This will return headers from the web server and indicate whether your device can connect or not. If it’s successful, you should see output similar to this:

HTTP/2 200
date: Thu, 17 Jun 2021 18:35:06 GMT
content-type: text/html; charset=utf-8
x-powered-by: PHP/7.3.27
...

If there is an issue, you may see an error message like curl: (6) Could not resolve host: www.raspberrypi.org.

Step 4: Checking Network Speed

To check the speed of your internet connection on your Raspberry Pi, you can use the speedtest-cli command. First, you need to install it by running the following commands in the terminal window:

sudo apt update
sudo apt install speedtest-cli

Once installed, you can run a speed test using this command:

speedtest-cli

This will perform a download and upload speed test and report back the results. If your connection is slow or not working correctly, you may want to check with your internet service provider for potential issues.

Step 5: Monitoring Network Performance

To monitor network performance over time, you can use tools like nload and iftop. These will show you real-time data on the traffic going in and out of your device. To install them, run these commands in a terminal window:

sudo apt update
sudo apt install nload iftop

To start monitoring network traffic with nload, type in the following command:

nload

This will display a graph showing data transfer rates. To stop it, press Ctrl+C.

To monitor network traffic with iftop, type in the following command:

sudo iftop -i wlan0

Replace wlan0 with the name of your network interface if it’s different. This will display a list of active connections and their bandwidth usage. To stop it, press q.

With these steps, you should be able to check your Raspberry Pi’s network connection and troubleshoot any issues that arise. Remember, if you still have problems after following these steps, consult your internet service provider or seek further assistance from the Raspberry Pi community forums.