The way I do this is to set
supersede domain-name-servers in
/etc/dhcp/dhclient.conf. I've tried variety of options, including
tail files, under
/etc/resolvconf/resolv.conf.d/ folder, but only
dhclient.conf does the trick for me. I've done it in 13.04, 14.04, and 15.04 versions of Ubuntu – always works.
Basic idea is that when you connect to a wifi access point, you receive certain information from
dhcp server. The
supersede option tells Ubuntu to replace whatever
dhcp server sends you, with your own. In this case we supersede dns server. So no matter what wifi you connect to, your ubuntu will replace wifi-given dns with its own.
Bellow is the sample of my own
dhclient.conf file, notice the line
supersede domain-name-servers 126.96.36.199;:
$ cat /etc/dhcp/dhclient.conf
# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send host-name "andare.fugue.com";
send host-name = gethostname();
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
supersede domain-name-servers 188.8.131.52;
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
Now, if you'd like you can use
prepend option to use both wifi-given and your own server. In case wifi-given server fails, your request will be routed to the prepended dns.