New ISP doesn't offer static IPs

I’ll be moving to a new house soon that has direct fibre (FTTP). However, there’s only one ISP and they don’t offer static IPv4 or IPv6 addresses to residential customers (crazy). I run a couple of hobby websites and wondering what solutions there are or will I have to bite the bullet and pay for cloud hosting? Ideally, there would be some workaround to use dynamic IP with Cloudflare but I can’t find anything.

One way is to use DNS-O-Matic

Otherwise with the API:
With the API you can actually update records on the fly. I have used this quite a lot with GCP (Google cloud) to update my DNS records for a Minecraft server and one for my website.

DNS record information
#/usr/bin/env sh
#Script to fetch your CF "dynamic" A-record ID
#You need the Zone ID, Authorization key and A-record ID for your domain.
#Fetch the first two from your CF account.
#Create the A-record in CF named “dynamic”.
#Create the CNAME alias (example.com --> dynamic.example.com 1)
#Fetch The A-record ID:

curl -X GET "https://api.cloudflare.com/client/v4/zones/[ZONE ID]/dns_records" \
     -H "Host: api.cloudflare.com" \
     -H "User-Agent: ddclient/3.9.0" \
     -H "Connection: close" \
     -H "X-Auth-Email: [EMAIL]" \
     -H "X-Auth-Key: [AUTHKEY]" \
     -H "Content-Type: application/json"```

Send this to a text document and you can fine the right details for the below script:

DNS record update
#/usr/bin/env sh

AUTH_EMAIL=[EMAIL]
AUTH_KEY=[AUTHKEY]
ZONE_ID=[ZONE ID]
A_RECORD_NAME="[RECORD NAME]"
A_RECORD_ID=[RECORD ID]

# Retrieve the last recorded public IP address
IP_RECORD="/tmp/ip-record"
RECORDED_IP=`cat $IP_RECORD`

# Fetch the current public IP address
PUBLIC_IP=$(curl --silent https://api.ipify.org) || exit 1

#If the public ip has not changed, nothing needs to be done, exit.
if [ "$PUBLIC_IP" = "$RECORDED_IP" ]; then
    exit 0
fi

# Otherwise, your Internet provider changed your public IP again.
# Record the new public IP address locally
echo $PUBLIC_IP > $IP_RECORD

# Record the new public IP address on Cloudflare using API v4
RECORD=$(cat <<EOF
{ "type": "A",
  "name": "$A_RECORD_NAME",
  "content": "$PUBLIC_IP",
  "ttl": 180,
  "proxied": false }
EOF
)
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$A_RECORD_ID" \
     -X PUT \
     -H "Content-Type: application/json" \
     -H "X-Auth-Email: $AUTH_EMAIL" \
     -H "X-Auth-Key: $AUTH_KEY" \
     -d "$RECORD"

I run this automatically on startup of the GCP machine and it will update the DNS records automatically.

One small issue, I know that a while back it consistently failed to update due to API limits.

The best bet is the API directly or ddclient which supports Cloudflare.

Yea that is why I included those scripts below it, I had no luck with DNS-O-Matic either but it is an easy way of doing it if it works.

1 Like

For myself I implemented DynDNS on Workers, to allow for easier implementation in routers/modems. Easier than having a Linux server running everywhere…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.