DNS CNAME shenanigans
Today I learned that using CNAMES in combination with /etc/hosts
can be a really powerful tool and a cheap way to build a split-DNS setup. The way it works, is by using a CNAME for the target domain(e.g. example.com
) and adding the reference (e.g. cdn.example.com
) with a local IP into /etc/hosts
. As a result, you’ll get the IP locally set for cdn.example.com
as target for example.com
.
I came across this, while searching for an easy way to redirect traffic to a local IP, while exposing the same service on a public IP. I decided to test how systemd-resolved would behave and it behaved exactly as I wanted, which might be the easiest solution for my problem for now.