<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>dns on Luis Logs</title>
    <link>https://luislogs.com/tags/dns/</link>
    <description>Recent content in dns on Luis Logs</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 08 May 2023 18:40:30 +0900</lastBuildDate><atom:link href="https://luislogs.com/tags/dns/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Run Pihole in an LXC container in Proxmox</title>
      <link>https://luislogs.com/posts/run-pihole-in-an-lxc-container-in-proxmox/</link>
      <pubDate>Mon, 08 May 2023 18:40:30 +0900</pubDate>
      
      <guid>https://luislogs.com/posts/run-pihole-in-an-lxc-container-in-proxmox/</guid>
      <description>Pihole as our local DNS at home has been working perfectly fine. It blocks almost every ad there is whenever I am browsing. I was initially running it as a docker container within my Unraid server. The problem is every time I would restart Unraid for some experimental work, the internet of the entire house also goes down momentarily. I already tried defining a secondary DNS on my DHCP server but noticed some of my devices would randomly pick a DNS if there are multiple defined.</description>
      <content:encoded><![CDATA[<p>Pihole as our local DNS at home has been working perfectly fine. It blocks almost every ad there is whenever I am browsing. I was initially running it as a docker container within my Unraid server. The problem is every time I would restart Unraid for some experimental work, the internet of the entire house also goes down momentarily. I already tried defining a secondary DNS on my DHCP server but noticed some of my devices would randomly pick a DNS if there are multiple defined. Now that I have a Proxmox running OPNsense, I just thought of running Pihole there instead, since anyway I rarely restart that box.</p>
<p>Proxmox already supports LXC containers by default and in this case, running Pihole on LXC provides some advantage in terms of flexibility and ease of configuration. This is especially for those who have less experience working with docker but only with Linux in general. I will share one good use case for this later on but for now let’s start setting up Pihole on Proxmox.</p>
<p>The hardware requirements according to the pihole documentation:
Minimum of 2GB disk (4GB recommended)
512MB RAM</p>
<p>First you need to download an LXC template. I like using debian as the base image since it’s very lightweight and it’s where Ubuntu is based from. If you don’t have it yet, you can download it by going to Datacenter &gt; pve &gt; storage &gt; CT templates &gt; Templates and search for Debian 11 Bullseye.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_2.png" alt="alt text">
  </p>
<p>Click on Create CT and input a container ID, hostname, and the root password. Check Unprivileged container and nesting (optional). Note that nesting is not really required but in my case the proxmox terminal will keep on printing permission errors if I leave this unchecked.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_3.png" alt="alt text">
  </p>
<p>Select debian as the template.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_4.png" alt="alt text">
  </p>
<p>For disk, I assigned 6GB. For RAM, double the recommended, since I have enough.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_5.png" alt="alt text">
  </p>
<p>Assign a static IP to the container. Gateway should also be defined.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_6.png" alt="alt text">
  </p>
<p>For DNS I will assign my unbound IP which is the same as my OPNsense gateway IP. (Unbound is a DNS caching tool built-into OPNsense). This will basically be my upstream DNS for my Pihole. If you don’t have Unbound running then you can input any public DNS like Google (8.8.8.8, 8.8.4.4) or Cloudflare (1.1.1.1).</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_7.png" alt="alt text">
  </p>
<p>Confirm</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_8.png" alt="alt text">
  </p>
<p>Enable start on boot flag.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_9.png" alt="alt text">
  </p>
<p>Login as root</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_10.png" alt="alt text">
  </p>
<p>Update and upgrade</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">apt-get update -y <span class="o">&amp;&amp;</span> apt-get upgrade -y
</span></span></code></pre></div><p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_11.png" alt="alt text">
  </p>
<p>Install curl:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">apt-get install curl -y
</span></span></code></pre></div><p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_12.png" alt="alt text">
  </p>
<p>Install Pihole:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -sSL https://install.pi-hole.net <span class="p">|</span> bash
</span></span></code></pre></div><p>Install custom upstream and point to unbound IP</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_13.png" alt="alt text">
  </p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_14.png" alt="alt text">
  </p>
<p>Install the default blacklist.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_15.png" alt="alt text">
  </p>
<p>Install admin interface and lighthttpd.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_16.png" alt="alt text">
  </p>
<p>Query logging or any other option is fine.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_17.png" alt="alt text">
  </p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_18.png" alt="alt text">
  </p>
<p>Reset the pihole password.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo pihole -a -p
</span></span></code></pre></div><p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_19.png" alt="alt text">
  </p>
<p>Now go to your container IP and append /admin (e.g. http://10.0.0.88/admin)</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_20.png" alt="alt text">
  </p>
<p>If you are running it on proxmox like me you’d probably get the same error as in the snap below. You can ignore this especially if you have multi-core host. If you want to be sure you can check your CPU utilization with the top command.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_21.png" alt="alt text">
  </p>
<p>After changing your DNS to pihole, check with nslookup if your device is able to send and receive to and from the Pihole IP.</p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_22.png" alt="alt text">
  </p>
<p>
    <img src="/posts/run-pihole-in-an-lxc-container-in-proxmox/20230508_23.png" alt="alt text">
  </p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
