Using example.com, I have a web server that serves:
example.com
www.example.com
I have a separate staging server which serves:
staging.example.com
For some reason, the production server resolves staging.example.com to 127.0.0.1. In fact, all subdomains resolve to 127.0.0.1. I do not have the same problem with the staging server. I.e. when I curl -I www.example.com
from the staging server, I get back the correct public facing IP address.
My question is, why is this happening and how can I fix it so that the production server correctly resolves DNS for subdomains?
2
Answers
The cause of the problem turned out to be
Dnsmasq
.Specifically, setting an address value in
/etc/dnsmasq.conf
like so:This rule will apply to the domain name as well as all subdomains. There is no way to have this rule only apply to the root domain.
My fix was to explicitly list the subdomains here and remove the root domain rule
Can you share the rest of your hosted zone configuration? For example if you have a record like:
*.example.com --> 127.0.0.1
In your hosted zone, this would cause all unmatched subdomains under example.com to resolve to this address