[SOLVED] change DNS to a LXC

piviul

Active Member
Mar 19, 2020
50
3
28
Hi all, in a LXC unprivileged container I would like to change the DNS. If I change the resolv.conf I fear that at every restart of the CT I find resolv.conf in a reversed state so I would ask you what's the standard way to change DNS in a LXC.

Best regards

Piviul
 
Proxmox is handling the config file, change the dns in the gui. Your container -> DNS

If you want to use something like ansible to automate config changes, create a .pve-ignore file, read the lxc docs.
 
Glad that resolved so easily :) - please mark the thread as 'SOLVED' - it helps other users with similar questions

Thanks!
 
Hi,

I'm experiencing nameserver get reverted the default bridge after the container getting reboot. This is the DNS settings of my containers.

Screenshot 2025-03-24 at 5.44.34 PM.png

I have two networks interfaces. For some reason it keeps reverted to the nameserver to 192.168.0.1 (my wifi router)

Screenshot 2025-03-24 at 5.45.35 PM.png

And the problem goes away when i use static IP for the default bridge. I'm not sure what happens but it would be nice to have a way to set fixed nameserver for multiple dhcp networks.
 
Last edited:
Is it possible that your DHCP server is sending the DNS server in its response, which then gets set? If that's the case then you need to configure dhclient to ignore the DNS servers in its config (/etc/dhcp/dhclient.conf):

Code:
supersede domain-name-servers X.X.X.X;

Also, please dont necro-bump old threads that are tangentially related to your issue, but rather open a new thread.
 
  • Like
Reactions: lnguyen
Hi Stefan,

Thank you very much for helping. This just saves me couple of hours on debugging.
And let me open a new thread next time.
 
  • Like
Reactions: shanreich