Difference between revisions of "Linode"
From Organic Design wiki
m |
(gotchas) |
||
Line 1: | Line 1: | ||
{{stub}} | {{stub}} | ||
+ | == Linode CLI == | ||
Installing the linode CLI: | Installing the linode CLI: | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 8: | Line 9: | ||
</source> | </source> | ||
− | + | == Linode DNS servers == | |
Example Perl code using LWP to update an A record $HOST.$DOMAIN to $IP: | Example Perl code using LWP to update an A record $HOST.$DOMAIN to $IP: | ||
<source lang="perl"> | <source lang="perl"> | ||
Line 36: | Line 37: | ||
); | ); | ||
</source> | </source> | ||
+ | |||
+ | === Gotchas === | ||
+ | *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 |
Revision as of 18:23, 28 July 2023
Linode CLI
Installing the linode CLI:
pip3 install linode-cli
linode-cli configure --token
linode-cli --json --pretty domains list
Linode DNS servers
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 })
);
Gotchas
- 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