Understanding Custom Domains and DNS
Custom domains give your self-hosted services professional URLs instead of IP addresses. This guide covers getting free subdomains and configuring them properly.
Free Subdomain Options
Option 1: FreeDNS (Afraid.org)
Advantages:
- Hundreds of domains to choose from
- Built-in DDNS support
- Completely free
- No ads
Setup Steps:
- Visit FreeDNS
- Create a free account
- Go to Subdomains > Add
- Choose from available domains (e.g.,
yourname.mooo.com) - Enter your VPS IP address
- Save
Option 2: DuckDNS
Advantages:
- Simple setup
- Great DDNS client
- Clean interface
Setup:
- Visit DuckDNS
- Sign in with any social account
- Choose a subdomain (e.g.,
yourname.duckdns.org) - Add your VPS IP
Option 3: No-IP
Advantages:
- Reliable service
- Good documentation
- Mobile apps available
Setup:
- Visit No-IP
- Create free account
- Create hostname
- Install DDNS client (optional)
Configuring DNS Records
Basic A Record
Points your domain to an IP address:
Type: A
Name: @ (or subdomain)
Value: 123.456.78.90
TTL: 3600
CNAME Record
Creates an alias to another domain:
Type: CNAME
Name: www
Value: @
TTL: 3600
Using Cloudflare with Free Domains
Even with free subdomains, you can proxy through Cloudflare:
Step 1: Add Domain to Cloudflare
- Log into Cloudflare
- Add your domain
- Get Cloudflare nameservers
Step 2: Update Nameservers
At your domain provider:
- Find DNS settings
- Replace nameservers with Cloudflare’s
- Wait 24-48 hours for propagation
Step 3: Configure Records
Type: A
Name: @
IPv4: Your VPS IP
Proxy: Enabled (orange cloud)
Benefits:
- Free SSL certificates
- DDoS protection
- CDN caching
- Analytics
Setting Up DDNS (Dynamic DNS)
If your VPS IP changes, use DDNS to auto-update:
Install ddclient
sudo apt install ddclient -y
Configure for FreeDNS
Edit /etc/ddclient.conf:
protocol=dyndns2
use=web
server=freedns.afraid.org
login=your-username
password=your-password
yoursubdomain.mooo.com
Configure for Cloudflare
protocol=cloudflare
use=web
server=api.cloudflare.com/client/v4
login=token
password=your-api-token
zone=yourdomain.com
yourdomain.com
Test and Enable
# Test configuration
sudo ddclient -daemon=0 -debug -verbose -noquiet
# Enable service
sudo systemctl enable ddclient
sudo systemctl start ddclient
# Check status
sudo systemctl status ddclient
SSL Certificates with Let’s Encrypt
Install Certbot
sudo apt install certbot python3-certbot-nginx -y
Generate Certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Auto-Renewal
Certbot automatically sets up renewal. Test it:
sudo certbot renew --dry-run
Multiple Subdomains
Host multiple services with subdomains:
blog.yourdomain.com → 10.0.0.2:3456
api.yourdomain.com → 10.0.0.2:3457
app.yourdomain.com → 10.0.0.2:3458
NGINX Configuration
Create separate configs for each:
# /etc/nginx/sites-available/blog
server {
listen 443 ssl;
server_name blog.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
location / {
proxy_pass http://10.0.0.2:3456;
proxy_set_header Host $host;
}
}
Troubleshooting
Domain not resolving
- Check DNS propagation:
nslookup yourdomain.com - Wait up to 48 hours for changes
- Clear DNS cache:
ipconfig /flushdns(Windows) orsudo systemd-resolve --flush-caches(Linux)
SSL certificate errors
- Ensure domain points to correct IP
- Check firewall allows port 80 (for verification)
- Verify NGINX is running
DDNS not updating
- Check ddclient logs:
sudo journalctl -u ddclient -f - Verify credentials
- Test API access manually
Best Practices
- Use Cloudflare proxy for added security
- Enable automatic SSL renewal
- Set up monitoring for domain availability
- Keep DDNS credentials secure
- Use separate subdomains for different services
- Document your DNS configuration
Conclusion
With free subdomains and proper DNS configuration, you can give your self-hosted services professional URLs without spending money on domains. Combined with SSL certificates and DDNS, you have a robust, production-ready setup.