{"id":1546,"date":"2022-02-14T21:41:25","date_gmt":"2022-02-14T21:41:25","guid":{"rendered":"https:\/\/coding.moris.org\/?p=1546"},"modified":"2025-11-13T22:01:11","modified_gmt":"2025-11-13T22:01:11","slug":"how-to-preserve-custom-etc-resolv-conf-entries-with-dhcp-in-debian-linux","status":"publish","type":"post","link":"https:\/\/priscimon.net\/coding\/2022\/02\/14\/how-to-preserve-custom-etc-resolv-conf-entries-with-dhcp-in-debian-linux\/","title":{"rendered":"How to preserve custom \/etc\/resolv.conf entries with DHCP in Debian Linux"},"content":{"rendered":"\n<p>In Debian Linux, when a network interface is configured to obtain an IP address automatically, the DHCP client utility writes the values received from the server over the content of file <em>\/etc\/resolv.conf<\/em>. Thus, custom entries that were saved in this file, typically domain suffixes and domain name servers, are lost. If you need DHCP but also want to keep your configuration, do this:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Edit file <em>\/etc\/dhcp\/dhclient.conf<\/em>.<\/li>\n\n\n\n<li>Add the following lines, adjusting the values to match your needs.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:18px\"><code>supersede domain-name \"my-domain.com\";\nsupersede domain-search \"my-domain.com\";\nprepend domain-name-servers 9.9.9.9;<\/code><\/pre>\n\n\n\n<p>This example specifies <strong>my-domain.com<\/strong> as the domain suffix, overriding whatever value is sent by the DCHP server.  The value of the <code>domain-search<\/code> setting is appended to hostnames to form fully-qualified domain names. For example, if you try to connect to hostname <strong>foo<\/strong> (without a domain name), the DNS will be queried for the FQDN <strong>foo.my-domain.com<\/strong>.<\/p>\n\n\n\n<p>The example also sets the domain name server <strong>9.9.9.9<\/strong> to take priority over domain name servers provided by a DHCP server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Debian Linux, when a network interface is configured to obtain an IP address automatically, the DHCP client utility writes the values received from the server over the content of file \/etc\/resolv.conf. Thus, custom entries that were saved in this file, typically domain suffixes and domain name servers, are lost. If you need DHCP but [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1546","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3I4g9-oW","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/comments?post=1546"}],"version-history":[{"count":22,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1546\/revisions"}],"predecessor-version":[{"id":2025,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1546\/revisions\/2025"}],"wp:attachment":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/media?parent=1546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/categories?post=1546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/tags?post=1546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}