I am using Linux oess (CentOS). I am working on a VM: enter image description here

In the terminal, I'm trying to:


to see my connectivity. It says:

Network is unreachable

Then I typed:

  inet addr:


sudo /sbin/route add -net gw eth0

Now I'm doing the same ping and it says:

Destination host is unreachable

for all the sequences.

What is the source of the problem?

route output: enter image description here


try DHCP for the network interface

sudo /etc/init.d/networking restart && sudo dhclient
  • You're a life saver. In my case it's network-manager and not networking. Oct 29 '20 at 9:15

first things first. can you ping ? if so then you have an IP connection to the router, set this as your default route. otherwise try pinging (broadcast) to see on what address you might get replies. see arp -a to check what addresses you can find.

can you ping (google) after changing the default route? if so you have internet access. if not check the router.

can you ping www.google.com? if not you might have a dns problem

do you get results from nslookup www.google.com ?

  • yes i can ping for i can not reach the destination host. so the problem is internet access. Regarding my router, i still believe it's not a router problems since i usually use diffrent routers. and it did not work in any of them
    – zeev1079
    Sep 4 '15 at 20:47
  • yes its not a router problem..it the config of your eth0 network settings.
    – Ray BSD
    Sep 4 '15 at 20:48
  • Yea, i knew it. but how do solve this issue. im truly do not know my direction
    – zeev1079
    Sep 4 '15 at 20:49
  • try #dhclient -r eth0 Or $sudo dhclient -r eth0 This will try to get a automatic ip address from your router.
    – Ray BSD
    Sep 4 '15 at 20:50
  • I did not get any adress, please expand your answer
    – zeev1079
    Sep 4 '15 at 20:52

check the network card of the VM in the virtualization software. is it in "bridged" mode? or in a "NAT" or "host-only" mode?

in the last case change it to bridged and try $sudo dhclient

in the first case, see if the hypervisor itself can ping to its default gw and

  • no i can not ping my ip and not
    – zeev1079
    Sep 4 '15 at 21:44

There are two cases what a computer can do, when it has to forward an IP package:

  • First case: Say the destination IP of the incoming package is and the interface on which the package arrives is configured to be netmask This is, the packages destination subnet and the interfaces subnet are the same. Then your OS will forward the package to the broadcast (it says "Here is a package that is addressed for someone in my own hood, so please take it!").

  • Second case: Say the destination IP of the incoming package is and the interface on which the package arrives is configured to be netmask Then the
    destination address lies outside of the interfaces subnet. So it does not know where to send it. So it forwards it to the default gateway
    which in turn tries to find the destination.

In your case the default gateway is exactly the same as your interface IP. That means: When your computer does not know where to send a package it sends it to itself respectively to one of its own interfaces. That sounds strange - and it is. An interface gateway should be in the same subnet as the interface itself, but it should never BE itself. You need another default gateway in the same subnet to be happy.

If you don't know your default gateway for this interface, so try to get a valid default gateway for this interface via DHCP configuration (configure this interface to be a DHCP client).


In the case you are working in a VM (I see it is Virtual Box) try to find out the IP address of the "Virtual Box Host Only Adapter" on your host machine (command: ifconfig or ipconfig). Then configure the IP address of the VM host only adapter to be the default gateway of your VM guest.


On your host machine your should activate ipv4-forwarding and NAT to get internet access:

echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
iptables -t nat -A POSTROUTING -o <interface on which you have the i-net access> -j MASQUERADE


If your want to use the "Host Only Adapter" then it may be possible, that you first have to create an "Host Only Network" under File->Preferences choosing the tab "Host Only Networks"...

  • Im working on a VM, it's maybe the reason why i m little confused with your answers.
    – zeev1079
    Sep 4 '15 at 21:12
  • I allready did what you said, but it's stil does not work properly, i changed it to bridge adapter
    – zeev1079
    Sep 4 '15 at 21:40
  • in your network settings inside virtual box: what is when you switch your "Intel PRO/1000 MT Desktop" adapter type to "Intel PRO/1000 T Server" ??? Sep 4 '15 at 21:45
  • i can not touch it, im so lost with this issue, i think it's a lost case. the reason i doing ping is because i can not do wget to downlad some webpage
    – zeev1079
    Sep 4 '15 at 21:47
  • what is the interface you getting internet to? Inside Vbox switch to bridge mode and use exactly the interface you getting internet connection to. Then switch the adapter type to "Intel PRO/1000 T Server" - it MUST work as far as your LAN provides an dhcp service. Can your post your /etc/network/interfaces file on the guest? Sep 4 '15 at 21:53

(I cannot comment yet, hence a reply)

A router is a box that is separate from your computer. Where does the network cable from your computer go to? That might be your router. Can you post the name and identification numbers of that box? It might help us in assisting you.

My guess is that your router has the address (if not, try but that need not be true. See if you can ping it, and if you can open your router's configuration page if you go to that IP address in a web browser.

If so, set that IP address as your gateway. The command you posted seems correct.

  • Im working on a VM, it's maybe the reason why i was little confused with your answers
    – zeev1079
    Sep 4 '15 at 21:11
  • This is Q&A site, not a forum, please be so polite to read the help→tour and to apply the part about not including chit-chat in your posts
    – Anthon
    Sep 4 '15 at 23:10

Your Virtual Box network adapter is set to "Host-only".

Host-only networking allows your guest to access your host and your guest to access other guests. However, it does not allow network traffic to pass between the guest to the real physical network beyond the host, including the internet.

You are unable to ping because that machine is neither your host nor one of your virtual machines. Change your Virtual Box network type to "NAT" or "Bridged" if you require access to the outside world.


Check your hw_address and add it to your DNS IP address:

$ arp -n 
$ arp -s <ip_address> <hw_address>

NOTE: hw_address is your MAC address


I see you receive the Destination Host Unreachable message when you ping from your machine. It tells that the ping packets from your computer failed to find a route to the destination host.

Reasons to getting Destination Host Unreachable Error

There are a number of reasons to get this message on your machine. They are:

  1. Wrong default gateway configuration

  2. High intense firewall settings on your machine or at the remote host

  3. Loose connection

Now let us check how to fix it.

The Solution

  1. Disable the Firewall

Disable the firewall and ping from your machine. If you receive successful ICMP replies, you need to check the firewall settings.

  1. Power Cycle

Disconnect the power cables and Ethernet cables from the modem, router, and PC. Clean the cables, and reconnect them. Power on the devices after two minutes.

Now ping again and check for the issue. Reference: https://www.corenetworkz.com/2009/05/destination-host-unreachable-reason-and.html

  • 1
    Welcome to Unix and Linux Stack. As a new user here, I would recommend closely reading the question (and existing answers) here before posting. Since the question does specify that this is a virtual machine, your answer regarding cables just doesn't make any sense in that context. Jul 13 at 14:49
  • Additionally, if you are the Alex that wrote the article at that site, posted June 11, 2021, please disclose your affiliation so that you're not seen as a spammer.
    – Jeff Schaller
    Jul 13 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.