Do you have Docker installed?
Can you reproduce this with just lxc?
lxc launch ubuntu:24.04 c1 lxc shell c1 -- getent hosts snapcraft.io
Have you seen this thread?