Clearing DNS cache in Debian 11/12 LXC

jsabater

Member
Oct 25, 2021
110
11
23
48
Palma, Mallorca, Spain
Hey everyone!

So I have a number of LXC in my Proxmox cluster, some of them Debian 11 and some others Debian 12 (templates provided by Proxmox), and I am trying to find a way to clear the local DNS cache as I need to force querying again the internal DNS server despite the TTL of the record. I have already cleared the cache of the internal PowerDNS recursor via the rec_control command.

For whatever reason I though that they would be using systemd-resolved but it seems that neither are. I have been searching for a solution on the Internet without luck. Does anyone know the way to do so without having to resort to systemctl restart networking?

Thanks.
 
Could you check to create .pve-ignore.resolv.conf in /etc/ e.g: `touch /etc/.pve-ignore.resolv.conf` for more information read [0].


[0] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#_guest_operating_system_configuration

Hi, @Moayad, and thanks for your reply. I wasn't aware of the possibilities explained in the link you provided.

However, if I understood correctly, creating the file /etc/.pve-ignore.resolv.conf would prevent Proxmox from updating the file /etc/resolv.conf with the DNS configuration made for the LXC (e.g., via the DNS option of the WebGUI) upon start-up, which would not help with the issue at hand.

For reference, the contents of my /etc/resolv.conf are as follows:

Code:
# --- BEGIN PVE ---
search localdomain.com
nameserver 192.168.0.253
nameserver 192.168.0.254
# --- END PVE ---

Where those two nameservers are my internal nameservers in the cluster and localdomain is the internal domain of the cluster.

The thing is that the configuration is working fine. My problem is that I have an Ansible playbook performing, among others, the following two tasks:

1. Check whether a record something.publicdomain.com exists.
2. If it does not, then create it.

Then, at the very end, it tries to prime the cache of the newly created website on that address by loading the home page. Thus it attempts to resolve the DNS query again, but the internal (PowerDNS) recursor already has the NXDOMAIN value cached (i.e., record does not exist), so it fails. Eventually, the TTL of the cache expires (minutes later) and, when querying the record again, it works fine.

First thing I tried to do was to clear the recursor cache, but that didn't help. So what I presume is happening is that there is some sort of local cache either inside the LXC (running Debian 12 at the moment), or at the host/node level (because of dynamics of LXD which I do not know about).

I hope this shed some light that can help you figure out what I could not.

Thanks in advance.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!