Page 1 of 1

GNU/Linux: Set manual DNS, but use rest from DHCP

Posted: Fri Oct 30, 2015 7:47 pm
by peter_b
Here is how you configure a Debian/Ubuntu based DHCP client in a way that it receives all information from a DHCP server, but uses different DNS servers.
This can be useful in cases where multiple local DNS are used, but the DHCP server can't be configured to handle that properly (e.g. DHCP is router or Windows, etc).

1) Edit dhclient.conf:
  • Debian: /etc/dhclient.conf
  • Ubuntu: /etc/dhcp3/dhclient.conf
2) Add the following lines:

Code: Select all

supersede domain-name "mydomain.local";
prepend domain-name-servers 127.0.0.1;
Change "mydomain.local" to match your desired domain suffix.
And the domain-name-server IP to point to your desired DNS.

I've left localhost "127.0.0.1", because that's a very popular case for this.
:D

3) Restart the network interface:
For example for "eth0":

Code: Select all

$ ifdown eth0
$ ifup eth0
Links:
Configuring Static DNS with DHCP on Debian/Ubuntu (by Raam Dev)