Unable to access the internet from my VirtualBox CentOS VM via wireless connection
Your routing table is incomplete.
Your computer only knows how to route to IPs that start with 192.168
and 169.254
but does not know how to route to any other IPs, we'll want any other IPs to be routed through your router.
If your router would be 192.168.1.1
, you can for example execute:
route add default gw 192.168.1.1
This would cause the table to look like this:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
For more information on how this works, execute man route
.
Related videos on Youtube
crmpicco
Updated on September 18, 2022Comments
-
crmpicco over 1 year
I have a VirtualBox CentOS VM setup on my Windows 7 machine. I can ping my router, however I am unable to access the outside world.
In Windows I have three network connections setup:
- Wireless Network Connection (my WWW connection)
- VirtualBox Host-Only Network (my VM)
- Local Area Connection (unused)
I have my VM setup to use a bridged adapter to connect through the "Dell Wireless adapter".
Is there any reason why I should be unable to access the outside world from the VM?
I am trying to ping Google with:
ping 8.8.8.8
and getting connect: network is unreachable
This is a dump from ifconfig:
eth0 Link encap:Ethernet HWaddr 08:00:27:F2:EF:F7 inet addr:192.168.0.25 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3310 errors:0 dropped:0 overruns:0 frame:0 TX packets:337 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:292875 (286.0 KiB) TX bytes:40593 (39.6 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:249 errors:0 dropped:0 overruns:0 frame:0 TX packets:249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:20076 (19.6 KiB) TX bytes:20076 (19.6 KiB)
Here is a dump from route -n:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
-
Tamara Wijsman about 12 yearsCan you visit your router page from the VM?
-
crmpicco about 12 yearsThere's no GUI installed, however if do a wget on the URL then i get a 401 unauthorized (as expected). I can ping the router successfully. Where do you think the issue is? With my router?
-
Tamara Wijsman about 12 yearsNot necessarily your router. Can you check whether the gateway is probably set on the VM guest, with
ipconfig
orifconfig
depending on operating system. Because I guess it can reach the first hop but doesn't know where to sent packets to that have to travel more than a single hop (that thus are not in the network segment). -
crmpicco about 12 yearsI've just updated the main question with a dump from ifconfig on my VM. Does that look like it is configured correctly? How can I tell if the gateway is correctly configured?
-
Tamara Wijsman about 12 yearsOh right, that's different on Linux. You can see the routing information with
route -n
, this would also show the gateway if it's configured properly. -
crmpicco about 12 yearsThe gateway is showing as 0.0.0.0 as you can see from the dump in the original question. Does this indicate there is an issue with the gateway?
-
Tamara Wijsman about 12 yearsPosted an answer. :)
-
crmpicco about 12 yearsOK, I have added my router's IP address (192.168.0.1) to the routing table and I can ping Google on the 8.8.8.8 IP. However, for some reason, I still cannot wget or access any domain (which is a big issue)? Does this mean it is a DNS problem?
-
Tamara Wijsman about 12 yearsYes, it sound to me that you haven't followed any guide to set your internet up. Configure your DNS.
-
crmpicco about 12 yearsThanks, DNS was infact the problem. I added 8.8.8.8 and 8.8.4.4 as primary and secondary DNS servers respectively using the "setup" command in CentOS. This adds the records to your /etc/resolv.conf file. Thanks for your help!