Create a file called /etc/resolv.conf
write fill in the contents:
nameserver
For example if your want to use googles dns-service:
nameserver 8.8.8.8
nameserver 8.8.4.4
This is likely caused by DHCP configuration when you first installed Ubuntu. Try this 3-step process to handle this auto configuration issue.
First
Edit your interface configuration, which is located in: /etc/network/interfaces
Add this line below iface lo inet loopback
:
dns-nameservers yourdns youraltdns
As an example for Google DNS, you may want to use this:
dns-nameservers 8.8.8.8 8.8.4.4
Second
Edit your DHCP configuration file, located at:
/etc/dhcp/dhclient.conf
Mark the syntax as a comment using #
on every line or simply remove every request name-server. In 16.04, you may not be required to make any changes here.
Third
Restart your networking by using this command :
/etc/init.d/networking restart
In 16.04:
sudo ifdown -a
sudo ifup -a