Example for Configuring the DNS Client
Networking Requirements
Compared with an IP address, the URL is easy to remember. Users want to access network servers using domain names. It is required that the DNS server can resolve a domain name after a user enters some fields of the domain name. For example, when a user attempts to access the server huawei.com, the user only needs to enter huawei. It is required that the DNS server can fast resolve common domain names.
Configuration Roadmap
The configuration roadmap is as follows:
Configure static DNS entries on RouterA to access server B and C.
Configure the dynamic DNS resolution on RouterA to access the DNS server.
Configure the domain name suffix on RouterA to support a domain name suffix list.
Configure OSPF on routers to ensure routes are reachable.
Procedure
- Configure RouterA.
# Configure an IP address for GE1/0/0.
<Huawei> system-view [Huawei] sysname RouterA [RouterA] interface gigabitethernet 1/0/0 [RouterA-GigabitEthernet1/0/0] ip address 10.1.1.2 255.255.0.0 [RouterA-GigabitEthernet1/0/0] quit
# Configure OSPF.
[RouterA] ospf [RouterA-ospf-1] area 0 [RouterA-ospf-1-area-0.0.0.0] network 10.1.0.0 0.0.255.255 [RouterA-ospf-1-area-0.0.0.0] quit [RouterA-ospf-1] quit
# Configure static DNS entries.
[RouterA] ip host serverB 10.4.1.1 [RouterA] ip host serverC 10.4.1.2
# Enable DNS resolution.
[RouterA] dns resolve
# Configure an IP address for the DNS server.
[RouterA] dns server 10.3.1.2
# Set the domain name suffix to net.
[RouterA] dns domain net
# Set the domain name suffix to com.
[RouterA] dns domain com [RouterA] quit
You need to configure OSPF on RouterB and RouterC to ensure reachable routes between them. For details about OSPF configurations on RouterB and RouterC, see the configuration files.
- Verify the configuration.
# Run the ping serverB command on RouterA. You can see that the ping operation succeeds and the destination IP address is 10.4.1.1.
<RouterA> ping serverB PING serverB (10.4.1.1): 56 data bytes, press CTRL_C to break Reply from 10.4.1.1: bytes=56 Sequence=1 ttl=126 time=4 ms Reply from 10.4.1.1: bytes=56 Sequence=2 ttl=126 time=1 ms Reply from 10.4.1.1: bytes=56 Sequence=3 ttl=126 time=1 ms Reply from 10.4.1.1: bytes=56 Sequence=4 ttl=126 time=1 ms Reply from 10.4.1.1: bytes=56 Sequence=5 ttl=126 time=1 ms --- serverB ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/1/4 ms
# Run the ping huawei.com command on RouterA. You can see that the ping operation succeeds and the destination IP address is 10.2.1.3.
<RouterA> ping huawei.com Trying DNS server (10.3.1.2) 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 ping huawei command on RouterA. You can see that the ping operation succeeds, the domain name changes to huawei.com, and the destination IP address is 10.2.1.3.
<RouterA> ping huawei Trying DNS server (10.3.1.2) 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 ip host command on RouterA. You can view mappings between host names and IP addresses in static DNS entries.
<RouterA> display ip host Host Age Flags Address serverB 0 static 10.4.1.1 serverC 0 static 10.4.1.2
# Run the display dns dynamic-host command on RouterA. You can view information about dynamic DNS entries saved in the cache.
<RouterA> display dns dynamic-host Host TTL Type Address(es) huawei.com 114 IP 10.2.1.3
The TTL field in the command output indicates the time left before a DNS entry ages out, in seconds.
Configuration File
Configuration file of RouterA
# sysname RouterA # ip host serverB 10.4.1.1 ip host serverC 10.4.1.2 # dns resolve dns server 10.3.1.2 dns domain net dns domain com # interface GigabitEthernet1/0/0 ip address 10.1.1.2 255.255.0.0 # ospf 1 area 0.0.0.0 network 10.1.0.0 0.0.255.255 # return
Configuration file of RouterB
# sysname RouterB # interface LoopBack0 ip address 10.4.1.1 255.255.255.255 # interface GigabitEthernet 1/0/0 ip address 10.1.1.1 255.255.0.0 # interface GigabitEthernet 2/0/0 ip address 10.2.1.1 255.255.0.0 # ospf 1 area 0.0.0.0 network 10.1.0.0 0.0.255.255 network 10.2.0.0 0.0.255.255 network 10.4.1.1 0.0.0.0 # return
Configuration file of RouterC
# sysname RouterC # interface LoopBack0 ip address 10.4.1.2 255.255.255.255 # interface GigabitEthernet 1/0/0 ip address 10.3.1.1 255.255.0.0 # interface GigabitEthernet 2/0/0 undo portswitch ip address 10.2.1.2 255.255.0.0 # ospf 1 area 0.0.0.0 network 10.2.0.0 0.0.255.255 network 10.3.0.0 0.0.255.255 network 10.4.1.2 0.0.0.0 # return