Examples & Use Cases
ResolverOne was a hackathon project, and the DNS service is offline. The commands on this page no longer work. Do not send DNS queries or email to rslvr.one or resolver.one, because these domains expired and a new owner can control them.
Production-ready examples for integrating ResolverOne into your applications.
Direct vs Recursive Queries
ResolverOne supports two query methods. Direct queries are recommended for production use.
Performance & Reliability Comparison
| Aspect | Direct Query (@rslvr.one) | Recursive Query (default) |
|---|---|---|
| Speed | 30-70% faster | Depends on ISP DNS quality |
| Reliability | Direct to our optimized servers | May fail if ISP filters DNS |
| Latency | Minimal hops | Extra DNS resolution overhead |
| Caching | Our optimized cache | ISP cache (variable quality) |
| Best for | Production, batch processing | Testing, debugging |
When to Use Each Method
Direct Queries (@rslvr.one) - Recommended for:
- Production applications
- Batch processing multiple IPs
- IoT devices with limited resources
- Networks with unreliable ISP DNS
- When you need consistent performance
Recursive Queries - Use for:
- Initial testing and validation
- Debugging DNS propagation issues
- Environments where direct DNS is restricted
Quick Command Line Examples
Basic Queries
Note: Use @rslvr.one for direct queries to our nameservers - typically 30-70% faster!
# Check Google's DNS (direct query - recommended)
dig TXT 8.8.8.8.rslvr.one @rslvr.one +short
# Output: "US|United States|North America|NA|AS15169|Google LLC|google.com"
# Check Cloudflare's DNS (direct query)
dig TXT 1.1.1.1.rslvr.one @rslvr.one +short
# Output: "US|United States|North America|NA|AS13335|Cloudflare, Inc.|cloudflare.com"
# Check your own public IP (direct query)
MY_IP=$(curl -s ifconfig.me)
dig TXT $MY_IP.rslvr.one @rslvr.one +short
# Compare performance: recursive vs direct
echo "=== Recursive Query (via ISP DNS) ==="
time dig TXT 8.8.8.8.rslvr.one +short
echo "=== Direct Query (to our nameservers) ==="
time dig TXT 8.8.8.8.rslvr.one @rslvr.one +short
Batch Processing
#!/usr/bin/env bash
# Process multiple IPs using ResolverOne
IPS="8.8.8.8 1.1.1.1 208.67.222.222"
for ip in $IPS; do
echo "IP: $ip"
dig TXT "$ip.rslvr.one" @rslvr.one +short
echo "---"
done
IoT & Embedded Applications
Python IoT Device Manager
#!/usr/bin/env python3
# /// script
# dependencies = [
# "dnspython>=2.0.0",
# ]
# ///
"""Simple IoT device location tracker using ResolverOne"""
import dns.resolver
def get_location(ip):
"""Get location data for an IP address"""
try:
result = dns.resolver.resolve(f"{ip}.rslvr.one", "TXT")
response = str(result[0]).strip('"')
parts = response.split("|")
return {
"country_code": parts[0],
"country": parts[1],
"asn": parts[4],
"as_name": parts[5],
}
except Exception as e:
print(f"Error: {e}")
return None
# Track some IoT devices
devices = {
"sensor_001": "144.6.0.1", # AU
"gateway_002": "125.234.160.1", # VN
"camera_003": "144.120.0.1", # FJ
}
print("IoT Device Locations:")
print("=" * 50)
for device_id, ip in devices.items():
location = get_location(ip)
if location:
print(f"{device_id} ({ip})")
print(f" Location: {location['country']} ({location['country_code']})")
print(f" Network: {location['as_name']}")
print()
Fraud Detection & Security
Simple IP Reputation Check
#!/usr/bin/env python3
# /// script
# dependencies = [
# "dnspython>=2.0.0",
# ]
# ///
"""
Simple fraud detection using ResolverOne
"""
import dns.resolver
from typing import Set, Dict, Optional
import logging
class FraudDetector:
def __init__(self):
# Define suspicious countries (adjust for your use case)
self.high_risk_countries = {"CN", "RU", "KP", "IR"}
# Define suspicious ASNs (known bad actors)
self.suspicious_asns = {
"AS8888", # Example ASN
"AS9999", # Example ASN
}
# Cloud provider ASNs (may want different handling)
self.cloud_providers = {
"AS15169": "Google",
"AS16509": "Amazon AWS",
"AS13335": "Cloudflare",
"AS8075": "Microsoft Azure",
}
def get_location(self, ip: str) -> Optional[Dict]:
"""Get location data for IP."""
try:
# Use direct queries to our nameservers for reliability in security contexts
resolver = dns.resolver.Resolver()
# Resolve rslvr.one A records to get our nameserver IPs
resolver.nameservers = [
str(ip) for ip in dns.resolver.resolve("rslvr.one", "A")
]
result = resolver.resolve(f"{ip}.rslvr.one", "TXT")
response = str(result[0]).strip('"')
parts = response.split("|")
if len(parts) == 7:
return {
"country_code": parts[0],
"country": parts[1],
"continent": parts[2],
"continent_code": parts[3],
"asn": parts[4],
"as_name": parts[5],
"as_domain": parts[6],
}
except Exception as e:
logging.error(f"Error looking up {ip}: {e}")
return None
def check_ip(self, ip: str) -> Dict:
"""Perform fraud check on IP address."""
location = self.get_location(ip)
if not location:
return {
"ip": ip,
"risk_level": "unknown",
"reason": "Could not resolve location",
"action": "allow_with_caution",
}
risk_factors = []
risk_level = "low"
# Check country risk
if location["country_code"] in self.high_risk_countries:
risk_factors.append(f"High-risk country: {location['country']}")
risk_level = "high"
# Check ASN
if location["asn"] in self.suspicious_asns:
risk_factors.append(f"Suspicious ASN: {location['asn']}")
risk_level = "high"
# Check if it's a cloud provider
if location["asn"] in self.cloud_providers:
risk_factors.append(
f"Cloud provider: {self.cloud_providers[location['asn']]}"
)
if risk_level == "low":
risk_level = "medium"
# Determine action
if risk_level == "high":
action = "block"
elif risk_level == "medium":
action = "require_additional_verification"
else:
action = "allow"
return {
"ip": ip,
"location": location,
"risk_level": risk_level,
"risk_factors": risk_factors,
"action": action,
}
# Example usage
if __name__ == "__main__":
detector = FraudDetector()
test_ips = [
"175.45.176.1", # North Korea
"1.1.1.1", # Cloudflare (US)
"208.67.222.222", # OpenDNS (US)
]
for ip in test_ips:
result = detector.check_ip(ip)
print(f"IP: {ip}")
print(
f"Country: {result['location']['country']} ({result['location']['country_code']})"
)
print(f"Risk Level: {result['risk_level']}")
print(f"Action: {result['action']}")
if result["risk_factors"]:
print(f"Risk Factors: {', '.join(result['risk_factors'])}")
print("---")
Web Application Integration (Flask)
Test with curl -s -H "X-Forwarded-For: 1.1.1.1" http://127.0.0.1:5000/ | jq .
# /// script
# dependencies = [
# "flask>=2.0.0",
# "dnspython>=2.0.0",
# ]
# ///
from flask import Flask, request, jsonify
import dns.resolver
app = Flask(__name__)
def get_location(ip):
"""Get location data for an IP address."""
try:
result = dns.resolver.resolve(f"{ip}.rslvr.one", "TXT")
response = str(result[0]).strip('"')
parts = response.split("|")
return {
"country_code": parts[0],
"country": parts[1],
"asn": parts[4],
"as_name": parts[5],
}
except Exception:
return None
@app.route("/")
def home():
"""Check your location."""
client_ip = request.headers.get("X-Forwarded-For", request.remote_addr)
location = get_location(client_ip)
if location:
return jsonify(
{
"ip": client_ip,
"country": location["country"],
"country_code": location["country_code"],
"network": location["as_name"],
}
)
else:
return jsonify({"error": "Could not determine location"}), 400
if __name__ == "__main__":
app.run(debug=True)
Content Delivery & Optimization
Nginx Log Enrichment with GeoIP
Enhance your nginx access logs with geographic data for better analytics and monitoring.
#!/usr/bin/env bash
# Enrich nginx access logs with GeoIP data in real-time
get_location() {
local ip=$1
dig TXT "$ip.rslvr.one" @rslvr.one +short 2>/dev/null | tr -d '"'
}
# Process nginx access log and add GeoIP data
tail -f /var/log/nginx/access.log | while read -r line; do
# Extract IP address (first field in nginx access log)
ip=$(echo "$line" | awk '{print $1}')
# Skip private IPs
if [[ $ip =~ ^(127\.|192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\.) ]]; then
echo "$line [LOCAL]"
continue
fi
# Get location data
location=$(get_location "$ip")
if [[ -n "$location" ]]; then
country=$(echo "$location" | cut -d'|' -f2)
country_code=$(echo "$location" | cut -d'|' -f1)
echo "$line [$country_code|$country]"
else
echo "$line [UNKNOWN]"
fi
done
Example output:
1.1.1.1 - - [16/Oct/2025:10:15:33] "GET /api HTTP/1.1" 200 [AU|Australia]
8.8.8.8 - - [16/Oct/2025:10:15:34] "GET / HTTP/1.1" 200 [US|United States]
For batch processing existing logs:
#!/usr/bin/env bash
# Process existing nginx log file
while read -r line; do
ip=$(echo "$line" | awk '{print $1}')
if [[ $ip =~ ^(127\.|192\.168\.|10\.) ]]; then
echo "$line [LOCAL]"
else
location=$(dig TXT "$ip.rslvr.one" @rslvr.one +short 2>/dev/null | tr -d '"')
country=$(echo "$location" | cut -d'|' -f1-2 | tr '|' ':')
echo "$line [$country]"
fi
done < /var/log/nginx/access.log > /var/log/nginx/access-geo.log
Dynamic Content Localization
const express = require('express');
const dns = require('dns').promises;
const app = express();
async function getLocation(ip) {
try {
const records = await dns.resolveTxt(`${ip}.rslvr.one`);
const parts = records[0][0].split('|');
return {
country_code: parts[0],
country: parts[1],
continent: parts[2]
};
} catch (error) {
return null;
}
}
// Middleware to add location to request
app.use(async (req, res, next) => {
const clientIP = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
// Default for localhost
if (!clientIP || clientIP === '127.0.0.1' || clientIP.includes('::1')) {
req.location = { country_code: 'US', country: 'United States' };
return next();
}
req.location = await getLocation(clientIP) || { country_code: 'US', country: 'United States' };
next();
});
// Return localized configuration
app.get('/api/config', (req, res) => {
const { country_code } = req.location;
const localization = {
'US': { currency: 'USD', language: 'en-US', phone: '+1-800-555-0123' },
'GB': { currency: 'GBP', language: 'en-GB', phone: '+44-20-7946-0958' },
'JP': { currency: 'JPY', language: 'ja-JP', phone: '+81-3-1234-5678' },
'DE': { currency: 'EUR', language: 'de-DE', phone: '+49-30-1234-5678' }
};
res.json({
location: req.location,
config: localization[country_code] || localization['US']
});
});
// Regional pricing
app.get('/pricing', (req, res) => {
const { country_code } = req.location;
const pricing = {
'US': { basic: '$9.99', pro: '$29.99' },
'GB': { basic: '£7.99', pro: '£24.99' },
'IN': { basic: '₹299', pro: '₹899' },
'BR': { basic: 'R$19.99', pro: 'R$59.99' }
};
res.json(pricing[country_code] || pricing['US']);
});
app.listen(3000, () => console.log('Server running on port 3000'));
Monitoring & Analytics
Simple Analytics Script
#!/usr/bin/env python3
# /// script
# dependencies = [
# "dnspython>=2.0.0",
# ]
# ///
"""
Analyze visitor locations from log files
"""
import re
import dns.resolver
from collections import defaultdict, Counter
import sys
def parse_nginx_log(log_line):
"""Parse nginx access log line to extract IP."""
# Standard nginx log format
pattern = r'^(\S+) - - \[(.*?)\] "(.*?)" (\d+) (\d+) "(.*?)" "(.*?)"'
match = re.match(pattern, log_line)
if match:
return {
"ip": match.group(1),
"timestamp": match.group(2),
"request": match.group(3),
"status": int(match.group(4)),
"size": int(match.group(5)),
}
return None
def get_location(ip):
"""Get location for IP using ResolverOne."""
try:
# Use direct queries for log analysis to ensure reliable batch processing
resolver = dns.resolver.Resolver()
# Resolve rslvr.one A records to get our nameserver IPs
resolver.nameservers = [
str(ip) for ip in dns.resolver.resolve("rslvr.one", "A")
]
result = resolver.resolve(f"{ip}.rslvr.one", "TXT")
response = str(result[0]).strip('"')
parts = response.split("|")
if len(parts) == 7:
return {
"country_code": parts[0],
"country": parts[1],
"continent": parts[2],
}
except:
pass
return None
def analyze_logs(log_file):
"""Analyze access logs for geographic distribution."""
countries = Counter()
continents = Counter()
unique_ips = set()
processed_ips = {}
with open(log_file, "r") as f:
for line_num, line in enumerate(f, 1):
if line_num % 1000 == 0:
print(f"Processed {line_num} lines...", file=sys.stderr)
entry = parse_nginx_log(line.strip())
if not entry:
continue
ip = entry["ip"]
# Skip private IPs
if ip.startswith(("127.", "192.168.", "10.", "172.")):
continue
unique_ips.add(ip)
# Cache location lookups
if ip not in processed_ips:
location = get_location(ip)
processed_ips[ip] = location
location = processed_ips[ip]
if location:
countries[location["country"]] += 1
continents[location["continent"]] += 1
return {
"countries": countries,
"continents": continents,
"unique_ips": len(unique_ips),
"total_requests": line_num,
}
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python3 analyze_logs.py /path/to/access.log")
sys.exit(1)
results = analyze_logs(sys.argv[1])
print(f"\n=== Geographic Analysis ===")
print(f"Total requests: {results['total_requests']}")
print(f"Unique IPs: {results['unique_ips']}")
print(f"\n=== Top Countries ===")
for country, count in results["countries"].most_common(10):
percentage = (count / results["total_requests"]) * 100
print(f"{country:20} {count:8d} ({percentage:5.1f}%)")
print(f"\n=== By Continent ===")
for continent, count in results["continents"].most_common():
percentage = (count / results["total_requests"]) * 100
print(f"{continent:15} {count:8d} ({percentage:5.1f}%)")
Need More Examples?
- Community: Join our Discord
The project is archived, so there are no new examples.