cznic-resolver-common.yang 12.2 KB
Newer Older
mrazekales's avatar
mrazekales committed
1 2 3 4 5 6 7 8 9 10 11 12
module cznic-resolver-common {

  yang-version "1.1";

  namespace "https://www.nic.cz/ns/yang/resolver-common";

  prefix "drc";

  import ietf-inet-types {
    prefix "inet";
  }

13 14 15 16
  import iana-dns-class-rr-type {
    prefix "dnsct";
  }

Ladislav Lhotka's avatar
Ladislav Lhotka committed
17 18 19 20
  import cznic-dns-rdata {
    prefix "rdata";
  }

mrazekales's avatar
mrazekales committed
21 22 23 24 25 26 27 28 29 30 31
  organization
    "CZ.NIC, z. s. p. o.";

  contact
    "Editor:   Ladislav Lhotka
               <mailto:lhotka@nic.cz>";

  description
    "This YANG module defines the common part of a data model for DNS
     resolvers.";

32
  revision 2018-12-17 {
mrazekales's avatar
mrazekales committed
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    description
      "Initial revision.";
    reference
      "TODO: put git tag here";
  }

  /* Features */

  feature set-group {
    description
      "This feature indicates support for setting the group.";
  }

  /* Typedefs */

  typedef fs-path {
    type string;
    description
      "This type is used for specifying a filesystem path (absolute
       or relative).

       An implementation must check that the string satisfies all
       rules of the underlying operating system.";
  }

  typedef l2-protocol-selection {
    type bits {
      bit ipv4 {
        description
          "Enable/disable IPv4.";
      }
      bit ipv6 {
        description
          "Enable/disable IPv6.";
      }
    }
    default "ipv4 ipv6";
  }

  /* Groupings */

  grouping static-hint {
    description
      "This grouping defines the content of a static hint.";
    leaf name {
      type inet:domain-name;
      description
        "Domain name of a root server.";
    }
    leaf-list values {
      type inet:ip-address-no-zone;
      min-elements "1";
      description
        "One or more IPv4/IPv6 addresses of the root server.";
    }
  }

Ladislav Lhotka's avatar
Ladislav Lhotka committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
  grouping trust-anchor-spec {
    description
      "Specification of a trust anchor.";
    choice trust-anchor-rdata {
      description
        "A trust anchor is specified by a DS or DNSKEY resource
         record data.";
      container ds {
        description
          "A trust anchor defined using DS RDATA.";
        uses rdata:ds;
      }
      container dnskey {
        description
          "A trust anchor defined using DS RDATA.";
        uses rdata:dnskey;
      }
    }
  }

