diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3fddda9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dns.config diff --git a/README.md b/README.md new file mode 100644 index 0000000..bc888bd --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Vercel Dynamic DNS + +Script for exposing local server with Vercel DNS. It runs every 15 minutes, checking current IP address and updates DNS records for your domain. + +## Installation + +1. Download +2. Move `dns.config.example` into `dns.config` +3. Edit config +4. Open cron settings `crontab -e` +5. Add this line `*/15 * * * * /home/username/vercel-ddns/dns-sync.sh` diff --git a/dns-sync.sh b/dns-sync.sh new file mode 100755 index 0000000..eea6a45 --- /dev/null +++ b/dns-sync.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +source ./dns.config + +# 1. Get current IP +IP=$(curl -s http://whatismyip.akamai.com/) +echo "$IP" + +# 2. Create/update DNS record +curl -X POST "https://api.vercel.com/v2/domains/$DOMAIN_NAME/records" \ + -H "Authorization: Bearer $VERCEL_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "'$SUBDOMAIN'", + "type": "A", + "value": "'$IP'", + "ttl": 60 +}' + +echo '' +echo "🎉 Done!" diff --git a/dns.config.example b/dns.config.example new file mode 100644 index 0000000..e53e4f9 --- /dev/null +++ b/dns.config.example @@ -0,0 +1,5 @@ +# Get token here https://vercel.com/account/tokens +VERCEL_TOKEN="" + +# Your domain/subdomain +DOMAIN_NAME=""