sir, you read it wrong. the command works as intended. but hosts file is not being used. a tip from another website says to add extra code to resolv.conf, but that gets overwritten every reboot. please advise.
$ nslookup apple.com
Server: 10.30.56.234
Address: 10.30.56.234#53
Non-authoritative answer:
Name: apple.com
Address: 17.149.160.49
Name: apple.com
Address: 17.178.96.59
Name: apple.com
Address: 17.172.224.47
$ dig apple.com
; <<>> DiG 9.8.3-P1 <<>> apple.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3746
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;apple.com. IN A
;; ANSWER SECTION:
apple.com. 1436 IN A 17.178.96.59
apple.com. 1436 IN A 17.172.224.47
apple.com. 1436 IN A 17.149.160.49
;; Query time: 8 msec
;; SERVER: 10.30.56.234#53(10.30.56.234)
;; WHEN: Thu Apr 24 13:50:45 2014
;; MSG SIZE rcvd: 75
$ ping apple.com
PING apple.com (17.172.224.47): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
^C
--- apple.com ping statistics ---
4 packets transmitted, 0 packets received, 100.0% packet loss
#(NOTE: This is normal for me, my firewall blocks icmps, but still resolves wrong)
$ host -v apple.com
Trying "apple.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56674
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;apple.com. IN A
;; ANSWER SECTION:
apple.com. 1305 IN A 17.149.160.49
apple.com. 1305 IN A 17.178.96.59
apple.com. 1305 IN A 17.172.224.47
Received 75 bytes from 10.30.56.234#53 in 0 ms
Trying "apple.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16733
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;apple.com. IN AAAA
;; AUTHORITY SECTION:
apple.com. 85699 IN SOA gridmaster-ib.apple.com. hostmaster.apple.com. 2010088892 1800 900 2016000 86500
Received 88 bytes from 10.20.0.50#53 in 0 ms
Trying "apple.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48782
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 11
;; QUESTION SECTION:
;apple.com. IN MX
;; ANSWER SECTION:
apple.com. 3599 IN MX 100 mail-in100.apple.com.
apple.com. 3599 IN MX 10 mail-in2.apple.com.
apple.com. 3599 IN MX 20 mail-in25.apple.com.
apple.com. 3599 IN MX 20 mail-in24.apple.com.
apple.com. 3599 IN MX 20 mail-in23.apple.com.
apple.com. 3599 IN MX 20 mail-in22.apple.com.
apple.com. 3599 IN MX 20 mail-in21.apple.com.
apple.com. 3599 IN MX 10 mail-in7.apple.com.
apple.com. 3599 IN MX 10 mail-in6.apple.com.
apple.com. 3599 IN MX 10 mail-in5.apple.com.
apple.com. 3599 IN MX 10 mail-in4.apple.com.
;; ADDITIONAL SECTION:
mail-in100.apple.com. 8 IN A 17.151.62.23
mail-in2.apple.com. 8 IN A 17.151.62.17
mail-in25.apple.com. 8 IN A 17.171.2.25
mail-in24.apple.com. 8 IN A 17.171.2.24
mail-in23.apple.com. 8 IN A 17.171.2.23
mail-in22.apple.com. 8 IN A 17.171.2.22
mail-in21.apple.com. 8 IN A 17.171.2.21
mail-in7.apple.com. 8 IN A 17.151.62.22
mail-in6.apple.com. 8 IN A 17.151.62.21
mail-in5.apple.com. 8 IN A 17.151.62.19
mail-in4.apple.com. 8 IN A 17.151.62.18
Received 485 bytes from 10.30.56.234#53 in 151 ms
it does not read the hosts file at all.