mrazekales's avatar
mrazekales committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
  /* Data definitions */

  container dns-resolver {
    description
      "DNS resolver parameters.";
    container server {
      description
        "Parameters of the resolver process.";
      leaf user-name {
        type string;
        description
          "After binding the network socket, drop the privileges and
           run with effective user ID of this user.";
      }
      leaf group-name {
        if-feature "set-group";
        type string;
        description
          "After binding the network socket, drop the privileges and
           run with effective group ID of this group.";
      }
    }
    container network {
      description
        "Network connection parameters.";
      list listen-interfaces {
        key "name";
        unique "ip-address port";
        description
          "Inet sockets to use for listening to queries.";
        leaf name {
          type string;
          description
            "Arbitrary name of the listening socket.";
        }
        leaf ip-address {
          type inet:ip-address;
          mandatory "true";
          description
            "IPv4 or IPv6 address.";
        }
        leaf port {
          type inet:port-number;
          default "53";
          description
            "Port number.";
        }
      }
      container source-address {
        leaf ipv4 {
          type inet:ipv4-address-no-zone;
          description
            "IPv4 address to use as the source address in outgoing
             queries.

             If not configured, the resolver uses any address
             provided by the operationg system.";
        }
        leaf ipv6 {
          type inet:ipv6-address-no-zone;
          description
            "IPv6 address to use as the source address in outgoing
             queries.

             If not configured, the resolver uses any address
             provided by the operationg system.";
        }
      }
      container client-transport {
        description
          "Specify L2 and L3 protocols used for receiving and
           answering client queries.";
        leaf l2-protocols {
          type l2-protocol-selection;
          description
            "L2 protocols used for receiving and answering client
             queries.";
        }
      }
      container recursion-transport {
        description
          "Specify L2 and L3 protocols used for recursive queries.";
        leaf l2-protocols {
          type l2-protocol-selection;
          description
            "L2 protocols used for recursive queries.";
        }
      }
      leaf udp-payload-size {
        type uint16 {
          range "512..max";
        }
        units "octets";
        default "4096";
        description
          "Largest UDP payload that the resolver can accept.

           This value is advertized in EDNS0.";
        reference
          "RFC 2671: Extension Mechanisms for DNS (EDNS0)";
      }
    }
    container resolver {
      description
        "Parameters affecting operation of the DNS resolver.";
      list stub-zones {
        key "domain";
        description
          "List of stub zones.";
        leaf domain {
          type inet:domain-name;
          description
            "Name of the stub zone.";
        }
        leaf nameserver {
          type inet:host;
          description
            "Name or IP address of the stub zone nameserver.";
        }
        leaf port {
          type inet:port-number;
          default "53";
          description
            "Port number to use for communicating with the stub zone
             nameserver.";
        }
      }
      container hints {
        description
          "Configuration of static hints.";
        list root-hint {
          key "name";
          description
            "Each entry contains hints for one root server.

             Records configured this way override the resolver
             defaults and records set via 'root-zone-file'.

             Root hints are used if and only if the root servers
             cannot be resolved from the cache.";
          uses static-hint;
        }
        leaf root-zone-file {
          type fs-path;
          description
            "Path to a root zone file.

             It is used only if root servers cannot be resolved the
             cache and no root hints are set via 'root-hint'.";
        }
      }
      container options {
        description
          "Fine-tuning parameters of resolver operation.";
        leaf glue-checking {
265 266
          type boolean;
          default "true";
mrazekales's avatar
mrazekales committed
267
          description
268 269
            "If true, the resolver will only trust glue records that
             are within the responding server's authority.";
mrazekales's avatar
mrazekales committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
        }
        leaf qname-minimisation {
          type boolean;
          description
            "Send minimum amount of information in recursive queries
             to enhance privacy.";
        }
        leaf query-loopback {
          type boolean;
          default "true";
          description
            "This flag permits queries to loopback addresses (prefix
             127.0.0.0/8 for IPv4 and ::1/128 for IPv6).";
        }
        leaf reorder-rrset {
          type boolean;
          default "false";
          description
            "Controls whether resource records within a RRSet are
             reordered each time it is served from the cache.";
        }
      }
    }
    container logging {
      description
        "Logging parameters.";
      leaf verbosity {
        type uint8 {
          range "0..5";
        }
        default "1";
        description
          "Verbosity level.";
      }
    }
    container dnssec {
      presence "Enable DNSSEC";
      description
        "DNSSEC parameters";
Ladislav Lhotka's avatar
Ladislav Lhotka committed
309 310
      list trust-anchors {
        key "domain";
mrazekales's avatar
mrazekales committed
311
        description
Ladislav Lhotka's avatar
Ladislav Lhotka committed
312 313 314
          "Per-domain DNSSEC trust anchors.";
        leaf domain {
          type inet:domain-name;
mrazekales's avatar
mrazekales committed
315
          description
Ladislav Lhotka's avatar
Ladislav Lhotka committed
316 317 318 319
            "The domain to which the trust anchors belong.";
        }
        leaf key-file {
          type fs-path;
320
          config "false";
Ladislav Lhotka's avatar
Ladislav Lhotka committed
321
          description
322 323 324
            "Name of the file that for storing trust anchors and
             updating them via the update procedure specified in RFC
             5011.";
Ladislav Lhotka's avatar
Ladislav Lhotka committed
325 326 327 328 329 330 331 332 333 334
        }
        leaf auto-update {
          type boolean;
          default "true";
          description
            "Setting this flag to false blocks updates according to
             RFC 5011 for the domain. By default, the updates are
             enabled.";
        }
        list trust-anchor {
335
          key "id";
336
          min-elements "1";
Ladislav Lhotka's avatar
Ladislav Lhotka committed
337
          description
338 339
            "List of trust anchors.

340 341 342 343 344 345 346 347 348 349 350 351 352
             In a configuration datastore, the semantics of this list
             depends on the setting of the 'auto-update' flag in the
             following way:

             - If 'auto-update' is true (the default), this list
               specifies the initial set of trust anchors for the
               domain that is used when the server starts. Later on,
               this list, and any updates to it, are ignored.

             - If 'auto-update' is false, this list configures the
               trust anchors to be used for the domain, and
               subsequent changes to this list shall be taken into
               account.
353

354
             In the operational datastore, this list contains trust
355
             anchors that are currently used by the resolver for the
Ladislav Lhotka's avatar
Ladislav Lhotka committed
356
             domain.";
357 358 359 360
          leaf id {
            type uint8;
            description
              "Opaque numeric ID of the trust anchor.";
361
          }
362
          uses trust-anchor-spec;
Ladislav Lhotka's avatar
Ladislav Lhotka committed
363 364 365
        }
        action add-trust-anchor {
          description
366
            "Install a trust anchor.
Ladislav Lhotka's avatar
Ladislav Lhotka committed
367

368 369
             The resolver shall add this item to the existing trust
             anchors for the domain.";
Ladislav Lhotka's avatar
Ladislav Lhotka committed
370 371
          input {
            uses trust-anchor-spec;
mrazekales's avatar
mrazekales committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
          }
        }
      }
      leaf-list negative-trust-anchors {
        type inet:domain-name;
        description
          "List of domain names representing negative trust
           anchors.";
        reference
          "RFC 7646: Definition and Use of DNSSEC Negative Trust
           Anchors.";
      }
    }
    container cache {
      description
        "Parameters of the resolver cache.";
      leaf max-size {
        type uint64;
        units "bytes";
        description
          "Maximum size of the cache.";
      }
      leaf current-size {
        type uint64;
        units "bytes";
        config "false";
        description
          "Current size of the cache.";
      }
      leaf max-ttl {
        type uint32;
        units "seconds";
        default "172800";
        description
          "Maximum time-to-live for cache entries.

           This value overrides the original TTL specified for the
           particular resource record if the latter is greater.";
      }
      leaf min-ttl {
        type uint32;
        units "seconds";
        must ". <= ../max-ttl" {
          error-message
            "'min-ttl' must not be higher than 'max-ttl'";
        }
        default "0";
        description
          "Minimum time-to-live for cache entries.

           This value overrides the original TTL specified for the
           particular resource record if the latter is smaller.";
      }
    }
    container dns64 {
      presence "enable DNS64 functionality";
      leaf prefix {
        type inet:ipv6-prefix;
        default "64:ff9b::/96";
        description
          "The DNS64 prefix to be used for synthesizing AAAA records.

           The prefix must be /96 or shorter.";
      }
    }
437 438 439 440
    container debugging {
      description
        "Configuration of debugging functions.";
    }
mrazekales's avatar
mrazekales committed
441
  }
442 443 444 445 446 447 448 449 450 451 452 453 454 455

  /* Operations */

  rpc resolve {
    description
      "Query the resolver and return the result.";
    input {
      leaf name {
        type inet:domain-name;
        mandatory "true";
        description
          "Query name.";
      }
      leaf type {
456
        type dnsct:rr-type;
457 458 459 460 461 462 463 464 465 466 467 468
        mandatory "true";
        description
          "Query type.";
      }
      leaf class {
        type dnsct:dns-class;
        default "IN";
        description
          "Query class.";
      }
    }
  }
mrazekales's avatar
mrazekales committed
469
}