Change DNS Server given during Ubuntu 18.04 installation

Edit your netplan configuration file and remove the old dns server names and add new ones. Edit the file with sudo nano /etc/netplan/01-netcfg.yaml and yours should be similar to the example below:

network:
    version:2 
    renderer: networkd
    ethernets:
         enp0s3:
             dhcp4: true
             nameservers:
                  search: [mydomain, otherdomain]
                  addresses: [10.10.10.1, 1.1.1.1]

The line of interest is the one that says addresses under the settings nameserver. It might also be written like so:

nameservers:
     search: 
         - mydomain
         - otherdomain
     addresses:
         - "10.10.10.1"
         - "1.1.1.1"

Change the address there to the one you desire. Make sure to observe the indentations as ther are. Now after thatv save the file and aplly the changes:

sudo netplan --debug apply