How to Check if Ubuntu Server is Connected to the Internet

It is essential to verify that your Ubuntu server has a stable internet connection to access online resources, install packages, and communicate with other systems.

In this guide, we’ll demonstrate how to check if your Ubuntu server is connected to the internet using a few simple commands.

Let’s get started!

Step 1: Ping a Well-Known Domain

The ping command sends small packets of data to a specified domain or IP address and measures the response time. It’s a simple and effective way to check if your server has an active internet connection. To check the connection using ping, run the following command:

ping -c 4

This command sends 4 ICMP packets to If your server is connected to the internet, you’ll see output similar to the following:

PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=110 time=24.1 ms
64 bytes from ( icmp_seq=2 ttl=110 time=24.0 ms
64 bytes from ( icmp_seq=3 ttl=110 time=24.0 ms
64 bytes from ( icmp_seq=4 ttl=110 time=24.1 ms

--- ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 24.041/24.090/24.126/0.114 ms

If you don’t receive any packets or see 100% packet loss, your server might not be connected to the internet.

See also  How to Install and Configure Bind 9 as a Caching Server on Ubuntu 11.10

Step 2: Test DNS Resolution

Another way to check your server’s internet connection is by testing its DNS resolution. The nslookup command queries the Domain Name System (DNS) to obtain the IP address associated with a domain name. To check DNS resolution, run the following command:


If your server is connected to the internet and has a working DNS configuration, you’ll see output similar to the following:


Non-authoritative answer:
Address: 2a00:1450:4010:c0f::71
Address: 2a00:1450:4010:c0f::8a
Address: 2a00:1450:4010:c0f::66
Address: 2a00:1450:4010:c0f::64

If the command fails or returns an error message, it indicates an issue with your server’s internet connection or DNS configuration.

Step 3: Check Network Interface and Gateway

To verify that your server’s network interface is up and running, use the ip command:

ip addr

This command displays information about the network interfaces on your system. Check for an assigned IP address in the output.

See also  How to Run the .sh File Shell Script In CentOS/RHEL

To check the default gateway configuration, run the following command:

ip route

Ensure that the default gateway is correctly configured, as it is responsible for routing traffic between your server and the internet.


You now know how to check if your Ubuntu server is connected to the internet using the ping, nslookup, and ip commands. These methods help you diagnose connectivity issues and ensure that your server can access online resources as needed.

Feel free to leave any questions, comments, or suggestions for improvement in the comments section below.

If you’re scouting for the crème de la crème of hosting providers for 2023, we’ve got just the guide for you. Explore our ‘Best Ubuntu Hosting 2023‘ article to find your perfect hosting match. Quality hosting is just a click away!

Additional Troubleshooting

If you still encounter connectivity issues after following the above steps, consider checking the following:

  1. Firewall settings: Make sure your server’s firewall isn’t blocking outgoing or incoming traffic. You can check the current firewall configuration using the sudo ufw status command if you’re using UFW (Uncomplicated Firewall). Adjust the firewall settings if necessary.
  2. Network configuration files: Verify the network configuration files located in the /etc/netplan directory (for Ubuntu 18.04 and newer). Check for any errors or misconfigurations in these files, and correct them if needed. After making changes, apply the new configuration using the sudo netplan apply command.
  3. Proxy settings: If your server is behind a proxy, ensure that the proxy settings are correctly configured. You can check the environment variables for proxy settings with the env | grep -i proxy command. Update the proxy settings in the /etc/environment file or the appropriate configuration files if needed.
  4. Hardware issues: Check for any hardware-related issues, such as faulty Ethernet cables or network interface cards. Replace or fix the hardware components if necessary.
See also  How to Uninstall Logstash on Ubuntu

By performing these additional troubleshooting steps, you can further diagnose and resolve connectivity issues with your Ubuntu server.


Leave a Reply

Your email address will not be published. Required fields are marked *