配置DNS客户端示例
组网需求
由于IP地址难于记忆,用户希望通过DNS域名请求方式访问网络服务器。用户希望输入域名部分字段,DNS服务器就可以正确解析,达到用户访问正确网络服务的效果。例如DNS客户端在访问该主机huawei.com时,用户只需要输入“huawei”即可。对于一些常用的域名,用户希望能够快速访问,提高域名解析的效率。
图1 配置DNS客户端组网图


配置思路
DNS的配置思路如下:
- 在SwitchA、SwitchB上配置各接口的IP地址,并配置动态路由协议,实现各设备之间的路由可达。
- 在SwitchA上配置静态DNS表项,实现在SwitchA上通过域名访问FTPServer。
- 在SwitchA上配置动态DNS功能,实现SwitchA以动态DNS查询方式与网络服务器进行通信的功能。
操作步骤
- 配置各接口所属VLAN
# 在SwitchA上配置各接口所属VLAN。
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan batch 102 [*SwitchA] interface 10ge 1/0/1 [*SwitchA-10GE1/0/1] port link-type trunk [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 102 [*SwitchA-10GE1/0/1] quit [*SwitchA] commit
# 在SwitchB上配置各接口所属VLAN。
<HUAWEI> system-view [~HUAWEI] sysname SwitchB [*HUAWEI] commit [~SwitchB] vlan batch 101 to 104 [*SwitchB] interface 10ge 1/0/1 [*SwitchB-10GE1/0/1] port default vlan 101 [*SwitchB-10GE1/0/1] quit [*SwitchB] interface 10ge 1/0/2 [*SwitchB-10GE1/0/2] port link-type trunk [*SwitchB-10GE1/0/2] port trunk allow-pass vlan 102 [*SwitchB-10GE1/0/2] quit [*SwitchB] interface 10ge 1/0/3 [*SwitchB-10GE1/0/3] port default vlan 103 [*SwitchB-10GE1/0/3] quit [*SwitchB] interface 10ge 1/0/4 [*SwitchB-10GE1/0/4] port default vlan 104 [*SwitchB-10GE1/0/4] quit [*SwitchB] commit
- 配置各VLANIF接口的IP地址
# 在SwitchA上配置接口的IP地址。
[~SwitchA] interface vlanif 102 [*SwitchA-Vlanif102] ip address 10.2.1.2 255.255.0.0 [*SwitchA-Vlanif102] quit [*SwitchA] commit
# 在SwitchB上配置各接口的IP地址。
[~SwitchB] interface vlanif 101 [*SwitchB-Vlanif101] ip address 10.1.1.1 255.255.0.0 [*SwitchB-Vlanif101] quit [*SwitchB] interface vlanif 102 [*SwitchB-Vlanif102] ip address 10.2.1.1 255.255.0.0 [*SwitchB-Vlanif102] quit [*SwitchB] interface vlanif 103 [*SwitchB-Vlanif103] ip address 10.3.1.1 255.255.0.0 [*SwitchB-Vlanif103] quit [*SwitchB] interface vlanif 104 [*SwitchB-Vlanif104] ip address 10.4.1.1 255.255.0.0 [*SwitchB-Vlanif104] quit [*SwitchB] commit
- 配置OSPF基本功能
# 在SwitchA上配置OSPF。
[~SwitchA] ospf [*SwitchA-ospf-1] area 0 [*SwitchA-ospf-1-area-0.0.0.0] network 10.2.0.0 0.0.255.255 [*SwitchA-ospf-1-area-0.0.0.0] quit [*SwitchA-ospf-1] quit [*SwitchA] commit
# 在SwitchB上配置OSPF。
[~SwitchB] ospf [*SwitchB-ospf-1] area 0 [*SwitchB-ospf-1-area-0.0.0.0] network 10.1.0.0 0.0.255.255 [*SwitchB-ospf-1-area-0.0.0.0] network 10.2.0.0 0.0.255.255 [*SwitchB-ospf-1-area-0.0.0.0] network 10.3.0.0 0.0.255.255 [*SwitchB-ospf-1-area-0.0.0.0] network 10.4.0.0 0.0.255.255 [*SwitchB-ospf-1-area-0.0.0.0] quit [*SwitchB-ospf-1] quit [*SwitchB] commit
- 配置静态DNS
[~SwitchA] ip host FTPServer 10.3.1.2 [*SwitchA] commit
- 配置动态DNS
[~SwitchA] dns resolve [*SwitchA] dns server 10.4.1.2 [*SwitchA] dns domain com [*SwitchA] commit [~SwitchA] quit
- 验证配置结果
# 在设备SwitchA上执行ping FTPServer命令,可以ping通,且对应的目的地址为10.3.1.2。
<SwitchA> ping FTPServer PING FTPServer (10.3.1.2): 56 data bytes, press CTRL_C to break Reply from 10.3.1.2: bytes=56 Sequence=1 ttl=253 time=4 ms Reply from 10.3.1.2: bytes=56 Sequence=2 ttl=253 time=1 ms Reply from 10.3.1.2: bytes=56 Sequence=3 ttl=253 time=1 ms Reply from 10.3.1.2: bytes=56 Sequence=4 ttl=253 time=1 ms Reply from 10.3.1.2: bytes=56 Sequence=5 ttl=253 time=1 ms --- FTPServer ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/1/4 ms
# 在设备SwitchA上执行ping huawei.com命令,可以ping通,且对应的目的地址为10.1.1.2。
<SwitchA> ping huawei.com PING huawei.com (10.1.1.2): 56 data bytes, press CTRL_C to break Reply from 10.1.1.2: bytes=56 Sequence=1 ttl=253 time=6 ms Reply from 10.1.1.2: bytes=56 Sequence=2 ttl=253 time=4 ms Reply from 10.1.1.2: bytes=56 Sequence=3 ttl=253 time=4 ms Reply from 10.1.1.2: bytes=56 Sequence=4 ttl=253 time=4 ms Reply from 10.1.1.2: bytes=56 Sequence=5 ttl=253 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
# 在设备SwitchA上执行ping huawei命令,可以ping通,且对应的域名变为huawei.com,目的地址为10.1.1.2。
<SwitchA> ping huawei PING huawei.com (10.1.1.2): 56 data bytes, press CTRL_C to break Reply from 10.1.1.2: bytes=56 Sequence=1 ttl=253 time=6 ms Reply from 10.1.1.2: bytes=56 Sequence=2 ttl=253 time=4 ms Reply from 10.1.1.2: bytes=56 Sequence=3 ttl=253 time=4 ms Reply from 10.1.1.2: bytes=56 Sequence=4 ttl=253 time=4 ms Reply from 10.1.1.2: bytes=56 Sequence=5 ttl=253 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
# 在SwitchA用display ip host命令可以查看到静态DNS表项中主机名和IP地址的对应关系。
<SwitchA> display ip host Host Age Flags Address FTPServer 0 static 10.3.1.2
# 在SwitchA用display dns dynamic-host命令可以查看到动态缓存区中的动态DNS表项信息。
<SwitchA> display dns dynamic-host No Domain Name IpAddress TTL Alias 1 huawei.com 10.1.1.2 114
配置文件
- SwitchA的配置文件
# sysname SwitchA # ip host FTPServer 10.3.1.2 dns resolve dns server 10.4.1.2 dns domain com # vlan batch 102 # interface Vlanif102 ip address 10.2.1.2 255.255.0.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 102 # ospf 1 area 0.0.0.0 network 10.2.0.0 0.0.255.255 # return
- SwitchB的配置文件
# sysname SwitchB # vlan batch 101 to 104 # interface Vlanif101 ip address 10.1.1.1 255.255.0.0 # interface Vlanif102 ip address 10.2.1.1 255.255.0.0 # interface Vlanif103 ip address 10.3.1.1 255.255.0.0 # interface Vlanif104 ip address 10.4.1.1 255.255.0.0 # interface 10GE1/0/1 port default vlan 101 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 102 # interface 10GE1/0/3 port default vlan 103 # interface 10GE1/0/4 port default vlan 104 # 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.3.0.0 0.0.255.255 network 10.4.0.0 0.0.255.255 # return
阅读剩余
版权声明:
作者:SE_YT
链接:https://www.cnesa.cn/6349.html
文章版权归作者所有,未经允许请勿转载。
THE END