CentOS Virtualbox no internet access

2

I have the following problem:

I have a VM with CentOS installed. From this machine, I can't connect to internet, so I can't upgrade nothing installed on it.

The VM configuration is:

Under Settings -> Network

  • Adapter 1
    • NAT
  • Adapter 2
    • Host-only Adapter
    • Name: vboxnet0
    • Promiscuous Mode: Deny
    • Calbe Connected: true

Under File->Preferences->Network, in Host-only Networks, vbonenet0:

  • IPv4 Address: 192.168.101.1
  • Ipv4 Newroks Mask: 255.255.255.0
  • IPv6 Address: fe80:0000:0000:0000:0800:27ff:fe00:0000
  • IPv6 Prefix Length: 64

When I'm on the machine:

ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:55:45:B3  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe55:45b3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1699 (1.6 KiB)  TX bytes:1414 (1.3 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:D7:3D:E9  
          inet addr:192.168.101.129  Bcast:192.168.101.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed7:3de9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:477 errors:0 dropped:0 overruns:0 frame:0
          TX packets:452 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:89736 (87.6 KiB)  TX bytes:183141 (178.8 KiB)

ping 192.168.101.129
PING 192.168.101.129 (192.168.101.129) 56(84) bytes of data.
64 bytes from 192.168.101.129: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.101.129: icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from 192.168.101.129: icmp_seq=3 ttl=64 time=0.031 ms
64 bytes from 192.168.101.129: icmp_seq=4 ttl=64 time=0.048 ms
64 bytes from 192.168.101.129: icmp_seq=5 ttl=64 time=0.062 ms


ping www.google.com
PING www.google.com (216.58.205.164) 56(84) bytes of data.
From 192.168.101.129 icmp_seq=2 Destination Host Unreachable
From 192.168.101.129 icmp_seq=3 Destination Host Unreachable
From 192.168.101.129 icmp_seq=4 Destination Host Unreachable

Under /etc/sysconfig/network-scripts/, the ifcfg-eh0 file:

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=DHCP
DNS1=8.8.8.8
DNS2=8.8.4.4

the ifcfg-eh1 file:

DEVICE=eth1
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.101.129
NETMASK=255.255.255.0
NETWORK=192.168.101.0
BROADCAST=192.168.101.255
NM_CONTROLLED=no
DNS1=8.8.8.8
DNS2=8.8.4.4

route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.101.0   *               255.255.255.0   U     0      0        0 eth0
10.0.3.0        *               255.255.255.0   U     0      0        0 eth1
192.168.56.0    *               255.255.255.0   U     0      0        0 eth0
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
default         192.168.101.2   0.0.0.0         UG    0      0        0 eth0

Can someone help me? Thanks for the support.

UPDATE

The default gateway is:

ip r | grep default
default via 192.168.101.2 dev eth1 

Bruno Pistone

Posted 2018-06-11T12:26:34.707

Reputation: 21

1Add the IP address of the default gateway to the GATEWAY=<IPAddress> value of the ifcfg-eth0 file and then see if that resolves. You can restart network service with systemctl restart network afterwards to test. – Pimp Juice IT – 2018-06-11T12:30:11.220

@PimpJuiceIT thanks for the answer. I've added GATEWAY=10.0.2.15 and now ping www.google.com says ping: unknown host www.google.com – Bruno Pistone – 2018-06-11T12:45:54.257

Odd, I'm not by my CentOS VM to check and I use Hyper-V for the one VM CentOS 7 machine that's virtualized in my case anyway. I typically use nmtui when I can for network configuration of CentOS machines so see if available in your case in case you see anything that looks obvious but the missing DG looked obvious to me but I'm not a Linux expert either but it's likely a VM network setting causing this I think at least. – Pimp Juice IT – 2018-06-11T12:51:20.620

Ping a IP number, not dns a name. That error means DNS is not working properly. (It's not resolving) check your DNS settings. Ping 8.8.8.8 see what happens. If that works try setting the DNS pointing to your local router – Tim_Stewart – 2018-06-11T13:22:35.787

@Tim_Stewart ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. From 192.168.101.129 icmp_seq=2 Destination Host Unreachable – Bruno Pistone – 2018-06-11T13:30:41.620

1Try adding the route table to your question so run route command and show that output in your question. I wonder if you even need the adapter 2 setup in VirtualBox for the network settings and just having adapter 1 setup with NAT alone would do it? I'd have to test with VirtualBox but perhaps this is something simple you could test with quickly just in case. – Pimp Juice IT – 2018-06-11T14:04:14.963

@PimpJuiceIT I've just added the route command result. thanks – Bruno Pistone – 2018-06-11T14:49:29.280

Answers

0

Make sure that the MAC Address from your VirtualBox Network Adapters it is been equal to the hardware Address (HWADDR) declared in your files ifcfg-eh0 and ifcfg-eh1. Until I fixed that I was able to make work my network.

Fidel Orozco

Posted 2018-06-11T12:26:34.707

Reputation: 181