<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can't get dns to work with cloud-init on debian11]]></title><description><![CDATA[<p dir="auto">I've read this post and also been trying my own research but I just can't get it to work.</p>
<p dir="auto"><a href="https://xcp-ng.org/forum/topic/6777/cloud-init-network-config-not-applying-to-debian-11-6?_=1692953942818">https://xcp-ng.org/forum/topic/6777/cloud-init-network-config-not-applying-to-debian-11-6?_=1692953942818</a></p>
<p dir="auto">This is my network cloud init configuration</p>
<pre><code class="language-yaml">network:
  version: 1
  config:
    - type: physical
      name: eth0
      subnets:
         - type: static
           address: 192.0.2.6/28
           gateway: 192.0.2.1
    - type: nameserver
      interface: eth0
      address:
        - 9.9.9.9
        - 1.1.1.1
      search:
        - example.com
    - type: physical
      name: eth1
      subnets:
         - type: static
           address: 10.10.10.6/24
</code></pre>
<p dir="auto">The result is this file data in <code>/etc/network/interfaces.d/50-cloud-init</code></p>
<pre><code class="language-yaml">auto lo
iface lo inet loopback
    dns-nameservers 9.9.9.9 1.1.1.1
    dns-search example.com

auto eth0
iface eth0 inet static
    address 192.0.2.6/28
    gateway 192.0.2.1

auto eth1
iface eth1 inet static
    address 10.10.10.6/24
</code></pre>
<p dir="auto">how do I get the network in such a way that DNS also works? If I add my nameservers to /etc/resolv.conf everything works.<br />
I'm also a bit confused as why I have eth0 as dhcp on in <code>/etc/network/interfaces</code> but nothing regarding <code>eth1</code></p>
<p dir="auto">This cloud-init stuff is driving me bananas!</p>
]]></description><link>https://xcp-ng.org/forum/topic/7669/can-t-get-dns-to-work-with-cloud-init-on-debian11</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 03:29:51 GMT</lastBuildDate><atom:link href="https://xcp-ng.org/forum/topic/7669.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Aug 2023 09:28:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 20:28:37 GMT]]></title><description><![CDATA[<p dir="auto">Good news! Keep us posted <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1d3f495298e" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/65016</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/65016</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 16:08:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> Thanks, just stumbled over this a few minutes ago and tried it, but doesn't work. According to <a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting#write-files-to-the-disk" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting#write-files-to-the-disk</a></p>
<blockquote>
<p dir="auto">This currently only works for RHEL-based distributions.</p>
</blockquote>
<p dir="auto">But this led me to <code>write_files</code> and this works:</p>
<pre><code class="language-yaml">write_files:
  - path: /etc/resolv.conf
    content: |
      domain exmple.com
      search example.com
      nameserver 192.168.20.1
</code></pre>
<p dir="auto">this is the full configuration I use:</p>
<pre><code class="language-yaml">#cloud-config
hostname: {name}
timezone: Europe/Vienna
users:
  - default
  - name: johndow
    passwd: ****
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: users, admin, sudo
    shell: /bin/bash
    lock_passwd: true
    ssh_authorized_keys:
      - ssh-ed25519 AAAA****
write_files:
  - path: /etc/resolv.conf
    content: |
      domain example.com
      search example.com
      nameserver 192.168.20.1
package_update: true
packages:
  - sudo
  - htop
  - vim
  - python
  - tmux
package_upgrade: true
runcmd:
  - sudo reboot
</code></pre>
<p dir="auto">the Network configuration looks like this:</p>
<pre><code class="language-yaml">  version: 2
  ethernets:
    eth0:
      match:
        name: eth0
      addresses:
        - 192.168.20.6/28
      gateway4: 192.168.20.1
    eth1:
      match:
        name: eth1
      addresses:
        - 10.10.10.6/24
</code></pre>
<p dir="auto">but now it seems I forgot the MTU but this is a different story, thanks for the hint in the right direction.</p>
]]></description><link>https://xcp-ng.org/forum/post/65012</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/65012</guid><dc:creator><![CDATA[ditzy-olive]]></dc:creator><pubDate>Fri, 25 Aug 2023 16:08:57 GMT</pubDate></item><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 15:56:39 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://cloudinit.readthedocs.io/en/18.5/topics/examples.html#configure-an-instances-resolv-conf" target="_blank" rel="noopener noreferrer nofollow ugc">https://cloudinit.readthedocs.io/en/18.5/topics/examples.html#configure-an-instances-resolv-conf</a></p>
]]></description><link>https://xcp-ng.org/forum/post/65010</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/65010</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Fri, 25 Aug 2023 15:56:39 GMT</pubDate></item><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 15:38:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> sure ... how?<br />
I couldn't find out how to do that.  Looking into that option right now but if you have some hints I would appreciate it.</p>
]]></description><link>https://xcp-ng.org/forum/post/65009</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/65009</guid><dc:creator><![CDATA[ditzy-olive]]></dc:creator><pubDate>Fri, 25 Aug 2023 15:38:42 GMT</pubDate></item><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 14:30:54 GMT]]></title><description><![CDATA[<p dir="auto">Why not passing the content of the resolvconf file via Cloudinit?</p>
]]></description><link>https://xcp-ng.org/forum/post/65006</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/65006</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Fri, 25 Aug 2023 14:30:54 GMT</pubDate></item><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 14:18:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> it's not that simple I guess. Because I can't install anything without having DNS during the cloud-init <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=1d3f495298e" class="not-responsive emoji emoji-android emoji--disappointed" style="height:1.4em;width:auto;vertical-align:middle" title=":(" alt="😞" /><br />
Everything works fine if I use DHCP but this would result in eth0 being my internal network and default GW being via the internal router and eth1 having my public IP.<br />
I want it the other way round <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1d3f495298e" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">The second solution would be to use DHCP to get everything installed then nuke the whole cloud-init stuff and configure network manually. Bit of a pain I guess.<br />
How are other people dealing with this whole clod-init on debian?</p>
]]></description><link>https://xcp-ng.org/forum/post/65005</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/65005</guid><dc:creator><![CDATA[ditzy-olive]]></dc:creator><pubDate>Fri, 25 Aug 2023 14:18:18 GMT</pubDate></item><item><title><![CDATA[Reply to Can't get dns to work with cloud-init on debian11 on Fri, 25 Aug 2023 09:50:53 GMT]]></title><description><![CDATA[<p dir="auto">This is a Debian question <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1d3f495298e" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /> You might check you have the <code>resolvconf</code> package installed, that's where it will check the DNS in the interfaces file and automatically fill the resolv file <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1d3f495298e" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/64995</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/64995</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Fri, 25 Aug 2023 09:50:53 GMT</pubDate></item></channel></rss>