Linode
From Organic Design wiki
Contents
Linode CLI
Installing the linode CLI:
pip3 install linode-cli
linode-cli configure --token
linode-cli --json --pretty domains list
Linode DNS servers
As of mid 2023, we're using Linode as our DNS server rather than using the one provided by the name's registrar. The move was made because we wanted to be able to manage domain records via API so that we could take use the DNS-01 validation method for our SSL certs. But it also means we can mane them all from one place, interact with them programmatically and later AI will be able to interact with them much more naturally. They can also be moved to other DNS providers like digital ocean using automated procedures too.
Using the API to manage your domains
Here's an example Perl code using LWP to update an A record $HOST.$DOMAIN to $IP:
# Set up a user agent with our token as default header
$ua = LWP::UserAgent->new();
$ua->default_header(
'Content-Type' => "application/json",
'Authorization' => "Bearer $API_KEY"
);
# Find the ID for $DOMAIN
$domains = $ua->get( 'https://api.linode.com/v4/domains' )->content;
for ( @{ decode_json( $domains )->{data} } ) {
$domain_id = $_->{id} if $_->{domain} eq $DOMAIN;
}
# Find the ID of the A record having the name $HOST
$records = $ua->get( "https://api.linode.com/v4/domains/$domain_id/records" )->content;
for ( @{ decode_json( $records )->{data} } ) {
$record_id = $_->{id} if $_->{name} eq $HOST;
}
# Update the A record to $IP
$ua->put(
"https://api.linode.com/v4/domains/$domain_id/records/$record_id",
'Content' => encode_json({ 'target' => $IP })
);
Useful DNS patterns
- Dynamic DNS (done)
- Replace IPs across all domains/records
- Delete records matching a pattern
- Add (if not exists) a group of records (e.g. mail and SPF records) across a set of domains
Gotchas
- You must have at least one active compute instance on your account for domain records to be served
- For some reason the "@" host is not allowed in the TXT record form, you have to use the naked domain in the host field which ends up as "@" in the zone file