0

I have configured the Ubuntu server (guest) with NAT adapter and configured it in /etc/network/interfaces like below:

auto enp0s3
iface enp0s3 inet dhcp

But doesn't connect to internet:

ping www.google.com
ping: unknown host www.google.com

The host machine is a Windows7 with the firewall disabled. How can I solve this problem?

  • Might I ask why you need a static IP in the NAT configuration of VirtualBox to the server? You might need to check this for Net DNS Proxy to work: https://forums.virtualbox.org/viewtopic.php?f=1&t=49066 – Terrance Mar 07 '18 at 17:44
  • I have changed to dhcp, but I don't know what I'm doing. I'm good at programming not in networks – Albert Lazaro de Lara Mar 07 '18 at 17:53
  • If I do ping -c5 66.102.9.147 (IP from google) it works. I have problems with DNS. Because I can't do an apt-get update. I have been following this https://askubuntu.com/questions/91543/apt-get-update-fails-to-fetch-files-temporary-failure-resolving-error – Albert Lazaro de Lara Mar 07 '18 at 17:56
  • Within a VM it is different as it is going through the Network Address Translation (NAT) controller. It generates its own DHCP. Don't put anything in the /etc/resolv.conf file. Remove the lines from /etc/network/interfaces that deals with the enp0s3. Reboot the VM and let it use the DNS from the host OS. Are you looking to access your server from outside the VM / Host computer? – Terrance Mar 07 '18 at 18:19

2 Answers2

2

You may need to include your DNS entries, manually. Try adding this line to your configuration. Note that these DNS servers are Google's, and will not be able to provide DNS for your local LAN, but will provide DNS for accessing sites on the Internet..

dns-nameservers 8.8.8.8 8.8.4.4

Reference: https://www.swiftstack.com/docs/install/configure_networking.html

DaneM
  • 376
0

I found a solution on internet. The idea is to execute next instruction:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolvconf/resolv.conf.d/base > /dev/null

This replaces the nameserver (DNS) used on the machine by the Google Public DNS service.