Linux Make Sure /etc/resolv.conf Never Get Updated By DHCP Client

www.la‮ruttu‬i.com
Linux Make Sure /etc/resolv.conf Never Get Updated By DHCP Client

There are a few ways you can prevent the /etc/resolv.conf file from being updated by a DHCP client:

  1. Use a static IP address instead of a dynamic one: If you configure your network interface to use a static IP address, the DHCP client will not be invoked and the /etc/resolv.conf file will not be updated. To set a static IP address, you can edit the configuration file for your network interface, such as /etc/network/interfaces or /etc/sysconfig/network-scripts/ifcfg-eth0.

  2. Configure the DHCP client to not update the /etc/resolv.conf file: Depending on the DHCP client you are using, you may be able to configure it to not update the /etc/resolv.conf file. For example, if you are using the dhclient DHCP client, you can use the resolv-file option in the /etc/dhcp/dhclient.conf file to specify a different file for the DHCP client to update instead of /etc/resolv.conf.

  3. Use a separate DHCP client: Instead of using the default DHCP client that comes with your Linux distribution, you can use a different DHCP client that does not update the /etc/resolv.conf file. For example, you could use the dhcpcd DHCP client, which allows you to specify a configuration file in which you can disable the updating of the /etc/resolv.conf file.

  4. Manually update the /etc/resolv.conf file: Instead of relying on the DHCP client to update the /etc/resolv.conf file, you can manually edit the file to specify your desired DNS servers. Just make sure to set the permissions on the file to prevent it from being overwritten by the DHCP client or any other process.

Created Time:2017-10-30 10:17:36  Author:lautturi