6

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

In the terminal, I'm trying to:

ping 8.8.8.8

to see my connectivity. It says:

Network is unreachable

Then I typed:

ifconfig: 
  inet addr: 192.168.56.101

Then:

sudo /sbin/route add -net 0.0.0.0 gw 192.168.56.101 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

1
11

try DHCP for the network interface

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

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

can you ping 8.8.4.4 (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 ?

7
  • yes i can ping 192.168.56.101. for 8.8.4.4 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
3

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 8.8.4.4

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

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 10.20.30.40 and the interface on which the package arrives is configured to be 10.20.30.1 netmask 255.255.255.0. This is, the packages destination subnet and the interfaces subnet are the same. Then your OS will forward the package to the broadcast 10.20.30.255 (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 10.20.40.40 and the interface on which the package arrives is configured to be 10.20.30.1 netmask 255.255.255.0. 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).

UPDATE:

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.

UPDATE2:

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

UPDATE3:

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"...

5
  • 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
0

(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 192.168.56.1 (if not, try 192.168.56.255) 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.

2
  • 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
0

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 8.8.8.8 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.

0

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

-2

I see you receive the Destination Host Unreachable message when you ping 8.8.8.8 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 8.8.8.8 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 8.8.8.8 again and check for the issue. Reference: https://www.corenetworkz.com/2009/05/destination-host-unreachable-reason-and.html

2
  • 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.