forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


DNS address

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Feb 19, 2009 10:35 am    Post subject: DNS address Reply with quote

Hi

Can anybody help me. Is there a way in pure VDS to find the IP address of the DNS server used by the PC. I have looked in the registry and found it but the location is tired to the NIC and has a GUID attached to it. This means it won't be the same on all PC's. I don't won't to use a 3rd party DLL as I will have to distribute this to 350 machines across 4 different sites!

Thanks

David.M
Back to top
View user's profile Send private message
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Thu Feb 19, 2009 7:41 pm    Post subject: Reply with quote

hi,

of course. the dns server is not the same on all pc's. therefore you need to evaluate it i guess Wink

try it with this code (should work with all nt-based systems):

Code:


  runh @windir(sys)\nslookup,pipe,wait
  %L = @new(list)
  list assign,%L,@pipe()
  %x = @item(%L,1)
  %x = @substr(%x,10,@len(%x))
  info DNS-Server-Address: %x@tab()
  list close,%L
  exit




greetings

attreus
Back to top
View user's profile Send private message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Fri Feb 20, 2009 10:51 am    Post subject: Reply with quote

Hi

Absolutely brilliant! Your the man, it worked just fine! I've turned it into a subroutine for my library.

Here's what I did..
Code:

#define function,dns-ip

runh subst b: \\@dns-ip(7)\c$
exit

rem ***********************************************************
rem * FUNCTION:
REM * @dns-ip(list#)
REM *
REM * DATE:
REM * 200209A
REM *
rem * DSCRPTN:
REM * Returns the IP address of the DNS server,
rem * requires a spare list!
rem *
REM * RETURNS:
REM * IP address OR null for failure
rem ***********************************************************
:dns-ip
    if @not(%1)
        warn List number not supplied for dns-ip subroutine
        exit
    end
    list create,%1
    runh @windir(sys)\nslookup,pipe,wait
    list assign,%1,@pipe()
    %x = @item(%1,1)
    %x = @substr(%x,11,@len(%x))
    %y = @substr(%x,1)
    if @not(@numeric(%y))
        warn DNS-Server not found
        exit
    end
    list close,%1
    exit %x
rem ***********************************************************


I hope the format returned by nslookup never changes or I'll have to do a re-write.

Thanks again

David.M
Back to top
View user's profile Send private message
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Fri Feb 20, 2009 2:51 pm    Post subject: Reply with quote

i'm glad to help you.

but i wonder at the line:

Code:
runh subst b: \\@dns-ip(7)\c$


isn't there a problem with the @-sign without quotes ?

btw. you simply could extend your subroutine resolving any ip or hostname and vice versa by just adding an additional parameter to nslookup and then parsing the result.

edit: and hence to check for internet-connection too.

Code:
runh @windir(sys)\nslookup <ip or hostname>,pipe,wait


greetz

attreus
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group