title: “Static DNS with DHCP (Ubuntu & Centos)”
date: 2016-01-14T09:18:40
slug: static-dns-with-dhcp-ubuntu-centos
Ubuntu:
vi /etc/dhcp/dhclient.conf
Remove the DNS and Serarch opteion (if needed)
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, host-name,
dhcp6.name-servers, dhcp6.domain-search,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers,
dhcp6.fqdn, dhcp6.sntp-servers;
Add the Static DNS and Search Values:
vi /etc/network/interfaces.d/eth0.cfg
# The primary network interface
auto eth0
iface eth0 inet dhcp
dns-nameservers 172.31.8.224
dns-search nyc2.example.com
Centos
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Change PEERDNS=”yes” to PEERDNS=”no”
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="yes"
PEERDNS="no"
IPV6INIT="no"
PERSISTENT\_DHCLIENT="1"
Set the required Values in /etc/resolv.conf
vi /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
nameserver 172.31.8.224
search nyc2.example.com