i can archive what i need on VM machine without any proble,m but not with CT.well, dhcp mostly also sends DNS entrys.
I would go with a Static IP ;-)
just tested for you ;-)
View attachment 90324
View attachment 90325
ssh root@your-proxmox-host
# Or use the Proxmox console from GUI
cd /var/lib/vz/snippets/
nano lxc-hookscript.pl
#!/usr/bin/perl
use strict;
use warnings;
print "GUEST HOOK: " . join(' ', @ARGV). "\n";
my $vmid = shift;
my $phase = shift;
print "STARTING PHASE '$phase' for CT $vmid\n";
if ($phase eq 'post-start') {
print "Configuring DNS for container $vmid\n";
# Configure DNS servers
system("pct exec $vmid -- bash -c 'echo \"nameserver 1.1.1.1\" > /etc/resolv.conf'");
system("pct exec $vmid -- bash -c 'echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf'");
system("pct exec $vmid -- bash -c 'echo \"search local\" >> /etc/resolv.conf'");
print "DNS configuration completed for container $vmid\n";
}
print "END PHASE '$phase' for CT $vmid\n";
chmod +x lxc-hookscript.pl
pct set 100 --hookscript local:snippets/lxc-hookscript.pl
pct stop 100
pct start 100
pct exec 100 -- cat /etc/resolv.conf
journalctl -u pve-container@100.service -f
# Make resolv.conf immutable to prevent DHCP changes
system("pct exec $vmid -- chattr +i /etc/resolv.conf");
Hi, thank for your reply with a workarround, i will test it and report back.I have seen you deleted your last comment. I also use from time to time claude as my Budy AI.
But as always it needs a good description ;-) and also never ever trust it in the first place.
when you execute certain commands, ask yourself what it does.
You have heard about hook scripts ?
1. Connect to Proxmox host:
Bash:ssh root@your-proxmox-host # Or use the Proxmox console from GUI
2. Navigate to snippets directory:
3. Create the hook script:Bash:cd /var/lib/vz/snippets/
4. Add the script content:Bash:nano lxc-hookscript.pl
Perl:#!/usr/bin/perl use strict; use warnings; print "GUEST HOOK: " . join(' ', @ARGV). "\n"; my $vmid = shift; my $phase = shift; print "STARTING PHASE '$phase' for CT $vmid\n"; if ($phase eq 'post-start') { print "Configuring DNS for container $vmid\n"; # Configure DNS servers system("pct exec $vmid -- bash -c 'echo \"nameserver 1.1.1.1\" > /etc/resolv.conf'"); system("pct exec $vmid -- bash -c 'echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf'"); system("pct exec $vmid -- bash -c 'echo \"search local\" >> /etc/resolv.conf'"); print "DNS configuration completed for container $vmid\n"; } print "END PHASE '$phase' for CT $vmid\n";
5. Make it executable:
Bash:chmod +x lxc-hookscript.pl
Test the Hook:
1. Apply hook to container:
2. Test by restarting container:Bash:pct set 100 --hookscript local:snippets/lxc-hookscript.pl
3. Check if DNS was configured:Bash:pct stop 100 pct start 100
4. View hook execution logs:Bash:pct exec 100 -- cat /etc/resolv.conf
Bash:journalctl -u pve-container@100.service -f
I just added other NS on my side, the ct 108 is an dhcp conatainer ;-)
View attachment 90369
View attachment 90370
View attachment 90371
We use essential cookies to make this site work, and optional cookies to enhance your experience.