DNS Configuration
This chapter describes how to configure the domain name system (DNS) for network devices to communicate using domain names.
Overview of DNS
Domain Name System (DNS) is a distributed database for TCP/IP applications that provides conversion between domain names and IP addresses.
DNS uses a hierarchical naming method to specify a meaningful name for each device on the network and uses a resolver to establish mappings between IP addresses and domain names. DNS allows users to use meaningful and easy-to-memorize domain names instead of IP addresses to identify devices.
Configuring DNS Client
This section describes how to configure DNS and establish mappings between domain names and IP addresses, so that a device can communicate with other devices using domain names.
Usage Scenario
- If you seldom use domain names to visit other devices or no DNS server is available, configure static DNS on the DNS client. To configure static DNS, you must know the mappings between domain names and IP addresses. If a mapping changes, you must manually modify the DNS entry on the DNS client.
- If you want to use domain names to visit many devices and DNS servers are available, configure dynamic DNS on the DNS client. Dynamic DNS requires DNS servers.
Pre-configuration Tasks
Configuring a route between the DNS client and server, so that the DNS client and server can communicate
Configuring DNS servers
Procedure
- Configure static DNS.
Run system-view
The system view is displayed.
Run ip host [ vpn-instance vpn-name ]
The mapping between the domain name and IPv4 address of the host is configured.
Run commit
The configuration is committed.
- Configure dynamic DNS.
Run system-view
The system view is displayed.
Run dns resolve
Dynamic DNS is enabled.
Run dns server ip-address [ vpn-instance vpn-name ]
A DNS server is specified.
(Optional) Run dns server source-ip source-ip-address [ vpn-instance vpn-name ]
An IP address is specified for the DNS client to communicate with the DNS server. Using a specified source address ensures the security of communication between the DNS client and DNS server.
Run dns domain domain-name [ vpn-instance vpn-name ]
A domain name suffix is added.
(Optional) Run dns timeout interval-time
A DNS query response timeout period is configured.
(Optional) Run dns try times
The number of retransmission times for DNS query packets is configured.
Run commit
The configuration is committed.
To configure multiple DNS servers, repeatedly perform Step 3. To configure multiple domain name suffixes, repeatedly perform Step 5.
Verifying the Configuration of a DNS Client
After configuring a DNS client, verify the configuration.
Run the display ip host command to view static DNS entries, including mappings between domain names and IP addresses.
Run the display dns server command to view the IP addresses of all configured DNS servers.
Run the display dns domain command to view the domain name suffix list.
Run the display dns dynamic-host command to view dynamic DNS entries stored in the cache.
Maintaining DNS
This chapter describes how to maintain DNS, which includes clearing dynamic DNS entries and monitoring the DNS running status.
Clearing Dynamic DNS Entries
Monitoring the DNS Running Status
This section describes how to monitor the DNS running status.
Context
In routine maintenance, you can run the following commands in all views to check the running status of DNS.
Procedure
- Run the display ip host [ vpn-instance vpn-name ] command to check information about the static domain name resolution table.
- Run the display dns server(IPv4) [ vpn-instance vpn-name ] command to check DNS server configurations.
- Run the display dns domain(IPv4) [ vpn-instance vpn-name ] command to check domain name suffixes.
- Run the display dns dynamic-host [ vpn-instance vpn-name ] command to check information about dynamic DNS entries in the cache.
Configuration Examples for DNS
Each configuration example consists of the networking requirements, configuration roadmap, configuration procedures, and configuration files.
Example for Configuring Static DNS
This section describes how to configure static DNS.
Networking Requirements
As shown in Figure 6-2, Device A frequently uses the domain name "host.com" to visit the host. To improve the efficiency of domain name resolution, you can establish a static mapping between the domain name "host.com" and IP address 10.100.1.2 in the static domain name resolution table of Device A.
Configuration Roadmap
The configuration roadmap is as follows:
- Establish a static mapping between the domain name "host.com" and IP address 10.100.1.2 on Device A.
Data Preparation
To complete the configuration, you need the following data:
IP addresses of Device A and the host
Domain name of the host
Procedure
- Configure a static mapping between the domain name "host.com" and IP address 10.100.1.2.
<HUAWEI> system-view
[~HUAWEI]sysname DeviceA
[*HUAWEI]commit
[~DeviceA] ip host host.com 10.100.1.2
[*DeviceA] commit
- Verify the configuration.# Run the ping host.com command on Device A. The host can be pinged. The destination IP address for the ping operation is 10.100.1.2.
<DeviceA> ping host.com
ping host.com (10.100.1.2):56 data bytes, press CTRL_C to break Reply from 10.100.1.2: bytes=56 Sequence=1 ttl=128 time=1 ms Reply from 10.100.1.2: bytes=56 Sequence=2 ttl=128 time=4 ms Reply from 10.100.1.2: bytes=56 Sequence=3 ttl=128 time=3 ms Reply from 10.100.1.2: bytes=56 Sequence=4 ttl=128 time=2 ms Reply from 10.100.1.2: bytes=56 Sequence=5 ttl=128 time=3 ms --- host.com ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/2/4 ms
# Run the display ip host command on Device A to check static DNS entry information, including mappings between domain names and IP addresses.<DeviceA> display ip host
Host Age Flags Address host.com 0 static 10.100.1.2
Example for Configuring Dynamic DNS Client
This section describes how to configure dynamic DNS.
Networking Requirements
As shown in Figure 6-3, Device A serves as the DNS client. With the help of the DNS server, Device A can use the domain name "huawei.com" to access the host with IP address 10.2.1.3/16.
Configuration Roadmap
The configuration roadmap is as follows:
Enable dynamic DNS.
Configure the IP address of the DNS server.
Configure a domain name suffix.
Data Preparation
To complete the configuration, you need the following data:
Domain names of Device B and Device C
IP address of the DNS server
Domain name suffixes
Procedure
- Configure Device A.
# Configure dynamic DNS entries.
<HUAWEI> system-view
[~HUAWEI]sysname DeviceA
[*HUAWEI]commit
# Enable dynamic DNS.
[~DeviceA] dns resolve
# Configure the IP address of the DNS server.
[*DeviceA] dns server 10.3.1.2
# Configure a domain name suffix "net".
[*DeviceA] dns domain net
# Configure a domain name suffix "com".
[*DeviceA] dns domain com
[*DeviceA] commit
[~DeviceA] quit
To implement domain name resolution, you must configure a route between Device A and the DNS server for them to communicate. For details about how to configure a route, see NE20EUniversal Service Router Configuration Guide - IP Routing.
- Verify the configuration.
# Run the ping huawei command on Device A. The host with domain name "huawei.com" can be pinged. The destination IP address for the ping operation is 10.2.1.3.
<DeviceA> ping huawei.com
PING huawei.com (10.2.1.3): 56 data bytes, press CTRL_C to break
Reply from 10.2.1.3: bytes=56 Sequence=1 ttl=126 time=6 ms
Reply from 10.2.1.3: bytes=56 Sequence=2 ttl=126 time=4 ms
Reply from 10.2.1.3: bytes=56 Sequence=3 ttl=126 time=4 ms
Reply from 10.2.1.3: bytes=56 Sequence=4 ttl=126 time=4 ms
Reply from 10.2.1.3: bytes=56 Sequence=5 ttl=126 time=4 ms
--- huawei.com ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 4/4/6 ms
# Run the display dns dynamic-host command on Device A. Dynamic DNS entry information stored in the cache is displayed.
<DeviceA> display dns dynamic-host
No Domain Name IpAddress TTL Alias
1 huawei.com 10.2.1.3 3579
TTL indicates how long a DNS entry can exist, in seconds.
Configuration Files
Configuration file of Device A
#
sysname DeviceA
#
dns resolve
dns server 10.3.1.2
dns domain net
dns domain com
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 1.1.1.2 255.255.0.0
#
rip 1
network 1.0.0.0
#
return
Configuration file of Device B
#
sysname DeviceB
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 2.1.1.1 255.255.0.0
#
interface GigabitEthernet0/1/1
undo shutdown
ip address 1.1.1.1 255.255.0.0
#
interface LoopBack0
ip address 4.1.1.1 255.255.255.255
#
rip 1
network 2.0.0.0
network 1.0.0.0
network 4.0.0.0
#
return
Configuration file of Device C
#
sysname DeviceC
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 2.1.1.2 255.255.0.0
#
interface GigabitEthernet0/1/1
undo shutdown
ip address 3.1.1.1 255.255.0.0
#
interface LoopBack0
ip address 4.1.1.2 255.255.255.255
#
rip 1
network 2.0.0.0
network 3.0.0.0
network 4.0.0.0
#
return