DNSControl Setup

exported directly from my Logseq graph cuz I’m lazy.

  • Setting up DNSControl
    • Referrences
    • Troubleshooting
      • Complained on Fedi
    • Setup
      • Install DNSControl
        • via Homebrew, on macOS
          brew install StackExchange/tap/dnscontrol
          
        • download pre-built binary see releases
      • Set up Git repository for configuration files
        • mkdir dns && cd dns
        • git init
        • nvim creds.json
          • For Cloudflare credentials
            {
              "cloudflare": {
                "TYPE": "CLOUDFLAREAPI",
                "accountid": "$CLOUDFLARE_ACCOUNT_ID",
                "apitoken": "$CLOUDFLARE_API_TOKEN"
              }
            }
            
          • It can read from enviroment variables, as long as it start with a $
        • nvim dnsconfig.js
          • Don’t type dnscontrol.js… I made that mistake
          • Set up registrar (none is OK) and DNS provider (Cloudflare in this case)
            var REG_NONE = NewRegistrar("none");
            var DSP_CLOUDFLARE = NewDnsProvider('cloudflare');
            
          • Use D() to add domain.
            D("example.com", REG_NONE, DSP_CLOUDFLARE, ...)
            
      • Get existing DNS records in JavaScript
        • use dnscontrol get-zone
          dnscontrol get-zone --format=js -out=draft.js "cloudflare" "CLOUDFLAREAPI" "geedea.pro"
          dnscontrol get-zone --format=js -out=draft.js "cloudflare" "CLOUDFLAREAPI" "eltr.ac"
          
        • copy the content from draft.js to dnsconfig.js, and modify it correctly
      • Preview and push
        • dnscontrol preview
        • dnscontrol push
      • Set up automatic workflow (with Forgejo Action)
          name: Push
        
          on:
            push:
              branches:
                - master
        
          jobs:
            push:
              runs-on: docker
              steps:
                - uses: actions/checkout@v3
                - name: Install and Push
                  env:
                    CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
                    CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
                  run: |
                    curl -sL https://github.com/StackExchange/dnscontrol/releases/download/v4.36.1/dnscontrol_4.36.1_linux_amd64.tar.gz | tar xz
        
                    ./dnscontrol push
        
Tags: