L
leo
Hi,
I have a query with embedding nslookup in my program and its
behaviour. Here is the snippet. I have to collect the domainname from
a file and get the root server IP as command line args.
I then have to use nslookup to lookp the domain. my results of
nslookup seems to be different when run from a c prog and when run
from command line.
code snippet
while (fgets (domain, sizeof domain,
fileptr) != EOF)
{
if( (childpid = fork()) == 0)
{
printf("The domain is ");
fputs(domain, stdout);
//Call exec to the program
nslookup using execvp()
execl("/usr/bin/nslookup" ,
"nslookup" ,domain, argv[2],"-norecurse", NULL);
}
}
fclose( fileptr);
}
O/P for www.google.com is
#nslookup www.google.com 192.168.10.1 -norecurse
Server: 192.168.10.1
Address: 192.168.10.1#53
Non-authoritative answer:
www.google.com canonical name = www.l.google.com.
Name: www.l.google.com
Address: 74.125.91.147
Name: www.l.google.com
Address: 74.125.91.99
Name: www.l.google.com
Address: 74.125.91.104
Name: www.l.google.com
Address: 74.125.91.103
From the program
$ ./Program1 192.168.10.1
The domain is www.google.com
Server: 192.168.10.1
Address: 192.168.10.1#53
Non-authoritative answer:
Name: www.google.com\010
Address: 67.63.55.3
I see an additional \010 appended to the response which I have no
clue.
Any pointers on what could be the issue here?
Also is there any reference for constructing a DNS packet response to
nslookup ?
Thanks.
I have a query with embedding nslookup in my program and its
behaviour. Here is the snippet. I have to collect the domainname from
a file and get the root server IP as command line args.
I then have to use nslookup to lookp the domain. my results of
nslookup seems to be different when run from a c prog and when run
from command line.
code snippet
while (fgets (domain, sizeof domain,
fileptr) != EOF)
{
if( (childpid = fork()) == 0)
{
printf("The domain is ");
fputs(domain, stdout);
//Call exec to the program
nslookup using execvp()
execl("/usr/bin/nslookup" ,
"nslookup" ,domain, argv[2],"-norecurse", NULL);
}
}
fclose( fileptr);
}
O/P for www.google.com is
#nslookup www.google.com 192.168.10.1 -norecurse
Server: 192.168.10.1
Address: 192.168.10.1#53
Non-authoritative answer:
www.google.com canonical name = www.l.google.com.
Name: www.l.google.com
Address: 74.125.91.147
Name: www.l.google.com
Address: 74.125.91.99
Name: www.l.google.com
Address: 74.125.91.104
Name: www.l.google.com
Address: 74.125.91.103
From the program
$ ./Program1 192.168.10.1
The domain is www.google.com
Server: 192.168.10.1
Address: 192.168.10.1#53
Non-authoritative answer:
Name: www.google.com\010
Address: 67.63.55.3
I see an additional \010 appended to the response which I have no
clue.
Any pointers on what could be the issue here?
Also is there any reference for constructing a DNS packet response to
nslookup ?
Thanks.