[{"data":1,"prerenderedAt":37},["ShallowReactive",2],{"article-fixing-dns-resolution-after-disabling-systemd-resolved-for-pi-hole-4df3":3},{"type_of":4,"id":5,"title":6,"description":7,"readable_publish_date":8,"slug":9,"path":10,"url":11,"comments_count":12,"public_reactions_count":13,"collection_id":14,"published_timestamp":15,"language":16,"subforem_id":13,"positive_reactions_count":13,"cover_image":17,"social_image":18,"canonical_url":11,"created_at":15,"edited_at":14,"crossposted_at":14,"published_at":15,"last_comment_at":15,"reading_time_minutes":19,"tag_list":20,"tags":21,"body_html":26,"body_markdown":27,"user":28},"article",2752546,"Fixing DNS Resolution After Disabling systemd-resolved for Pi-hole","However, after doing this, I ran into a strange issue: some Python programs (specifically those using...","Aug 5 '25","fixing-dns-resolution-after-disabling-systemd-resolved-for-pi-hole-4df3","\u002Fashraful\u002Ffixing-dns-resolution-after-disabling-systemd-resolved-for-pi-hole-4df3","https:\u002F\u002Fdev.to\u002Fashraful\u002Ffixing-dns-resolution-after-disabling-systemd-resolved-for-pi-hole-4df3",0,1,null,"2025-08-05T04:49:15Z","en","https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=1000,height=420,fit=cover,gravity=auto,format=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpj54yxt6a25tytwm2yj.png","https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=1000,height=500,fit=cover,gravity=auto,format=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpj54yxt6a25tytwm2yj.png",2,"pihole, dns, ubuntu, linux",[22,23,24,25],"pihole","dns","ubuntu","linux","\u003Cp>However, after doing this, I ran into a strange issue: some Python programs (specifically those using \u003Ccode>dnspython\u003C\u002Fcode>) could no longer resolve domain names. Here's how I diagnosed and fixed the problem.\u003C\u002Fp>\n\n\u003Cp>\u003Cstrong>Originally Posted on \u003Ca href=\"https:\u002F\u002Fblog.ashraful.dev\u002Fposts\u002Fhome-server\u002Fdns-resolving-at-home-server.html\" target=\"_blank\" rel=\"noopener noreferrer\">Ashraful's Blog\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>\n\n\n\u003Chr>\n\n\u003Ch2>\n  \u003Ca name=\"the-problem\" href=\"#the-problem\">\n  \u003C\u002Fa>\n  🔍 The Problem\n\u003C\u002Fh2>\n\n\u003Cp>To route DNS through Pi-hole, I disabled \u003Ccode>systemd-resolved\u003C\u002Fcode>:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>\u003Cspan class=\"nb\">sudo \u003C\u002Fspan>systemctl disable \u003Cspan class=\"nt\">--now\u003C\u002Fspan> systemd-resolved\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>My home server then used Pi-hole's IP (e.g., \u003Ccode>192.168.10.10\u003C\u002Fcode>) as its DNS server. Most things worked fine — \u003Ccode>ping\u003C\u002Fcode>, \u003Ccode>curl\u003C\u002Fcode>, and \u003Ccode>dig\u003C\u002Fcode> had no issues.\u003C\u002Fp>\n\n\u003Cp>But some Python code using \u003Ccode>dnspython\u003C\u002Fcode> threw an error like:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight plaintext\">\u003Ccode>dns.resolver.NoNameservers: All nameservers failed to answer the query\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>Or even:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight plaintext\">\u003Ccode>FileNotFoundError: [Errno 2] No such file or directory: '\u002Fetc\u002Fresolv.conf'\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\n\u003Chr>\n\n\u003Ch2>\n  \u003Ca name=\"whats-going-on\" href=\"#whats-going-on\">\n  \u003C\u002Fa>\n  🧠 What’s Going On?\n\u003C\u002Fh2>\n\n\u003Cp>Many programs — including \u003Ccode>dnspython\u003C\u002Fcode> — read DNS server information directly from \u003Ccode>\u002Fetc\u002Fresolv.conf\u003C\u002Fcode>.\u003C\u002Fp>\n\n\u003Cp>When \u003Ccode>systemd-resolved\u003C\u002Fcode> is active, \u003Ccode>\u002Fetc\u002Fresolv.conf\u003C\u002Fcode> is often a \u003Cstrong>symlink\u003C\u002Fstrong> to a dynamically generated file like:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>\u002Fetc\u002Fresolv.conf -&gt; ..\u002Frun\u002Fsystemd\u002Fresolve\u002Fstub-resolv.conf\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>But once \u003Ccode>systemd-resolved\u003C\u002Fcode> is disabled, this symlink points to a non-existent file. Programs depending on it will fail to resolve any domains.\u003C\u002Fp>\n\n\n\u003Chr>\n\n\u003Ch2>\n  \u003Ca name=\"the-fix\" href=\"#the-fix\">\n  \u003C\u002Fa>\n  ✅ The Fix\n\u003C\u002Fh2>\n\n\u003Cp>We need to \u003Cstrong>replace the broken symlink\u003C\u002Fstrong> with a static \u003Ccode>resolv.conf\u003C\u002Fcode> file that directly specifies our Pi-hole DNS.\u003C\u002Fp>\n\n\u003Ch3>\n  \u003Ca name=\"1-remove-the-broken-symlink\" href=\"#1-remove-the-broken-symlink\">\n  \u003C\u002Fa>\n  1. Remove the broken symlink\n\u003C\u002Fh3>\n\n\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>\u003Cspan class=\"nb\">sudo rm\u003C\u002Fspan> \u002Fetc\u002Fresolv.conf\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Ch3>\n  \u003Ca name=\"2-create-a-new-static-file\" href=\"#2-create-a-new-static-file\">\n  \u003C\u002Fa>\n  2. Create a new static file\n\u003C\u002Fh3>\n\n\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>\u003Cspan class=\"nb\">sudo \u003C\u002Fspan>nano \u002Fetc\u002Fresolv.conf\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>Paste your Pi-hole DNS IP (replace with your actual IP):\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight plaintext\">\u003Ccode>nameserver 192.168.10.10\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>Optionally, add a fallback:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight plaintext\">\u003Ccode>nameserver 192.168.10.10\nnameserver 8.8.8.8\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>Save and close the file.\u003C\u002Fp>\n\n\u003Ch3>\n  \u003Ca name=\"3-optional-prevent-overwrites\" href=\"#3-optional-prevent-overwrites\">\n  \u003C\u002Fa>\n  3. (Optional) Prevent overwrites\n\u003C\u002Fh3>\n\n\u003Cp>To ensure no other service modifies it (e.g., NetworkManager):\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>\u003Cspan class=\"nb\">sudo \u003C\u002Fspan>chattr +i \u002Fetc\u002Fresolv.conf\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>To remove the protection later:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>\u003Cspan class=\"nb\">sudo \u003C\u002Fspan>chattr \u003Cspan class=\"nt\">-i\u003C\u002Fspan> \u002Fetc\u002Fresolv.conf\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\n\u003Chr>\n\n\u003Ch2>\n  \u003Ca name=\"test-dns-resolution\" href=\"#test-dns-resolution\">\n  \u003C\u002Fa>\n  🧪 Test DNS Resolution\n\u003C\u002Fh2>\n\n\u003Cp>Using \u003Ccode>nslookup\u003C\u002Fcode>:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight shell\">\u003Ccode>nslookup google.com\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>Using Python:\u003Cbr>\n\u003C\u002Fp>\n\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight python\">\u003Ccode>\u003Cspan class=\"kn\">import\u003C\u002Fspan> \u003Cspan class=\"n\">dns.resolver\u003C\u002Fspan>\n\u003Cspan class=\"n\">result\u003C\u002Fspan> \u003Cspan class=\"o\">=\u003C\u002Fspan> \u003Cspan class=\"n\">dns\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"n\">resolver\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nf\">resolve\u003C\u002Fspan>\u003Cspan class=\"p\">(\u003C\u002Fspan>\u003Cspan class=\"sh\">\"\u003C\u002Fspan>\u003Cspan class=\"s\">google.com\u003C\u002Fspan>\u003Cspan class=\"sh\">\"\u003C\u002Fspan>\u003Cspan class=\"p\">)\u003C\u002Fspan>\n\u003Cspan class=\"nf\">print\u003C\u002Fspan>\u003Cspan class=\"p\">(\u003C\u002Fspan>\u003Cspan class=\"n\">result\u003C\u002Fspan>\u003Cspan class=\"p\">[\u003C\u002Fspan>\u003Cspan class=\"mi\">0\u003C\u002Fspan>\u003Cspan class=\"p\">])\u003C\u002Fspan>\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\">\u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n    \u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\">\u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\n    \u003Cpath d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\">\u003C\u002Fpath>\n\u003C\u002Fsvg>\n\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\n\n\u003Cp>If everything is working, you'll get a valid IP response.\u003C\u002Fp>\n\n\n\u003Chr>\n\n\u003Ch2>\n  \u003Ca name=\"summary\" href=\"#summary\">\n  \u003C\u002Fa>\n  🧵 Summary\n\u003C\u002Fh2>\n\n\u003Cp>Because I'm using \u003Cstrong>Pi-hole as my network guardian\u003C\u002Fstrong>, I wanted to disable any system-level DNS services that could bypass it. Disabling \u003Ccode>systemd-resolved\u003C\u002Fcode> was necessary — but it broke \u003Ccode>\u002Fetc\u002Fresolv.conf\u003C\u002Fcode>, which some programs still depend on.\u003C\u002Fp>\n\n\u003Cp>By creating a \u003Cstrong>manual \u003Ccode>resolv.conf\u003C\u002Fcode>\u003C\u002Fstrong> that points to Pi-hole, I ensured full DNS functionality while keeping all traffic filtered and protected.\u003C\u002Fp>\n\n\n\u003Chr>\n\n\u003Cp>Happy tinkering! 🛠️🧠🔒\u003C\u002Fp>\n\n","\nHowever, after doing this, I ran into a strange issue: some Python programs (specifically those using `dnspython`) could no longer resolve domain names. Here's how I diagnosed and fixed the problem.\n\n**Originally Posted on [Ashraful's Blog](https:\u002F\u002Fblog.ashraful.dev\u002Fposts\u002Fhome-server\u002Fdns-resolving-at-home-server.html)**\n\n---\n\n## 🔍 The Problem\n\nTo route DNS through Pi-hole, I disabled `systemd-resolved`:\n\n```bash\nsudo systemctl disable --now systemd-resolved\n```\n\nMy home server then used Pi-hole's IP (e.g., `192.168.10.10`) as its DNS server. Most things worked fine — `ping`, `curl`, and `dig` had no issues.\n\nBut some Python code using `dnspython` threw an error like:\n\n```\ndns.resolver.NoNameservers: All nameservers failed to answer the query\n```\n\nOr even:\n\n```\nFileNotFoundError: [Errno 2] No such file or directory: '\u002Fetc\u002Fresolv.conf'\n```\n\n---\n\n## 🧠 What’s Going On?\n\nMany programs — including `dnspython` — read DNS server information directly from `\u002Fetc\u002Fresolv.conf`.\n\nWhen `systemd-resolved` is active, `\u002Fetc\u002Fresolv.conf` is often a **symlink** to a dynamically generated file like:\n\n```bash\n\u002Fetc\u002Fresolv.conf -> ..\u002Frun\u002Fsystemd\u002Fresolve\u002Fstub-resolv.conf\n```\n\nBut once `systemd-resolved` is disabled, this symlink points to a non-existent file. Programs depending on it will fail to resolve any domains.\n\n---\n\n## ✅ The Fix\n\nWe need to **replace the broken symlink** with a static `resolv.conf` file that directly specifies our Pi-hole DNS.\n\n### 1. Remove the broken symlink\n\n```bash\nsudo rm \u002Fetc\u002Fresolv.conf\n```\n\n### 2. Create a new static file\n\n```bash\nsudo nano \u002Fetc\u002Fresolv.conf\n```\n\nPaste your Pi-hole DNS IP (replace with your actual IP):\n\n```text\nnameserver 192.168.10.10\n```\n\nOptionally, add a fallback:\n\n```text\nnameserver 192.168.10.10\nnameserver 8.8.8.8\n```\n\nSave and close the file.\n\n### 3. (Optional) Prevent overwrites\n\nTo ensure no other service modifies it (e.g., NetworkManager):\n\n```bash\nsudo chattr +i \u002Fetc\u002Fresolv.conf\n```\n\nTo remove the protection later:\n\n```bash\nsudo chattr -i \u002Fetc\u002Fresolv.conf\n```\n\n---\n\n## 🧪 Test DNS Resolution\n\nUsing `nslookup`:\n\n```bash\nnslookup google.com\n```\n\nUsing Python:\n\n```python\nimport dns.resolver\nresult = dns.resolver.resolve(\"google.com\")\nprint(result[0])\n```\n\nIf everything is working, you'll get a valid IP response.\n\n---\n\n## 🧵 Summary\n\nBecause I'm using **Pi-hole as my network guardian**, I wanted to disable any system-level DNS services that could bypass it. Disabling `systemd-resolved` was necessary — but it broke `\u002Fetc\u002Fresolv.conf`, which some programs still depend on.\n\nBy creating a **manual `resolv.conf`** that points to Pi-hole, I ensured full DNS functionality while keeping all traffic filtered and protected.\n\n---\n\nHappy tinkering! 🛠️🧠🔒\n",{"name":29,"username":30,"twitter_username":31,"github_username":32,"user_id":33,"website_url":34,"profile_image":35,"profile_image_90":36},"Mohamad Ashraful Islam","ashraful","_ashraful","iashraful",30490,"https:\u002F\u002Fashraful.dev","https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=640,height=640,fit=cover,gravity=auto,format=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F30490%2F9dc1ef64-0233-43b5-9127-79affd83cc43.jpg","https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=90,height=90,fit=cover,gravity=auto,format=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F30490%2F9dc1ef64-0233-43b5-9127-79affd83cc43.jpg",1784633123718]