DNS Management
This section describes the configuration model of DNS and provides examples of XML packets.
Data Model
The configuration model files matching DNS are ietf-system.yang and huawei-dns.yang.
Object |
Description |
Value |
Remarks |
---|---|---|---|
/ietf-system:system/dns-resolver/server/transport/udp-and-tcp/address |
Configures the IP address of a DNS server. |
The value is an IPv4 address in dotted decimal notation. |
N/A |
/huawei-dns:dns/dns-common/dns-resolve-enable |
Indicates whether DNS is enabled. |
The value is of the Boolean type:
|
N/A |
/huawei-dns:dns/dns-common/dns-server/ip-version/ipv4/ipv4/ip-address |
Configures the IPv4 address of a DNS server. |
The value is an IPv4 address in dotted decimal notation. |
This command is equivalent to the dns server ip-address command. A maximum of six DNS server IP addresses (IPv4 and IPv6 addresses) can be configured on a switch. |
/huawei-dns:dns/dns-common/dns-server/ip-version/ipv6/ipv6/ip-address |
Configures the IPv6 address of a DNS server. |
The value is an IPv6 address. It contains 128 bits, which are divided into eight groups. Each group contains four hexadecimal digits. The value is in the format of X:X:X:X:X:X:X:X. |
This command is equivalent to the dns server ipv6 ipv6-address command. A maximum of six DNS server IP addresses (IPv4 and IPv6 addresses) can be configured on a switch. |
/huawei-dns:dns/dns-client/domain-suffixes/domain-suffix |
Configures a domain name suffix. |
The value is a string of 1 to 64 characters without spaces. A combination of digits, letters, underscores (_), hyphens (-), and dots (.) is allowed. |
A maximum of ten domain name suffixes can be configured on a switch. |
Example for Configuring a DNS Server
This section provides a sample of configuring DNS using the edit-config:merge method.
Operation |
XPATH |
---|---|
edit-config:merge |
/ietf-system:system/dns-resolver |
Data Requirements
Item |
Data |
Description |
---|---|---|
DNS server name |
t2 |
- |
DNS server address. |
192.168.1.5 |
- |
Request Example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <sys:system xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system"> <sys:dns-resolver> <sys:server> <sys:name>t2</sys:name> <sys:udp-and-tcp> <sys:address>192.168.1.5</sys:address> </sys:udp-and-tcp> </sys:server> </sys:dns-resolver> </sys:system> </config> </edit-config> </rpc>
Response Example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="35"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="36"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>parse rpc config error.</error-message> </rpc-error> </rpc-reply>
Example for Configuring a DNS Domain Name Suffix
This section provides an example for configuring a DNS domain name suffix using the edit-config method.
Operation |
XPATH |
---|---|
edit-config |
|
Data Requirements
Item |
Data |
Description |
---|---|---|
Dynamic DNS function |
true |
Enable the dynamic DNS function. |
Index when multiple DNS server IP addresses are configured. |
huawei |
The index value is a character string. Set the index to huawei. A maximum of six DNS server IP addresses (IPv4 and IPv6 addresses) can be configured on a switch. |
DNS server IP address |
10.1.1.1 |
Set the IP address of the DNS server to 10.1.1.1. |
Domain name suffix |
huawei.com |
Set the domain name suffix to huawei.com. |
Request Example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="3" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <hw-dns:dns xmlns:hw-dns="urn:huawei:params:xml:ns:yang:huawei-dns"> <hw-dns:dns-common> <hw-dns:dns-resolve-enable>true</hw-dns:dns-resolve-enable> <hw-dns:dns-server> <hw-dns:name>huawei</hw-dns:name> <hw-dns:ipv4> <hw-dns:ip-address>10.1.1.1</hw-dns:ip-address> </hw-dns:ipv4> </hw-dns:dns-server> </hw-dns:dns-common> <hw-dns:dns-client> <hw-dns:domain-suffixes> <hw-dns:domain-suffix>huawei.com</hw-dns:domain-suffix> </hw-dns:domain-suffixes> </hw-dns:dns-client> </hw-dns:dns> </config> </edit-config> </rpc>
Response Example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-path>/huawei-dns:dns/dns-common/dns-server[name='huawei']/ipv4/ip-address</error-path> <error-message>parse rpc config error.(Value "10.1.1.289" does not satisfy the constraint "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?" (range, length, or pattern).).</error-message> </rpc-error> </rpc-reply>