{"id":2449,"date":"2015-07-29T16:39:36","date_gmt":"2015-07-29T13:39:36","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/troubleshoot-network-connectivity-linux-server\/"},"modified":"2015-07-29T16:39:36","modified_gmt":"2015-07-29T13:39:36","slug":"troubleshoot-network-connectivity-linux-server","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/troubleshoot-network-connectivity-linux-server\/","title":{"rendered":"Troubleshooting Network Connectivity on Linux Servers: A Complete Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When your Linux server experiences network connectivity issues, you need reliable tools and techniques to quickly identify and resolve the problem. This guide covers essential Linux commands for troubleshooting, including how to check network interfaces, test internet connectivity, and verify DNS records. Whether you&#8217;re using Ubuntu, CentOS, or Debian, these steps will help you diagnose network failures, check server configurations, and restore connectivity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When your <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/secure-linux-cloud-server\/\">Linux server<\/a> seems to be offline or otherwise inaccessible, you should always be able to log in with the web\u00a0console at your UpCloud control panel or through a VNC connection. Once logged in, test your server\u2019s internet connection using ping and a public IP address such as Google\u2019s public DNS server, which is most likely to reply, provided your internet connection works.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ping -c 4 8.8.8.8<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your output should show something like<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=1.68 ms\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 time=1.70 ms\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=58 time=1.71 ms\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=58 time=1.69 ms\n\n--- 8.8.8.8 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3005ms\nrtt min\/avg\/max\/mdev = 1.686\/1.699\/1.718\/0.051 ms\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the server is unable to reach the destination, there may be a problem with your configuration. Follow the steps described here in order to troubleshoot the most common network issues with Linux Cloud Servers.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Try UpCloud for free!<\/a><\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/developer-plans-banner-3.png\" alt=\"developer-cloud\" class=\"wp-image-43358\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Check your network configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your Linux server is unreachable, start by checking your network interfaces. Use the ip addr command to view the status of all interfaces, ensuring critical connections like eth0 are enabled. Should you find any interfaces disabled, activate them with ifup. Troubleshoot persistent issues by restarting interfaces using the ifdown &#8211;force and ifup commands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure the network interfaces, such as eth0, are enabled. To see all the configured interfaces, use this command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ip addr<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The output of the command will show the status of each network interface on the server with \u201cstate UP\u201d or \u201cstate DOWN\u201d, for example, as below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Turn on any disabled interfaces with the next command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ifup &lt;interface name&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here the interface name is one of the names listed in the <tt>ip addr<\/tt>&nbsp;command output such as <tt>eth0<\/tt>, <tt>eth1<\/tt> or <tt>eth2<\/tt>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When all network interfaces have been enabled, try using the <tt>ping<\/tt> command again. If the problem persists, check that the network interfaces have IPs assigned to them, and they match the information in the<a href=\"https:\/\/hub.upcloud.com\/networks\/public\/\" target=\"_blank\" rel=\"noreferrer noopener\"> Network section<\/a> of the UpCloud control panel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Try restarting any problematic interface with the following commands.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ifdown &lt;interface name&gt;\nsudo ifup &lt;interface name&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If either of these commands fails, the interface may be in a state unknown to the command script. Try the same commands again withthe \u2014<tt>-force<\/tt> parameter to resolve any such issues.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ifdown --force &lt;interface name&gt;\nsudo ifup &lt;interface name&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If restarting the network interface fixed the issue then great! If not, continue with the troubleshooting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check the network configuration file<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Linux commonly stores network settings in specific files and reads them, for example, at boot or when using the ifup command. To make changes to the network configuration, you\u2019ll need to open the right file in a text editor. In Debian and Ubuntu-based distributions, this can be done with<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo nano \/etc\/network\/interfaces<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In most cases, the <tt>interfaces<\/tt> file should list the following interfaces.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet dhcp\n\nauto eth1\niface eth1 inet dhcp<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In CentOS and other Red Hat variants, these configurations are split into separate files for each network interface and stored in <tt>\/etc\/sysconfig\/network-scripts\/<\/tt>. The default interface for internet connection is usually called <tt>eth0<\/tt>, which opens the corresponding configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration file for eth0 should look like this.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">DEVICE=eth0\nBOOTPROTO=dhcp\nONBOOT=yes<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the interface configuration files do not match the example here, edit the file specific to your system to restore the original functionality. For any changes made to these files to take effect, you must restart the interfaces to which the changes apply as described previously with <tt>ifdown<\/tt> and <tt>ifup<\/tt> commands.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check the server&#8217;s DNS records<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your server can ping an IP but fails to connect to domains, it may be a DNS issue. Use ping upcloud.com to test domain name resolution, and check DNS configuration with sudo cat \/etc\/resolv.conf. Ensure your DNS servers, such as UpCloud\u2019s resolvers, are properly configured in this file or through your network interfaces file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ping upcloud.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the domain does not reply, the problem is most likely with how your server resolves domain names to IP addresses. Check your server\u2019s DNS records.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo cat \/etc\/resolv.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The list should contain a minimum of 1 name server. All default DNS resolvers at UpCloud have the same IP addresses regardless of the availability zone. The DNS servers are provided automatically by the DHCP protocol, and there should be no need for manual configurations in the operating system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The UpCloud DNS resolver IPv4 addresses are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>94.237.127.9<\/strong><\/li>\n\n\n\n<li><strong>94.237.40.9<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If your server has a public IPv6 address, you can also use IPv6 with the following servers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>2a04:3540:53::1<\/strong><\/li>\n\n\n\n<li><strong>2a04:3544:53::1<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If the list is empty do not edit it manually, because if you have a nameserver manager installed any changes you make will just get reverted. Instead, you can try to update it on Ubuntu and some Debian systems with this command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo resolvconf -u<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On Debian servers, which do not have <tt>resolvconf<\/tt> installed, you can edit the <tt>resolv.conf<\/tt> file directly.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo nano \/etc\/resolv.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the lines shown below to the file, save and exit.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nameserver 94.237.127.9\nnameserver 94.237.40.9<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For those with <tt>resolvconf<\/tt> installed, in case resolv.conf is still empty after the update command, you can add nameservers to your interfaces file. Open it for editing.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo nano \/etc\/network\/interfaces<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add a name server to the end of the eth0 section.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">auto eth0\niface eth0 inet dhcp\ndns-nameservers 94.237.127.9<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Afterwards, save the file and exit. You will also need to restart the network service with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo service networking restart<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In CentOS and other Red Hat variants the <tt>resolv.conf<\/tt> file is populated a little differently, if the file is empty, you can add up to two DNS entries in your network configuration file for the network interface responsible for the public IP. For example, open <tt>ifcfg-eth0<\/tt> it with the next command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Edit the file to look like this.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">DEVICE=eth0\nBOOTPROTO=dhcp\nONBOOT=yes\nDNS1=94.237.127.9\nDNS2=94.237.40.9<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Exit the editor and restart the interface which the configuration file you just edited using <tt>ifdown<\/tt> and <tt>ifup<\/tt> commands.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test the connection both ways<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Try pinging your server over the internet. Open a terminal or command prompt on your own computer and try pinging your server\u2019s public IP, which you can find in the UpCloud control panel under the <a href=\"https:\/\/hub.upcloud.com\/networks\/public\/\" target=\"_blank\" rel=\"noreferrer noopener\">Network section<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">On your own computer: ping &lt;server public IP&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Test the internet connection by pinging another site from your server. For example, use the following command to ping Google\u2019s public DNS.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ping 8.8.8.8<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you have a second server deployed on your account and the problem is with the interface assigned with the private IP address, try to ping your other server to and from it using the private IPs listed in the UpCloud control panel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Should ping fail to receive a reply, try restarting your server\u2019s network services. In Debian and Ubuntu 12.04 or older, use the command below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo service networking restart<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On CentOS and other Red Hat-based systems, restart the network with the command underneath instead.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo service network restart<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In Ubuntu 14.04 and newer, you\u2019ll need to run the command for each network interface separately. For example, you can restart eth0 simply by following the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ifdown eth0 &amp;&amp; sudo ifup eth0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After restarting the network services, try running ping again both ways. Check your firewall settings if ping works in one direction but not in the other.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find out where the connection fails<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When basic troubleshooting doesn&#8217;t resolve the issue, test network routes using tools like <em><strong>mtr, traceroute, or tracepath<\/strong><\/em> to identify where connectivity fails. These commands provide visibility into each node the connection passes through, helping pinpoint any network routing failures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu servers have a networking tool called <tt>mtr<\/tt> for this purpose. Start it with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mtr 8.8.8.8<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To quit, just press <tt>q<\/tt> on your keyboard.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can use traceroute instead on Debian systems where mtr is usually not installed by default.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">traceroute -4 8.8.8.8<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On CentOS servers, use <tt>tracepath<\/tt> command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tracepath 8.8.8.8<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Different distributions run different tools and the output of these tools also differs slightly. The <tt>mtr<\/tt> runs in the foreground until cancelled, updating the response table on each pass, example output is shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">                                My traceroute  [v0.85]<br>example.com (0.0.0.0)                                   Wed Jul 29 16:03:43 2015<br>Keys:  Help   Display mode   Restart statistics   Order of fields   quit<br>                                             Packets               Pings<br> Host                                      Loss%   Snt   Last   Avg  Best  Wrst StDev<br> 1. 83.136.252.2                            0.0%     8    0.5   0.4   0.4   0.5   0.0<br> 2. te0-0-1-2.rcr11.lon10.atlas.cogentco.c  0.0%     8    0.8   0.8   0.7   1.1   0.0<br> 3. te0-7-0-13.ccr22.lon01.atlas.cogentco.  0.0%     8    1.2   1.2   1.1   1.3   0.0<br> 4. 149.14.8.150                            0.0%     8    1.3   2.7   1.1  13.0   4.1<br> 5. 216.239.47.25                           0.0%     7    1.9   1.8   1.8   1.9   0.0<br> 6. 216.239.47.59                           0.0%     7    1.8   1.9   1.8   2.0   0.0<br> 7. google-public-dns-a.google.com          0.0%     7    2.0   2.1   1.9   2.3   0.0<br><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><tt>Traceroute<\/tt> and <tt>tracepath<\/tt> are very similar to one another, they run pass over the network to the given destination and show the latency to each node that replied. The example of the traceroute shown underneath has much of the same information as <tt>mtr<\/tt>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets\n 1  83.136.252.2 (83.136.252.2)  0.494 ms  1.010 ms  1.006 ms\n 2  te0-0-1-2.rcr11.lon10.atlas.cogentco.com (149.11.22.93)  0.877 ms  1.415 ms  1.413 ms\n 3  te0-7-0-13.ccr22.lon01.atlas.cogentco.com (154.54.75.65)  1.107 ms  1.643 ms  1.648 ms\n 4  149.14.8.150 (149.14.8.150)  1.499 ms  1.495 ms  1.492 ms\n 5  216.239.47.25 (216.239.47.25)  2.096 ms 64.233.174.213 (64.233.174.213)  2.097 ms 216.239.47.23 (216.239.47.23)  2.090 ms\n 6  72.14.237.41 (72.14.237.41)  2.088 ms 216.239.47.59 (216.239.47.59)  1.717 ms 209.85.249.241 (209.85.249.241)  1.995 ms\n 7  google-public-dns-a.google.com (8.8.8.8)  1.733 ms  2.250 ms  1.721 ms\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Try the same from your own computer to the server using one of the tools mentioned above, for example, using the command below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">traceroute -4 &lt;server public IP&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If an outbound trace does not reach even the first node, check your network settings and firewall. The firewall may also be responsible for connection rejections if the trace over the internet to your server falls short just before reaching the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Firewall settings<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check that your connection is not getting blocked by a firewall. CentOS and some other Red Hat-based distributions have strict firewall rules by default. The following command will list all server-side firewall rules on your system.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo iptables -L<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Iptables is the Linux built-in software firewall, and the command above prints out the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Chain INPUT (policy ACCEPT)\ntarget     prot opt source               destination\nACCEPT     all  --  anywhere             anywhere             the  RELATED,ESTABLISHED\nACCEPT     tcp  --  anywhere             anywhere             The firewall dpt:http\nACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh\nDROP       all  --  anywhere             anywhere\n\nChain FORWARD (policy ACCEPT)\ntarget     prot opt source               destination\n\nChain OUTPUT (policy ACCEPT)\ntarget     prot opt source               destination<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is an example of a simple firewall table. It has rules to allow SSH and HTTP traffic, but block all other input, which also blocks ping attempts. Check your server\u2019s <tt>iptable<\/tt> for any is shown that might block your connection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Your&nbsp;<a href=\"https:\/\/hub.upcloud.com\/\" target=\"_blank\" rel=\"noopener\">UpCloud control panel<\/a> also provides an easily configurable firewall in your server settings under the Firewall tab.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/database-firewall-settings.png\" alt=\"Database firewall settings\" class=\"wp-image-5771\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The example image above has a few accepted incoming rules, but the default rule is set to reject. Make sure there are no rules blocking your desired connection.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Host status information<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the most up-to-date information on UpCloud infrastructure at <a title=\"UpCloud Status page\" rel=\"noopener\" href=\"https:\/\/status.upcloud.com\/\" target=\"_blank\">status.upcloud.com<\/a>, where you can also subscribe to updates by email, SMS, and Atom or RSS feeds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If everything seems to be in order, but the network connection still just doesn\u2019t work, or you are otherwise unable to troubleshoot the connection issues, don\u2019t hesitate to ask for help.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"author":3,"featured_media":27310,"comment_status":"open","ping_status":"closed","template":"","community-category":[259,289],"class_list":["post-2449","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2449"}],"version-history":[{"count":0,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2449\/revisions"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2449"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}