How to Detect Wildcard DNS A Records: A Programmer’s Guide to DNS Record Analysis


2 views

html

Wildcard DNS records (specifically A records) are configured using the asterisk (*) character as a subdomain placeholder. When present, they match any undefined subdomains. For example:

*.example.com.    IN  A   192.0.2.1

This means requests to any undefined subdomain (like random.example.com) will resolve to 192.0.2.1.

Here are three reliable techniques to check for wildcard DNS configuration:

1. Using DIG (Command Line Tool)

Run these commands in sequence:

dig @8.8.8.8 test123.example.com +short
dig @8.8.8.8 random456.example.com +short

If both return the same IP address for non-existent subdomains, a wildcard record likely exists.

2. Windows PowerShell Approach

For Windows developers, use Resolve-DnsName:

Resolve-DnsName -Server 8.8.8.8 -Name "nonexistent1.example.com" -Type A
Resolve-DnsName -Server 8.8.8.8 -Name "nonexistent2.example.com" -Type A

Compare the IP addresses in the results.

3. Programmatic Detection in Python

Here's a script to automate wildcard detection:

import dns.resolver
import random

def has_wildcard_a_record(domain):
    test1 = f"{random.randint(0,99999)}.{domain}"
    test2 = f"{random.randint(0,99999)}.{domain}"
    
    try:
        answer1 = dns.resolver.resolve(test1, 'A')
        answer2 = dns.resolver.resolve(test2, 'A')
        return answer1[0].address == answer2[0].address
    except:
        return False

print(has_wildcard_a_record("example.com"))

Platforms known to use wildcard DNS:

  • Blogspot: *.blogspot.com (redirects to specific blog)
  • Heroku: *.herokuapp.com (routes to apps)
  • AWS Elastic Beanstalk: *.elasticbeanstalk.com

When testing for wildcards:

  • Use truly random subdomains to avoid cached results
  • Check multiple non-existent subdomains for consistency
  • Be aware of DNS caching - use different test strings each time
  • Some domains may have rate limits for DNS queries

Understanding wildcard DNS is crucial when:

// In web applications handling dynamic subdomains
if (hasWildcardDNS(domain)) {
    // Implement custom routing logic
    handleWildcardSubdomains();
} else {
    // Process individual subdomains
    handleExplicitSubdomains();
}

Wildcard DNS records (specifically wildcard A records) are DNS configurations that use an asterisk (*) as a subdomain placeholder. When configured as *.example.com, this single record will respond to any undefined subdomain requests for the domain.

For Windows programmers, these tools can help identify wildcard configurations:

# Using nslookup (Windows native tool)
nslookup random123.example.com
nslookup anotherrandom.example.com

# If both return identical IP addresses despite being non-existent subdomains,
# this strongly suggests a wildcard record exists

Here's a Python script to systematically test for wildcard DNS:

import dns.resolver
import random
import string

def check_wildcard(domain):
    # Generate random subdomains
    test_sub1 = ''.join(random.choices(string.ascii_lowercase, k=10)) + '.' + domain
    test_sub2 = ''.join(random.choices(string.ascii_lowercase, k=10)) + '.' + domain
    
    try:
        ip1 = dns.resolver.resolve(test_sub1, 'A')[0].address
        ip2 = dns.resolver.resolve(test_sub2, 'A')[0].address
        return ip1 == ip2
    except:
        return False

# Usage example
print(check_wildcard('example.com'))

For developers with Linux tools available:

dig +short nonexistent123.example.com A
dig +short anothernonexistent.example.com A

Let's examine blogspot.com's configuration:

nslookup random123.blogspot.com
# Returns: 216.58.192.46
nslookup anotherrandom.blogspot.com
# Returns: 216.58.192.46
# Both return same IP - confirms wildcard DNS

Some domains might implement partial wildcards (e.g., *.users.example.com) or have multiple wildcard levels. Always test with completely random subdomains to avoid false positives from actual existing records.

DNS caching can also affect results. For accurate testing, either use fresh subdomains each time or wait for TTL to expire between tests.