First make sure you have your network adapter enabled in virtual box settings.
Your network interface which you use it for connecting to internet might not be active.
-
To check this,use "sudo nmcli d" command.
-
If it is disconnected,use "sudo nmtui"->Edit a connection,select your network interface and choose "Automatically connect" option(by pressing Space key) and select OK.
-
Do "sudo reboot now" After logging in,do "ping www.google.com".
You should be able to connect now.