10. Command line

The program kudurru is the server and the command line client in one file. This chapter shows how to connect the client to a server and lists the commands that you use most.

Before you start:

  • You have the kudurru program. It is in the container image and in the Linux packages. You can also download it from a release.
  • You have a token (Chapter 9) or the password of an account.

Two kinds of command

KindWhere it runsExamples
Client commandsOn any computer. They use the API of a server.get, apply, lists, logs, query, settings
Host commandsOn the host of the node. They read the local files or the local socket.serve, doctor, health, admin

In Docker, run a host command with docker exec:

docker exec kudurru kudurru health --ready

Connect to a server

A context holds the address of a server and a token. Use login to make one.

  1. Sign in with a password:

    kudurru login --server https://dns.example.net:8080 --username admin
    

    Enter the password when the command asks for it. The command makes a token for the command line and stores it.

  2. Or use a token that you made in the dashboard:

    kudurru login --server https://dns.example.net:8080 --token-stdin < token.txt
    
  3. Test the connection:

    kudurru nodes
    

The command stores the token in the keyring of your system. If there is no keyring, it stores the token in a file that only you can read. To skip the keyring, set KUDURRU_KEYRING=file.

NOTE: The default certificate of kudurru is self-signed. Use --ca-file with the certificate to trust it. For a test only, use --insecure-skip-tls-verify. Do not use this option in production.

Use more than one server

TaskCommand
List the contextskudurru config get-contexts
Show the current contextkudurru config current-context
Change the contextkudurru config use-context <name>
Use a context for one commandkudurru --context <name> nodes
Delete a contextkudurru config delete-context <name>

Output formats

Use -o to select the format: table (default), wide, json, yaml or name. Use -n <namespace> to select a namespace. The default namespace is default.

Common tasks

TaskCommand
Show if blocking is onkudurru blocking status
Turn blocking off for 5 minuteskudurru blocking disable 5m
Turn blocking onkudurru blocking enable
Show the queries of a clientkudurru logs --client 192.168.1.23 --limit 100
Show the blocked querieskudurru logs --status-class blocked
Follow new querieskudurru logs --follow
Test a namekudurru query example.com
Test a name for another clientkudurru query ads.example.net AAAA --client 192.168.1.23
Show the statistics of 24 hourskudurru stats summary
Show the top blocked nameskudurru stats top --dim domains --blocked
Remove the cachekudurru cache flush
Show the nodeskudurru nodes
Show the audit logkudurru audit --since 24h
Show the settingskudurru settings get
Change a settingkudurru settings set cache.maxEntries=200000
Set a setting to its defaultkudurru settings set log.level-

You cannot change a setting with the label host only with settings set. Change it in kudurru.yaml.

Work with objects

Zones, record sets, block lists, client groups and policies are objects. The command line uses the same YAML as Kubernetes.

TaskCommand
List objects of a kindkudurru get policies
Show one object as YAMLkudurru get policy kids -o yaml
Show the state and the messages of an objectkudurru describe policy kids
Create or change objectskudurru apply -f policy.yaml
Create or change all files in a directorykudurru apply -f objects.d/ -R
Delete an objectkudurru delete policy kids
Print all objects as YAMLkudurru export

The kinds and their short names are:

KindShort names
dnszoneszone, zones
dnsrecordsetsrrset, rrsets
blocklistslist, lists, bl
clientgroupscg
policiespol, policy

Example

This file makes a client group and a policy for it:

apiVersion: kudurru.io/v1alpha1
kind: ClientGroup
metadata:
  name: kids
  namespace: default
spec:
  clients:
    - cidr: 10.0.20.0/24
      name: Kids VLAN
---
apiVersion: kudurru.io/v1alpha1
kind: Policy
metadata:
  name: kids
  namespace: default
spec:
  clientGroupRefs: [kids]
  blockListRefs: [starter]
  priority: 10

Apply it:

kudurru apply -f kids.yaml

The dashboard then shows the objects with the owner API. The folder config/samples/ has more examples.

NOTE: kudurru apply refuses an object that a file or Kubernetes owns. The error says managed_by and names the owner.

Back up and restore objects

TaskCommand
Save all objects to a filekudurru backup --out objects.yaml
Save without secrets in URLskudurru backup --out objects.yaml --safe
Load the objects againkudurru restore -f objects.yaml

Chapter 11 explains what a backup holds.

Other commands

CommandUse
kudurru doctorCheck the configuration, the ports and the API on the host
kudurru health --readyCheck that a node is ready (for example in a container health check)
kudurru config schemaList all settings with their scope and flags
kudurru config showShow the effective configuration
kudurru completion <shell>Print a script for shell completion
kudurru versionShow the version

Use kudurru <command> --help for the options of each command. The command reference has all of them.

Source: docs/guide/admin/10-command-line.md