Page 1 of 2

Unable to ping default gateway and no internet connection

Posted: 5. Nov 2020, 23:16
by kkaito
Everything seems okay when first installed and after updates and upgrades. But once i reboot my computer, I was unable to ping my default gateway and could not surf the internet. This happened in my kali guest and parrot guest.I am using virtualbox 6.1.16, ubuntu host 20.04.01 LTS, kali guest 2020.4.

I am a newbie to virtualbox and linux so i don't no much what i need to provide. Please tell me what else its needed.
Also, I apologize to my poor English :(

Re: Unable to ping default gateway and no internet connection

Posted: 7. Nov 2020, 05:53
by scottgus1
For each guest, please right-click the guest in the main Virtualbox window's guest list, choose Show in Explorer/Finder/File Manager. Zip the guest's .vbox file, and post the zip file, using the forum's Upload Attachment tab.

Also, please run these commands in the terminal on the host OS and post the outputs:

ipconfig -or- ip address
vboxmanage list natnets
vboxmanage list dhcpservers


BTW your English sounds fine! :D

Re: Unable to ping default gateway and no internet connection

Posted: 7. Nov 2020, 11:44
by fth0
In the NAT networking mode, the gateway 10.0.2.1 never answers pings. Try 10.0.2.2, 10.0.2.3 or 10.0.2.4 instead, they will probably answer your pings.

Your real problem is the temporary name resolution failure, which doesn't happen in my Kali setup.

Edit:
Strikethrough above: In the NAT networking mode, 10.0.2.2 is the gateway, not 10.0.2.1.

Re: Unable to ping default gateway and no internet connection

Posted: 8. Nov 2020, 14:32
by kkaito
scottgus1 wrote:For each guest, please right-click the guest in the main Virtualbox window's guest list, choose Show in Explorer/Finder/File Manager. Zip the guest's .vbox file, and post the zip file, using the forum's Upload Attachment tab.

Also, please run these commands in the terminal on the host OS and post the outputs:

ipconfig -or- ip address
vboxmanage list natnets
vboxmanage list dhcpservers


BTW your English sounds fine! :D
I noticed that there are no nat networks in the list even I have already add one from the preferences in virtualbox. What are the possible reasons of it and how to solve it?

Re: Unable to ping default gateway and no internet connection

Posted: 8. Nov 2020, 14:40
by kkaito
fth0 wrote:In the NAT networking mode, the gateway 10.0.2.1 never answers pings. Try 10.0.2.2, 10.0.2.3 or 10.0.2.4 instead, they will probably answer your pings.

Your real problem is the temporary name resolution failure, which doesn't happen in my Kali setup.
i've set my default gateway to 10.0.2.1 so i should be able to ping it if it works. Does it mean that i need to change the ip addr of the default gateway in order to make it works? My dns server is also 10.0.2.1 as i checked in /etc/resolv.conf. What are the possible reasons to this name resolution failure? :?:

Re: Unable to ping default gateway and no internet connection

Posted: 8. Nov 2020, 17:38
by fth0
First of all, please ignore my previous answer, since I probably wasn't aware which networking mode you wanted to use.

In VirtualBox, there are two networking modes that can easily be confused: NAT and NAT Network. Both use IP addresses from the 10.0.2.x/24 range as default and the IP address 10.0.2.1 for the gateway. The NAT gateway does not answer pings (*), whereas the NAT Network gateway does. NAT uses 10.0.2.2 for the gateway, and NAT Network uses 10.0.2.1 for the gateway. Both usually provide the DNS server of the host to the guest, which is typically not in the 10.0.2.x/24 range.
kkaito wrote:My dns server is also 10.0.2.1 as i checked in /etc/resolv.conf. What are the possible reasons to this name resolution failure?
This could be an indication of the problem, since in my setups either the DNS server of the host (my Internet router's IP address) or a loopback IP address (e.g. 127.0.0.53) is written to /etc/resolv.conf.

If you want to use NAT Network, you'll have to configure it under VirtualBox > Preferences > Network.
If you want to use NAT, you'd have to modify your VM configuration.
If you want to use Host-only (guessed from seeing vboxnet0), @scottgus1 will probably give you a broader answer than me ...

(*) Answering pings (i.e. replying to ICMP echo requests with ICMP echo responses) is a purely voluntary behavior, and the VirtualBox NAT gateway simply doesn't do it. I'm with you that it should, though.

Edit:
Text in red is wrong and replaced with the blue text.

Re: Unable to ping default gateway and no internet connection

Posted: 9. Nov 2020, 18:48
by scottgus1
Could have sworn I posted on this, maybe I forgot to hit Submit... (Or maybe I put it on another topic and and somewhere an OP is going 'what the--") :lol:

You have both guests set to NAT network:
Parrot .vbox wrote: <Adapter slot="0" enabled="true" MACAddress="0800270B65DC" type="82540EM">
<DisabledModes>
<InternalNetwork name="intnet"/>
</DisabledModes>
<NATNetwork name="NatNetwork"/>
</Adapter>
</Network>
kali .vbox wrote: <Network>
<Adapter slot="0" enabled="true" MACAddress="08002756694F" type="82540EM">
<DisabledModes>
<InternalNetwork name="intnet"/>
</DisabledModes>
<NATNetwork name="NatNetwork"/>
</Adapter>
</Network>
However that empty 'vboxmanage list natnets' shows that something is very wrong.

Please go to the main Virtualbox window, File menu, Preferences, Network, and delete any and all NAT networks you see there. Make a new NAT network not called "NatNetwork", change the name. Also set the desired IP address and DHCP server ranges now, before you use the NAT network. Click OK to everything. Now set each guest's NAT network's "Name" dropdown to the new name you set. Try each guest to see if standard internet access and pings to each other work. You should also be able to ping the host's LAN's gateway and Google at 8.8.8.8

Re: Unable to ping default gateway and no internet connection

Posted: 10. Nov 2020, 01:05
by kkaito
I've tried to delete the old nat network and create a new one 10.0.15.0/24.
It turns out that i can see the natnetwork in vboxmanage list now but i still cannot ping my default gateway, my other subnet devices, and the internet.
Here are the vboxmanage list natnets and dhcpservers in host ubuntu:
ubuntu@vivobook:~$ vboxmanage list natnets
NetworkName: natnet
IP: 10.0.15.1
Network: 10.0.15.0/24
IPv6 Enabled: No
IPv6 Prefix: fd17:625c:f037:2::/64
DHCP Enabled: Yes
Enabled: Yes
loopback mappings (ipv4)
127.0.0.1=2

ubuntu@vivobook:~$ vboxmanage list dhcpservers
NetworkName: HostInterfaceNetworking-vboxnet0
Dhcpd IP: 192.168.56.100
LowerIPAddress: 192.168.56.101
UpperIPAddress: 192.168.56.254
NetworkMask: 255.255.255.0
Enabled: Yes
Global Configuration:
minLeaseTime: default
defaultLeaseTime: default
maxLeaseTime: default
Forced options: None
Suppressed opts.: None
1/legacy: 255.255.255.0
Groups: None
Individual Configs: None

NetworkName: NatNetwork
Dhcpd IP: 10.0.2.3
LowerIPAddress: 10.0.2.4
UpperIPAddress: 10.0.2.254
NetworkMask: 255.255.255.0
Enabled: Yes
Global Configuration:
minLeaseTime: default
defaultLeaseTime: default
maxLeaseTime: default
Forced options: None
Suppressed opts.: None
1/legacy: 255.255.255.0
3/legacy: 10.0.15.1
6/legacy: 10.0.15.1
Groups: None
Individual Configs: None

NetworkName: natnet
Dhcpd IP: 10.0.15.3
LowerIPAddress: 10.0.15.4
UpperIPAddress: 10.0.15.254
NetworkMask: 255.255.255.0
Enabled: Yes
Global Configuration:
minLeaseTime: default
defaultLeaseTime: default
maxLeaseTime: default
Forced options: None
Suppressed opts.: None
1/legacy: 255.255.255.0
3/legacy: 10.0.15.1
6/legacy: 10.0.15.1
Groups: None
Individual Configs: None
ubuntu@vivobook:~$
And here are the results in kali guest:
root@kali:/home/kali# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.15.6 netmask 255.255.255.0 broadcast 10.0.15.255
inet6 fe80::72b4:b0ff:fe61:f7b7 prefixlen 64 scopeid 0x20<link>
ether 70:b4:b0:61:f7:b7 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 590 (590.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23 bytes 1862 (1.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 18 bytes 1162 (1.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18 bytes 1162 (1.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@kali:/home/kali# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.15.1 0.0.0.0 UG 100 0 0 eth0
10.0.15.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
root@kali:/home/kali# ping 10.0.15.1
PING 10.0.15.1 (10.0.15.1) 56(84) bytes of data.
From 10.0.15.6 icmp_seq=1 Destination Host Unreachable
From 10.0.15.6 icmp_seq=2 Destination Host Unreachable
From 10.0.15.6 icmp_seq=3 Destination Host Unreachable
^C
--- 10.0.15.1 ping statistics ---
4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3173ms
pipe 4
root@kali:/home/kali# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 10.0.15.6 icmp_seq=1 Destination Host Unreachable
From 10.0.15.6 icmp_seq=2 Destination Host Unreachable
From 10.0.15.6 icmp_seq=3 Destination Host Unreachable
From 10.0.15.6 icmp_seq=4 Destination Host Unreachable
From 10.0.15.6 icmp_seq=5 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 0 received, +5 errors, 100% packet loss, time 5885ms
pipe 5
root@kali:/home/kali#

Re: Unable to ping default gateway and no internet connection

Posted: 10. Nov 2020, 13:34
by fth0
The only peculiar thing that I see, is that the NatNetwork still exists (and that the DHCP server delivers the gateway and DNS server address of natnet). Remove the NatNetwork or both NAT Networks, reboot the host and see if they still exist.

Re: Unable to ping default gateway and no internet connection

Posted: 10. Nov 2020, 18:16
by scottgus1
fth0, I'm not certain the NAT network named "NatNetwork" exists. It doesn't show in 'vboxmanage list natnets'. It does show in 'list dhcpservers', which is normal: if a NAT netowrk that used DHCP is deleted, the DHCP server stays behind.

That "NatNetwork" did not show in the earlier 'list natnets' or 'list dhcpservers' but now shows in the new 'list dhcpservers' but not in the new 'list natnets' is a little unusual but might happen considering all the OKs and "oops I didn't mean to do that" incidents that can happen in networking. :lol:

I think the NAT network "NATnetwork" is gone, and a new NAT network "natnet" with an IP range 10.0.15.0/24 is active. The Kali 'ifconfig' shows "inet 10.0.15.6", which fits the IP range of the "natnet".

On an XP guest on my Windows host, I can ping the NAT network gateway and Google. Why ping is not working for kkaito is a puzzle.

kkaito, please try setting the guest to plain NAT, start it up and see what happens. The guest should get 10.0.2.15 IP address with both gateway and DHCP server on 10.0.2.2. See if you can ping 10.0.2.2 and 8.8.8.8.

Re: Unable to ping default gateway and no internet connection

Posted: 10. Nov 2020, 23:16
by fth0
scottgus1 wrote:fth0, I'm not certain the NAT network named "NatNetwork" exists. It doesn't show in 'vboxmanage list natnets'. It does show in 'list dhcpservers', which is normal: if a NAT netowrk that used DHCP is deleted, the DHCP server stays behind.
You're right, and I'm mistaken. Once in a while you can catch me, so don't just believe me. ;)

Re: Unable to ping default gateway and no internet connection

Posted: 10. Nov 2020, 23:43
by fth0
scottgus1 wrote:Why ping is not working for kkaito is a puzzle.
Yes, agreed for the ping to 10.0.15.1.

Regarding the ping to 8.8.8.8, the host network configuration plays a role, which has a wireless interface wlp1s0, a Linux tun interface tun0, and the Virtualbox Host-Only interface vboxnet0 (and the loopback interface lo). What's the output of route -n on the host?

Re: Unable to ping default gateway and no internet connection

Posted: 11. Nov 2020, 02:41
by kkaito
scottgus1 wrote:fth0, I'm not certain the NAT network named "NatNetwork" exists. It doesn't show in 'vboxmanage list natnets'. It does show in 'list dhcpservers', which is normal: if a NAT netowrk that used DHCP is deleted, the DHCP server stays behind.

That "NatNetwork" did not show in the earlier 'list natnets' or 'list dhcpservers' but now shows in the new 'list dhcpservers' but not in the new 'list natnets' is a little unusual but might happen considering all the OKs and "oops I didn't mean to do that" incidents that can happen in networking. :lol:

I think the NAT network "NATnetwork" is gone, and a new NAT network "natnet" with an IP range 10.0.15.0/24 is active. The Kali 'ifconfig' shows "inet 10.0.15.6", which fits the IP range of the "natnet".

On an XP guest on my Windows host, I can ping the NAT network gateway and Google. Why ping is not working for kkaito is a puzzle.

kkaito, please try setting the guest to plain NAT, start it up and see what happens. The guest should get 10.0.2.15 IP address with both gateway and DHCP server on 10.0.2.2. See if you can ping 10.0.2.2 and 8.8.8.8.
I'm able to ping using NAT. It seems like to be a NAT Network problem. But i want to use the NAT network as i need to communicate my other virtualbox guests.
Pretty frustrated about it.
kali@kali:~$ sudo su root
[sudo] password for kali:
root@kali:/home/kali# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::1a67:47ff:fe19:b4f3 prefixlen 64 scopeid 0x20<link>
ether 18:67:47:19:b4:f3 txqueuelen 1000 (Ethernet)
RX packets 6 bytes 1960 (1.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 1998 (1.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 12 bytes 556 (556.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 556 (556.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@kali:/home/kali# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
root@kali:/home/kali# ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=0.440 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.430 ms
64 bytes from 10.0.2.2: icmp_seq=3 ttl=64 time=0.435 ms
^C
--- 10.0.2.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2099ms
rtt min/avg/max/mdev = 0.430/0.435/0.440/0.004 ms
root@kali:/home/kali# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=63 time=434 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=63 time=495 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=63 time=502 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 3 received, 25% packet loss, time 3291ms
rtt min/avg/max/mdev = 434.189/476.891/501.534/30.314 ms
root@kali:/home/kali#

Re: Unable to ping default gateway and no internet connection

Posted: 11. Nov 2020, 02:44
by kkaito
fth0 wrote:
scottgus1 wrote:Why ping is not working for kkaito is a puzzle.
Yes, agreed for the ping to 10.0.15.1.

Regarding the ping to 8.8.8.8, the host network configuration plays a role, which has a wireless interface wlp1s0, a Linux tun interface tun0, and the Virtualbox Host-Only interface vboxnet0 (and the loopback interface lo). What's the output of route -n on the host?
For your information, the route on my ubuntu host looks like this. I don't think it's a host problem as i can surf the internet and ping other subnet devices on it.
ubuntu@vivobook:~$ sudo su root
[sudo] password for ubuntu:
root@vivobook:/home/ubuntu# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 983 bytes 91106 (91.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 983 bytes 91106 (91.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.8.8.4 netmask 255.255.255.0 destination 10.8.8.4
inet6 fe80::1eb:3cb5:7f94:6b96 prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
RX packets 4151 bytes 3138727 (3.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3851 bytes 446891 (446.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vmnet1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.65.1 netmask 255.255.255.0 broadcast 172.16.65.255
inet6 fe80::250:56ff:fec0:1 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:c0:00:01 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 72 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vmnet8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.45.1 netmask 255.255.255.0 broadcast 172.16.45.255
inet6 fe80::250:56ff:fec0:8 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:c0:00:08 txqueuelen 1000 (Ethernet)
RX packets 12 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 72 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::b334:b20d:3da1:65c1 prefixlen 64 scopeid 0x20<link>
ether 10:03:26:2c:e6:6f txqueuelen 1000 (Ethernet)
RX packets 5067 bytes 4085422 (4.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4447 bytes 870033 (870.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@vivobook:/home/ubuntu# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.8.8.1 0.0.0.0 UG 50 0 0 tun0
0.0.0.0 192.168.1.1 0.0.0.0 UG 600 0 0 wlp1s0
10.8.8.0 0.0.0.0 255.255.255.0 U 50 0 0 tun0
45.9.249.245 192.168.1.1 255.255.255.255 UGH 600 0 0 wlp1s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlp1s0
172.16.45.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
172.16.65.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp1s0
192.168.1.1 0.0.0.0 255.255.255.255 UH 600 0 0 wlp1s0
root@vivobook:/home/ubuntu#

Re: Unable to ping default gateway and no internet connection

Posted: 11. Nov 2020, 19:09
by fth0
I've just noticed something that was hiding in your information from the beginning: ;)

The Kali Linux guest reports a different MAC address for eth0 each time (mine doesn't, BTW). Since your .vbox files showed that you've configured MAC addresses with the "VirtualBox" OUI (08:00:27), I'd guess that Kali Linux uses randomized MAC addresses for privacy reasons. Try to prevent this and see if your problem persists.