blob: 1c7049595d2503fe2d6d14cfea4df4ad70e9206b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# Namecheap CLI
A quick script to list/add/remove/update DNS records for a Namecheap managed domain. It does not use any non-standard Go libraries.
## Why
At the time of writing, there is no simple way to add DNS records for my Namecheap domain from the cli, since strictly "adding" is not supported. Instead, we have to first get all the current records and include the new one as part of the [setHosts](https://www.namecheap.com/support/api/methods/domains-dns/set-hosts/) method. This would involve a bunch of XML parsing which is beyond my bash-fu.
## Pre-Requisites
You must setup an API Access Key, and whitelist your access IP. Follow instructions for [Enabling API Access](https://www.namecheap.com/support/api/intro/).
## Usage
Available sub-commands:
* `list`: show all DNS records currently configured.
* `add`: add a DNS record.
* `update`: update an existing DNS record.
* `remove`: remove existing DNS record(s). You will be prompted for which record(s) you want to remove.
### Docker
```bash
docker run --rm -it --name nctest \
-e API_USER="[ your namecheap user ]"
-e API_KEY="[ your namecheap api access key ]"
-e ACCESS_IP="[ your namecheap api whitelisted IP ]"
-e DOMAIN_MAIN="[ your namecheap managed domain ]"
-e DOMAIN_END="[ your namecheap managed domain's ending (net, or com, or xyz etc.) ]"
registry.gitlab.com/kdam0/nccli:[your architecture]
/bin/nccli add -h
```
Outputs:
```bash
Usage of add:
-name string
Name of DNS record.
-priority int
Value of the DNS record.
-ttl int
TTL of the DNS record. (default 1800)
-type string
Type of DNS record.
-v Verbosity. More output. Default=false.
-value string
Value of the DNS record.
```
Images are available for the following architectures:
* linux/amd64
* linux/arm32v7
### Non-Docker
1. Create `nccli.env` file with content:
```bash
API_USER="[ your namecheap user ]"
API_KEY="[ your namecheap api access key ]"
ACCESS_IP="[ your namecheap api whitelisted IP ]"
DOMAIN_MAIN="[ your namecheap managed domain ]"
DOMAIN_END="[ your namecheap managed domain's ending (net, or com, or xyz etc.) ]"
```
2. Build:
```bash
go build nccli.go
```
3. Activate env:
```bash
source nccli.env
```
4. Run:
```bash
./nccli -h
```
|