简体   繁体   中英

DNS issue where all subdomains for Debian linux web server resolve to 127.0.0.1 instead of their proper public IP addresses

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. Ie 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?

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

The cause of the problem turned out to be Dnsmasq .

Specifically, setting an address value in /etc/dnsmasq.conf like so:

address=/example.com/127.0.0.1 

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

address=/api.example.com/127.0.0.1
address=/anothersubdomain.example.com/127.0.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM