-
-
Notifications
You must be signed in to change notification settings - Fork 6
DNS Configuration with resolv.conf
By default, /etc/resolv.conf is updated when DHCP is enabled for an interface. This is useful for WiFi or laptops where you frequently change networks. However, it can be problematic sometimes when different DNS servers are required.
For static IP addresses, this is not modified automatically.
Methods to try:
- Use a static IP address
- Make /etc/resolv.conf immutable
- Override the dhclient configuration
- Turn off resolvconf
Simply edit your /etc/rc.conf and replace DHCP in your ifconfig line with a static IP configuration
chflags schg /etc/resolv.conf
place the following in /etc/dhclient.conf, but change the name of the interface as appropriate. This example uses OpenDNS with an Intel Gigabit NIC.
interface "em0" {
`supersede domain-name-servers 208.67.222.222,208.67.220.220;`
}
You will need to restart the dhclient for changes to take effect.
service dhclient restart em0
Create a file
/etc/resolvconf.conf
Place this in the file
resolv_conf="/dev/null"
Alternatively, disable in /etc/rc.conf resolvconf="NO"