Practices Overview
1 PTR dns.us.oracle.com.
101 PTR host01.example.com. 102 PTR host02.example.com. 103 PTR host03.example.com. 104 PTR host04.example.com. Perform the next task from host03.
4. Test host name to IP resolution on host03.
a. Use the ping command to contact host01 and host02.
• You can successfully contact these systems by name, because /etc/hosts resolves host names to IP addresses.
[host03]# ping host01
PING host01.example.com (192.0.2.101) 56(84) bytes of data. 64 bytes from host01.example.com (192.0.2.101): icmp_seq=1... ...
CTRL-C
[host03]# ping host02
PING host02.example.com (192.0.2.102) 56(84) bytes of data. 64 bytes from host02.example.com (192.0.2.102): icmp_seq=1... ...
CTRL-C
b. Use the vi editor to edit the /etc/hosts file and comment out the lines for the VMs with a # sign as follows.
[host03]# vi /etc/hosts 127.0.0.1 localhost.localdomain localhost 192.0.2.1 example.com dom0 #192.0.2.101 host01.example.com host01 #192.0.2.102 host02.example.com host02 #192.0.2.103 host03.example.com host03 c. Use the ping command to contact host01 and host02.
• You can still successfully contact these systems by name, because DNS is resolving host names to IP addresses.
[host03]# ping host01
PING host01.example.com (192.0.2.101) 56(84) bytes of data. 64 bytes from host01.example.com (192.0.2.101): icmp_seq=1...
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 2: Network Addressing and Name Services
...
CTRL-C
[host03]# ping host02
PING host02.example.com (192.0.2.102) 56(84) bytes of data. 64 bytes from host02.example.com (192.0.2.102): icmp_seq=1... ...
CTRL-C
d. Use the grep command to search for the “hosts” string in the /etc/nsswitch.conf file.
• The first “hosts” entry is a comment.
• In the second “hosts” entry, “files” means to use the local /etc/hosts file to resolve host names to IP addresses.
• Also in the second “hosts” entry, “dns” means to use DNS to resolve host names to IP addresses when unable to resolve by using the /etc/hosts file.
[host03]# grep hosts /etc/nsswitch.conf #hosts: db files nisplus nis dns
hosts: files dns
e. Use the vi editor to edit the /etc/nsswitch.conf file and remove the “dns” argument from the “hosts” entry as follows.
[host03]# vi /etc/nsswitch.conf
hosts: files dns # old entry hosts: files # new entry f. Use the ping command to contact host01 and host02.
• You cannot contact these systems by name now because DNS is no longer used. [host03]# ping host01
ping: unknown host host01 [host03]# ping host02 ping: unknown host host02
g. Use the vi editor to edit the /etc/nsswitch.conf file and restore the “dns” argument to the “hosts” entry as follows.
[host03]# vi /etc/nsswitch.conf
hosts: files # old entry hosts: files dns # new entry h. Use the ping command to contact host01 and host02.
• You can now successfully contact these systems by name, because DNS is resolving host names to IP addresses.
[host03]# ping host01
PING host01.example.com (192.0.2.101) 56(84) bytes of data. 64 bytes from host01.example.com (192.0.2.101): icmp_seq=1... ...
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
CTRL-C
[host03]# ping host02
PING host02.example.com (192.0.2.102) 56(84) bytes of data. 64 bytes from host02.example.com (192.0.2.102): icmp_seq=1... ...
CTRL-C
i. View the /etc/resolv.conf file.
• DNS is only able to resolve host names to IP addresses because the
/etc/resolv.conf file contains a valid search domain, example.com, and valid nameserver information.
• The nameserver 192.0.2.1 for the example.com domain stores the zone files that provide host name to IP address resolution.
[host03]# cat /etc/resolv.conf # Generated by NetworkManager search example.com
nameserver 192.0.2.1 nameserver 152.68.154.3 nameserver 10.216.106.3
j. Use the vi editor to edit the /etc/resolv.conf file and comment out all lines as follows. [host03]# vi /etc/resolv.conf # Generated by NetworkManager #search example.com #nameserver 192.0.2.1 #nameserver 152.68.154.3 #nameserver 10.216.106.3
k. Use the ping command to contact host01 and host02. • You cannot contact these systems by name now.
[host03]# ping host01 ping: unknown host host01 [host03]# ping host02 ping: unknown host host02
l. Use the vi editor to edit the /etc/resolv.conf file and remove the # signs to uncomment the “search” and “nameserver” entries as follows.
[host03]# vi /etc/resolv.conf # Generated by NetworkManager search example.com nameserver 192.0.2.1 nameserver 152.68.154.3 nameserver 10.216.106.3
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 2: Network Addressing and Name Services
m. Use the ping command to contact host01 and host02.
• You can now successfully contact these systems by name, because DNS is resolving host names to IP addresses.
[host03]# ping host01
PING host01.example.com (192.0.2.101) 56(84) bytes of data. 64 bytes from host01.example.com (192.0.2.101): icmp_seq=1... ...
CTRL-C
[host03]# ping host02
PING host02.example.com (192.0.2.102) 56(84) bytes of data. 64 bytes from host02.example.com (192.0.2.102): icmp_seq=1... ...
CTRL-C
5. Note that NetworkManager generates the /etc/resolv.conf entries on host03. a. View the /etc/resolv.conf file.
• Note the commented line indicating that NetworkManager generated the /etc/resolv.conf file.
[host03]# cat /etc/resolv.conf # Generated by NetworkManager search example.com
nameserver 192.0.2.1 nameserver 152.68.154.3 nameserver 10.216.106.3
b. View the /etc/sysconfig/network-scripts/ifcfg-eth0 file.
• Note that the DNS[123] entries in the ifcfg-eth0 file correspond to the nameserver entries in the resolv.conf file.
• Note that the DOMAIN entry in the ifcfg-eth0 file corresponds to the search entry in resolv.conf.
• NetworkManager uses the information in the ifcfg-eth0 file to populate the resolv.conf file.
[host03]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 ...
DNS1=192.0.2.1 DNS2=152.68.154.3 DNS3=10.216.106.3 DOMAIN=example.com
6. Use the host command to perform DNS lookups on host03. a. Query DNS for the nameserver for the example.com domain.
[host03]# host –t NS example.com
example.com name server dns.example.com.
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
b. Query DNS for the IP address that corresponds to host01 system. [host03]# host host01
host01.example.com has address 192.0.2.101
c. Perform a reverse lookup by querying DNS for the domain name that corresponds to IP address 192.0.2.102.
[host03]# host 192.0.2.102
102.2.0.192.in-addr-arpa domain name pointer host02.example.com d. Use the -v option to display verbose information about the example.com domain.
[host03]# host -v example.com Trying "example.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65099 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ...
;; QUESTION SECTION:
;example.com. IN A
;; AUTHORITY SECTION:
example.com. 86400 IN SOA dns.example.com. ... ...
7. Use the dig command to perform DNS lookups on host03. Query DNS for the information about host02.example.com.
[host03]# dig host02.example.com ... ;; QUESTION SECTION. ;host02.example.com. IN A ;; ANSWER SECTION. host02.example.com. 86400 IN A 192.0.2.102 ;; AUTHORITY SECTION. example.com. 86400 IN A dns.example.com ;; ADDITIONAL SECTION. dns.example.com. 86400 IN A 192.0.2.1 ...
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 2: Network Addressing and Name Services