First of all, please clean up your configuration. Is your eth0
interface supposed to be configured with a static IP address or with DHCP? If static, why are you running dhclient
? If DHCP, why does /etc/network/interfaces
list static IP parameters and iface eth0 inet static
instead of iface eth0 inet dhcp
? Also, there is no reason you would need to add a default route via your up route
command since you already specified the default route as the gateway
parameter.
Now keep in mind that as per the name, prepend domain-name-servers
adds DNS servers to the list that is supplied by the DHCP server. It doesn't replace them.
I recommend that, instead of asking dhclient
to customize the name servers you want to use, use the resolvconf
framework instead. resolvconf
coordinates all of the different possible sources of DNS nameserver information (including separate DHCP clients running on one or more network interfaces, local DNS servers you want to use as resolvers, and static configuration) and centralized the building of a single coherent /etc/resolv.conf
file. It's much better than letting several different things manage /etc/resolv.conf
and have them stomp over each other trying to do it.
Install the resolvconf
package if it isn't already installed. This will automatically disable dhclinent
's direct mucking with the /etc/resolv.conf
file.
Now your requirement is that you don't want to use the nameserver(s) provided by the DHCP server, so comment the line that reads eth*
in /etc/resolvconf/interface-order
. Be sure to also comment the last line of the file that reads *
, otherwise eth0
will still be considered.
Next, you want to use a set of statically provisioned nameservers instead. Since they're system-global (not related to the state if any given interface), you can add them as nameservers on the lo interface in /etc/network/interfaces
:
iface lo inet loopback
dns-nameservers x.x.x.x y.y.y.y z.z.z.z
And then ifdown lo; ifup lo
to activate this.