Override dhclient and use manual DNS entries

Be it the home computer, the friend’s wi-fi or the personal VPS, in some instances using the ISP’s DNS service is not desirable. Maybe for speed or maybe for privacy concerns a trusted DNS provider is preferred instead.

While the DNS settings can be manually changed after each (re)connection, applying a permanent solution requires a bit of file fiddling.

Method 1

Create /etc/dhclient-enter-hooks with the following contents:
#!/bin/sh
make_resolv_conf() {
echo "doing nothing to resolv.conf"
}

Change its permissions to make it executable:
chmod a+x /etc/dhclient-enter-hooks

See man dhclient-script for more info.

Method 2

Edit etc/sysconfig/network-scripts/ifcfg-eth0 (or whichever your network interface file is) and add
PEERDNS=no
Alternatively, adding
DNS1=10.0.0.1
DNS2=10.0.0.254

also works.

Remember to use the DNS server IP addresses appropriate for your network.

Leave a Reply