CLI tool for manipulating DNS of CloudFlare hosted domains. This tool uses CloudFlare's v4 API to add, remove, list, or modify DNS records.
Install using pip
.
$ pip install cfdns
optional arguments:
-h, --help show this help message and exit
-v, --verbose Enable verbosity
Actions:
{add,remove,modify,list}
add Add DNS Records
remove Remove DNS records
modify Modify existing records
list List existing records
List DNS records or a set of DNS records by calling the list
action.
Syntax:
$ cfdns list <email> <api_key> <domain>
Additional arguments:
--name
- Match records with the specified name--type
- Match records with the specified type A, AAAA, CNAME, or MX--content
- Match records with the specified content
Examples:
$ cfdns list email@example.com 12345api
$ cfdns list email@example.com 12345api --name www.example.com
$ cfdns list email@example.com 12345api --name www.example.com --type A
$ cfdns list email@example.com 12345api --name www.example.com --type A --content 10.0.0.1
$ cfdns list email@example.com 12345api --type A
$ cfdns list email@example.com 12345api --type A --content 10.0.0.1
$ cfdns list email@example.com 12345api --content 10.0.0.1
Add DNS records with the add
action.
Syntax:
$ cfdns add <email> <api_key> <domain> <record_name> <record_type> <record_content>
Supported record types are: A
, AAAA
, CNAME
, & MX
Additional Arguments:
--ttl
- Specify the TTL value (default: 0)--noproxy
- Disable CloudFlare's proxying
Examples:
$ cfdns add email@example.com 12345api example.com www.example.com A 10.0.0.1
$ cfdns add email@example.com 12345api example.com www.example.com A 10.0.0.1 --ttl 20
$ cfdns add email@example.com 12345api example.com www.example.com A 10.0.0.1 --noproxy
Remove one or more DNS records with the remove
action.
Syntax:
$ cfdns remove <email> <api_key> <domain> --name <record_name> --content <record_content>
The --name
or --content
flags can be used together or on their own to limit the number of records to be deleted. At least one flag must be used or no records will be deleted.
--name
- Match records with a specified name--content
- Match records with a specified content
Examples:
$ cfdns remove email@example.com 12345api example.com --name test.example.com --content 10.0.0.1
$ cfdns remove email@example.com 12345api example.com --name test.example.com
$ cfdns remove email@example.com 12345api example.com --content 10.0.0.1
Modify DNS records using the modify
action.
Syntax:
$ cfdns modify <email> <api_key> <domain> <old_record_content> <new_record_type> <new_record_content>
You can add the --name
flag to restrict updates to only the named record. By default all records with the matching "old content" will be updated.
Examples:
$ cfdns modify email email@example.com 12345api example.com 10.0.0.1 A 10.0.0.2
$ cfdns modify email email@example.com 12345api example.com 10.0.0.1 A 10.0.0.2 --name www.example.com