LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Reverse lookup not resolving IP to Name. (https://www.linuxquestions.org/questions/linux-newbie-8/reverse-lookup-not-resolving-ip-to-name-822391/)

gardenair 07-27-2010 04:51 AM

Reverse lookup not resolving IP to Name.
 
I have configured Bind 9 in my test lab using class c .I can successfully dig pc1 as following.

[root@mainserver ~]# dig A pc1.mydomain.com

; <<>> DiG 9.2.4 <<>> A pc1.mydomain.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61797
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;pc1.mydomain.com. IN A

;; ANSWER SECTION:
pc1.mydomain.com. 86400 IN A 192.168.1.1

;; AUTHORITY SECTION:
mydomain.com. 86400 IN NS mainserver.mydomain.com.

;; ADDITIONAL SECTION:
mainserver.mydomain.com. 86400 IN A 192.168.1.254

;; Query time: 363 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Jul 23 01:51:28 2010
;; MSG SIZE rcvd: 91


but when i try to use reverse lookup it does't give me ans.

[root@mainserver ~]# dig -x 192.168.1.1

; <<>> DiG 9.2.4 <<>> -x 192.168.1.1
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 56468
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;1.1.168.192.in-addr.arpa. IN PTR

;; Query time: 77 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jul 26 19:49:55 2010
;; MSG SIZE rcvd: 42


My /etc/resolve file is as

search mydomain.com
nameserver 192.168.1.254

Please guide that how can I fix this issue.
thanks
garden

zirias 07-27-2010 04:56 AM

reverse lookup is a separate zone and needs to be configured as such in bind. for IPv4, use a zone named z.y.x.in-addr.arpa. pointing to a zone-file with PTR records for each value of n, where x.y.z.n is the full dotted IPv4-address.

example:

zone: 0.168.192.in-addr.arpa -> file rev-lan.db

zonefile: 1 IN PTR foo.example.org.

makes 192.168.0.1 resolve to foo.example.org

Don't forget the trailing dot in a PTR record to make it "absolute".

gardenair 07-27-2010 05:18 AM

in \etc\named.conf file

zone “1.168.192.in-addr.arpa” IN {
type master;
file “mydomain.com.rev” ;
allow-update {none; };
};


and my reverse life is as

[root@mainserver named]#vi@mydomain.com.rev

PHP Code:

$ORIGIN 1.168.192.in-addr-arpa.
     
$TTL    86400
      
@            IN SOA mainserver.mydomain.com.    admin@mydomain.com (
                        
20100722        serial   (d.    admin)
                        
3H        ;refresh
                        15M        
;retry
                        1W        
;expire
                        1D        
;minimum
       
@            IN NS        mainserver.mydomain.com.
       @            
IN MX        10    mainserver.mydomain.com.
        
254.1.168.192.in-addr.arpa.           IN    PTR       mainserver.mydomain.com.
         
1.1.168.192.in.addr.arpa.           IN    PTR 


zirias 07-27-2010 05:24 AM

Uhm .. I spot a lot of little errors like "ORIGIN" instead of "$ORIGIN", "in.addr" instead of "in-addr" ... and the file ends after a "PTR"? ... this record lacks a hostname!

Btw, you do NOT need to write the full thing like "1.1.168.192.in.addr.arpa." if $ORIGIN is set appropriately -- it will be appended automatically, so just "1" would be enough.

gardenair 07-27-2010 05:30 AM

sorry,in my linux box there was already $ORIGIN i forget to write here in my post.
Please specify with code where is an error.

$ORIGIN 1.168.192.in.addr.arpa.
is it correct ?

should be too much thankful.

zirias 07-27-2010 05:35 AM

Quote:

Originally Posted by gardenair (Post 4046665)
1.1.168.192.in.addr.arpa. IN PTR

This line definitely has two errors:
- "in.addr" instead of "in-addr"
- nothing after the "PTR", so this address points to nothing -- you need to put a FQDN after PTR, with trailing dot.

And, the whole IP-address is unnecessary here, "1" instead of "1.1.168.192.in-addr.arpa." would be enough :)

zirias 07-27-2010 05:36 AM

Quote:

Originally Posted by gardenair (Post 4046675)
$ORIGIN 1.168.192.in.addr.arpa.
is it correct ?

No, the top-level zone for IPv4 addresses is "in-addr.arpa." and NOT "in.addr.arpa.".

gardenair 07-27-2010 05:45 AM

thanks a lot "zirias" for the help.I appriciate you. It is now working perfact.

One thing more i want to discuss that what is the role of /etc/resolve
my default it was as

Code:

search localdomain
nameserver 127.0.0.1

but I change it as

Code:

search mydomain.com
nameserver 192.168.1.254

what does this file do ?

zirias 07-27-2010 05:49 AM

It tells your libc where to look for a nameserver inside "gethostbyname()" calls and the like. The parameter "search" is appended automatically to unqualified hostnames, so a gethostbyname('foo'); will really look up "foo.mydomain.com.".

gardenair 07-27-2010 06:29 AM

from client side how can i test my server ? when i write
Code:

[root@pc1 root] ping www.mydomain.com
ping:unknown host  www.mydomain.com

the client can ping with ip address of the bind serveri.e 192.168.1.254

zirias 07-27-2010 06:34 AM

So this client is located inside the same private LAN, otherwise it wouldn't be able to ping a 192.168.0.0/16 address. Just adjust /etc/resolv.conf on this client :)

gardenair 07-27-2010 06:48 AM

yes it is inside the same network.I should be thankful if you guide me that how can i add the client in /etc/resolv.conf file ?My client address is 192.168.1.1 and the subnet mask is same which is
255.255.255.0

Code:

search mydomain.com
nameserver 192.168.1.254
pc1 192.168.1.1

the editor is showing it under red colour which is i am sure wronge.Please guide about it.

in the pc1 i edit the file and it was showing as as
Quote:

nameserver 192.168.1.254
search mydomain.com

zirias 07-27-2010 06:53 AM

Uhm ... what do you THINK this "pc1" entry should do? the only thing you HAVE to configure in resolv.conf is the IP address of your primary name server. I don't know what it is in your case, just put there the IP where you installed "bind".

gardenair 07-27-2010 11:34 PM

Code:

Uhm ... what do you THINK this "pc1" entry should do? the only thing you HAVE to configure in resolv.conf is the IP address of your primary name server. I don't know what it is in your case, just put there the IP where you installed "bind".
Well pc1 i.e "pc1.mydomain.com" is my client machine and main server is the computer in which bind is install.The client computer pc1 and the main server (Bind server) i.e FQDN "mainserver.mydomain.com "are on the same network.from client machine i can't resolve the name to IP address as my server do successfully with client.
The /etc/resolv.conf file in my bind server is as

Code:

search mydomain.com
nameserver 192.168.1.254

At my client computer when I use dig command
Code:

[root@pc1 root]# dig A mainserver.mydomain.com
it does't resolve :confused:

Kindly help me .....please

thanks


All times are GMT -5. The time now is 02:31 PM.