Changes to /etc/resolv.conf discarded when connecting to a new network

Solution 1:

As per the header on /etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

Try putting your change in

/etc/resolvconf/resolv.conf.d/base and they should get added to /etc/resolv.conf when it gets re-written every 15 minutes.

Solution 2:

DISCLAIMER! Following this answer may cause unexpected problems if your DNS servers are managed as a part of network manager - while this will force the usage of the DNS servers you want above the dnsmasq system and the DNS servers in network manager's settings, it will do this for everything. As well, certain networks and/or connections may require you to use their DNS server(s) to get out to the internet with resolving things.

Edit /etc/resolvconf/resolv.conf.d/head and add the nameserver 1.2.3.4 record here.

This works on 14.04 even on a Desktop install. I know this because I have a locally running DNS server (via bind9) on my laptop locally for local zone resolution (since I do a lot of virtual machine stuff), and it becomes necessary to query my local DNS first above all else.