1

Is there any way to resolve local host without any DNS server?

Below is my config

# ifconfig
eth4      Link encap:Ethernet  HWaddr 00:50:56:9C:4D:2F
          inet6 addr: 2004:c0a8:5b01:1:250:56ff:fe9c:4d2f/64 Scope:Global
          inet6 addr: fe80::250:56ff:fe9c:4d2f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:196832 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12558 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:16362576 (15.6 MiB)  TX bytes:2467903 (2.3 MiB)

I have added name in /etc/hosts file also

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
2004:c0a8:5b01:1:250:56ff:fe9c:4d2f  saravana69rhel83 
2004:c0a8:5b01:1:250:56ff:fe9c:4d2f         localhost localhost.localdomain localhost6 localhost6.localdomain6
::1  saravana69rhel83 

When I try to do a DNS lookup, it is not resolving at all:

# dig saravana69rhel83  AAAA

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6_9.4 <<>> saravana69rhel83  AAAA
;; global options: +cmd
;; connection timed out; no servers could be reached

EDIT

[root@saravana69rhel83 ~]# ping saravana69rhel83 
ping: unknown host saravana69rhel83 
[root@saravana69rhel83 ~]# ping6 saravana69rhel83 
PING saravana69rhel83 (saravana69rhel83 ) 56 data bytes
64 bytes from saravana69rhel83 : icmp_seq=1 ttl=64 time=0.030 ms
^C
--- saravana69rhel83  ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 855ms
rtt min/avg/max/mdev = 0.030/0.030/0.030/0.000 ms
[root@saravana69rhel83 ~]#


[root@saravana69rhel83 ~]# nslookup -query=AAAA saravana69rhel83 
;; connection timed out; trying next origin
;; connection timed out; no servers could be reached

[root@saravana69rhel83 ~]#
  • 1
    As a side note you speak about nslookup but then use dig. You do well, you should prefer dig. And based on your directory where you are, DNSmasq can be a local resolver for your needs. – Patrick Mevzek Nov 30 '17 at 10:54
  • Yes, I was trying to resolve it with some local resolver. Could not make it!! – saravanakumar Dec 1 '17 at 8:08
3

You're using /etc/hosts correctly but nslookup ignores the hosts file. It is doing a DNS lookup not a lookup of how the hostname resolves in your configured environment. Try pinging the hostname instead as that will include hosts file.

See why is my /etc/hosts file not queried when...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.