配置DNS客户
Procedure
- Configure one or more DNS name servers with the command
ip dns server
. - To resolve DNS requests by appending a domain name to the requests, either configure a single domain name with the command
ip dns domain-name
, or configure a list of up to six domain names with the commandip dns domain-list
. - To use static name resolution for certain hosts, associate an IP address to a host with the command
ip dns host
. - Review your DNS configuration settings with the command
show ip dns
.
Examples
This example creates the following configuration:
- Defines the domainswitch.comto append to all requests.
- Defines a DNS server with IPv4 address of1.1.1.1.
- Defines a static DNS host namedmyhost1with an IPv4 address of3.3.3.3.
DNS client traffic is sent on the default VRF (nameddefault).
switch(config)#ip dns域名switch.comswitch(config)#ip dns server-address 1.1.1.1switch(config)#ip dns host myhost1 3.3.3.3switch(config)#exitswitch#show ip dnsVRF Name : vrf_mgmt Host Name Address -------------------------------------------------------------------------------- VRF Name : vrf_default Domain Name : switch.com DNS Domain list : Name Server(s) : 1.1.1.1 Host Name Address -------------------------------------------------------------------------------- myhost1
This example creates the following configuration:
- Defines three domains to append to DNS requestsdomain1.com,domain2.com,domain3.comwith traffic forwarding on VRFmainvrf.
- Defines a DNS server with an IPv6 address ofc::13.
- Defines a DNS host namedmyhostwith an IPv4 address of3.3.3.3.
switch(config)#ip dns domain-list domain1.com vrf mainvrfswitch(config)#ip dns domain-list domain2.com vrf mainvrfswitch(config)#ip dns domain-list domain3.com vrf mainvrfswitch(config)#ip dns server-address c::13switch(config)#ip dns host myhost 3.3.3.3 vrf mainvrfswitch(config)#quitswitch#show ip dns mainvrfVRF Name : mainvrf Domain Name : DNS Domain list : domain1.com, domain2.com, domain3.com Name Server(s) : c::13 Host Name Address -------------------------------------------------------------------------------- myhost 3.3.3.3