300-420 · Question #334
A network engineer prepares a script to configure a loopback interface with IP address 172.16.15.12/32. To comply with the company security policies, 'Content-type': 'application/yang- data+json' is a
The correct answer is D. "ietf-interfaces:interface": { "name": "Loopback0", "type": "iana-if-type:softwareLoopback", "enabled": true, "address_ipv4": { "ip": "172.16.15.12", "netmask": "255.255.255.255" }, "ietf-ip:ipv6": { } }. To configure a loopback interface with an IPv4 address using YANG data in JSON format, the engineer must use the ietf-interfaces:interface container, define address_ipv4 as a single object, and specify the /32 netmask as 255.255.255.255.
Question
A network engineer prepares a script to configure a loopback interface with IP address 172.16.15.12/32. To comply with the company security policies, 'Content-type': 'application/yang- data+json' is added to the script. Connection to the network devices must be secured. Which code snippet must the network engineer use to meet this requirement? A. B. C. D.
Options
- A"ietf-interfaces:interface": { "name": "Loopback0", "type": "iana-if-type:softwareLoopback", "enabled": true, "address_ipv4": [ { "ip": "172.16.15.12", "netmask": "255.255.255.255" } ], "address_ipv6": [null] }
- B"interface": "ietf-loopback" { "name": "Loopback0", "enabled": true, "address": "ipv4" [ { "ip": "172.16.15.12", "netmask": "255.255.255.255" } ], "address_ipv6": { } }
- C"ietf-interfaces:interface": { "name": "Loopback0", "type": "iana-if-type:softwareLoopback", "enabled": true, "address_ipv4": [ { "ip": "172.16.15.12", "netmask": "0.0.0.0" } ], "address_ipv6": { } }
- D"ietf-interfaces:interface": { "name": "Loopback0", "type": "iana-if-type:softwareLoopback", "enabled": true, "address_ipv4": { "ip": "172.16.15.12", "netmask": "255.255.255.255" }, "ietf-ip:ipv6": { } }
How the community answered
(19 responses)- A16% (3)
- B26% (5)
- C5% (1)
- D53% (10)
Why each option
To configure a loopback interface with an IPv4 address using YANG data in JSON format, the engineer must use the `ietf-interfaces:interface` container, define `address_ipv4` as a single object, and specify the `/32` netmask as `255.255.255.255`.
The `address_ipv4` is defined as an array `[...]` containing an object, which is not the standard or most common representation in `ietf-ip` for a single IPv4 address on an interface; it should typically be a single object. Also, `address_ipv6` is an array containing `null`, which is an unconventional and potentially incorrect way to indicate no IPv6 address.
The root element `interface` without a namespace and `ietf-loopback` as a separate key are syntactically incorrect for standard YANG-to-JSON mapping. The `address` key with 'ipv4' and an array `[...]` is also non-standard.
The `netmask` `0.0.0.0` is incorrect for a `/32` IP address; a `/32` netmask is `255.255.255.255`. Using `0.0.0.0` would imply a default route or a different subnet.
This snippet correctly uses the `ietf-interfaces:interface` container and sets the interface name, type, and enabled status. Crucially, for IPv4, it uses `address_ipv4` as a single JSON object (not an array) to define the IP address and specifies the `netmask` as `255.255.255.255`, which correctly represents a /32 subnet as required by the `ietf-ip` YANG module for IPv4 interface configuration. The `ietf-ip:ipv6` container is correctly included as an empty object for IPv6 configuration.
Concept tested: YANG data models, JSON for network configuration, IETF interfaces and IP modules
Source: https://datatracker.ietf.org/doc/html/rfc7223
Topics
Community Discussion
No community discussion yet for this question.