Re:I wish my web server were in the corner of my room
by aembleton on Wednesday October 12, 2022 @04:39AM
(#33174408)
I have a cron that updates the DNS entries on Cloudflare with my current IP address. This runs every five minutes.
[ Parent
| on HN ]
Re:I wish my web server were in the corner of my room
by BatteryMountain on Wednesday October 12, 2022 @05:15AM
(#33174596)
Mind sharing your script? Just want to compare :)
Re:I wish my web server were in the corner of my room
by aembleton on Wednesday October 12, 2022 @06:38AM
(#33175059)
This is to update a record named jellyfin. Its a python script.
import json
import requests
IP_API = 'https://api.ipify.org?format=json'
CF_API_KEY = # Cloudflare API Key
CF_EMAIL = # Cloudflare email address
ZONE_ID = # Zone ID
RECORD_ID = # Record ID for this DNS entry
resp = requests.get(IP_API)
ip = resp.json()['ip']
resp = requests.put(
'https://api.cloudflare.com/client/v4/zones/{}/dns_records/{}'.format(
ZONE_ID, RECORD_ID),
json={
'type': 'A',
'name': 'jellyfin',
'content': ip,
'proxied': False
},
headers={
'X-Auth-Key': CF_API_KEY,
'X-Auth-Email': CF_EMAIL
})