nameserver settings

If none of the above work, keep it mind that Ubuntu appends a tail file to the resolv.conf file that it generates.

Try this:

sudo nano /etc/resolvconf/resolv.conf.d/tail

Which will open a blank resolv.conf.d file in the nano text editor. You will need to place your DNS server address on the first line of this file and remember to end the line with a carriage return (hit enter) as seen below:

nameserver 10.20.1.2

Editing the tail file instead of the actual resolv.conf file will prevent your change from being lost upon a system reboot.

You will need to run sudo resolvconf -u to activate the change. You should be able to ping google.com after this. Good luck!

https://askubuntu.com/questions/143819/how-do-i-configure-my-static-dns-in-interfaces


** I had to apt-get install resolvconf  in my test env

netplan - ubuntu

sudo nano /etc/netplan/01-netcfg.yaml  

dhcp

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: yes
     dhcp6: yes

To save your changes, you run the commands below.

sudo netplan apply

static

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
     dhcp4: no
     dhcp6: no
     addresses: [192.168.1.2/24]
     gateway4: 192.168.1.1
     nameservers:
       addresses: [8.8.8.8,8.8.4.4]
To save your changes, you run the commands below.

sudo netplan apply

To save your changes, you run the commands below.

sudo netplan apply

https://websiteforstudents.com/configuring-static-ips-ubuntu-17-10-servers/