Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-medvedev committed Jan 17, 2021
0 parents commit a154ee3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dns.config
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
21 changes: 21 additions & 0 deletions dns-sync.sh
Original file line number Diff line number Diff line change
@@ -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!"
5 changes: 5 additions & 0 deletions dns.config.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Get token here https://vercel.com/account/tokens
VERCEL_TOKEN=""

# Your domain/subdomain
DOMAIN_NAME=""

0 comments on commit a154ee3

Please sign in to comment.