If you use AWS and you need to update the Route53 from the CLI there are a few methods.
You can use cli53 tool from github or aws route53 CLI commands. In this post we will use aws route53.
With aws route53 you can provide the info via a JSON file than can be inline or standalone.
In order to see the available zones for your account, use this command:
aws route53 list-hosted-zones
The “Id”: “/hostedzone/Z1XXXXXXXXXXXX” contains the ID we need further, starting with Z1 in our case.
First method, use inline JSON:
For A record:
$ZONE : “Z1XXXXXXXXXXXX”
$LOCAL_HOSTNAME : “myserver.evilbox.local”
$TTL : 300
$LOCAL_IPV4 : 192.168.10.100
aws route53 change-resource-record-sets --hosted-zone-id $ZONE --change-batch '{"Changes":[{"Action":"UPSERT","ResourceRecordSet":{"Name":"'"$LOCAL_HOSTNAME"'","Type":"A","TTL":'"$TTL"',"ResourceRecords":[{"Value":"'"$LOCAL_IPV4"'"}]}}]}'
For PTR record:
$ZONEPTR : “Z2YYYYYYYYYYY”
$PTR_NAME : “100.10.168.192.in-addr.arpa”
$TTL : 300
$PTR_VALUE : “myserver.evilbox.local.”
Note the dot at the end of $PTR_VALUE.
aws route53 change-resource-record-sets --hosted-zone-id $ZONEPTR --change-batch '{"Changes":[{"Action":"UPSERT","ResourceRecordSet":{"Name":"'"$PTR_NAME"'","Type":"PTR","TTL":'"$TTL"',"ResourceRecords":[{"Value":"'"$PTR_VALUE"'"}]}}]}'
The second method uses a JSON file.
For A record create a JSON file named update-dns.json :
{
"Comment": "ADD A record",
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "myserver.evilbox.local",
"Type": "A",
"TTL": 300,
"ResourceRecords": [{ "Value": "192.168.10.100"}]
}}]
}
Apply the command:
$ZONE : “Z1XXXXXXXXXXXX”
aws route53 change-resource-record-sets --hosted-zone-id $ZONE --change-batch file://update-dns.json
For A record create a JSON file named update-ptr.json :
{
"Comment": "ADD PTR record ",
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "100.10.168.192.in-addr.arpa",
"Type": "PTR",
"TTL": 300,
"ResourceRecords": [{"Value": "myserver.evilbox.local."}]
}}]
}
Not the dot at the end of the “Value” parameter : myserver.evilbox.local.
https://anuragbhatia.com/2012/01/dns/understanding-dot-in-the-end-of-hostname/
Apply the command:
$ZONEPTR : “Z2YYYYYYYYYYY”
aws route53 change-resource-record-sets --hosted-zone-id $ZONEPTR --change-batch file://update-ptr.json