Page 1 of 1 1
Topic Options
#174771 - 2007-03-20 09:19 AM Change DNS settings
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Hi,

I'm looking for a script where I can change the DNS settings on my servers (they have static IP and I know how to change suffix), due to new DNS servers. Is there anybody how knows how to do that. My servers have different network vendors, so it has to be able to get the current LAN-card in use.

Thanks

Jan

Top
#174778 - 2007-03-20 01:59 PM Re: Change DNS settings [Re: jan]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
See if these will get you going.

SetIPOptions() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=144740&page=1#Post144740
GetIPOptions() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=159170&page=2#Post159170
EnumNetworkConnections() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=139601&page=2#Post139601
_________________________
(... better days ahead)

Top
#174779 - 2007-03-20 02:14 PM Re: Change DNS settings [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
To get you going, here is a quick and dirty attempt... make sure to paste the UDFs to the bottom of your script.

Untested
 Code:
$newdnsservers="nnn.nnn.nnn.nnn,mmm.mmm.mmm.mmm"
$olddnsservers="xxx.xxx.xxx.xxx,yyy.yyy.yyy.yyy"
$serverlist=  ;array of computernames...list them manually here, use a file, or query AD/NT

for each $server in $serverlist 
  For each $netconnection in Enumnetworkconnections(1,$server)
    ? $Server + " : " + $netconnection + " : "
    $mac=split($netconnection,",")[1]
    if GetIPOptions("DNSServers",$Server,$mac)=$olddnsservers
      $RC=setipoptions("DNSServers",$newdnsservers,$server,$mac) 
      @serror
    endif  
  next
next
_________________________
(... better days ahead)

Top
#174858 - 2007-03-22 02:26 PM Re: Change DNS settings [Re: Allen]
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Hi,

My problem is that I have both 2000 and 2003 server and NetConnectionID is not supported in 2000. Do you have any other ideas?

Jan

Top
#174862 - 2007-03-22 03:13 PM Re: Change DNS settings [Re: jan]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
To be honest with you, I thought 2000/NT was supported, but it looks like its not. To be honest though, all you need is a collection of mac addresses, and I would bet there are a couple of UDFs to do that.

Also see NICInfo()
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=7&Number=150839
_________________________
(... better days ahead)

Top
#174905 - 2007-03-23 01:39 AM Re: Change DNS settings [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Digging around some... and sure enough there are a number of variations of the GetMAC() in this one thread: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84616&page=4#Post84616

I really liked Radimus's version (very bottom), but Jooel's UDF should work for the purpose of fixing the example script:

 Code:
$newdnsservers="nnn.nnn.nnn.nnn,mmm.mmm.mmm.mmm"
$olddnsservers="xxx.xxx.xxx.xxx,yyy.yyy.yyy.yyy"
$serverlist=  ;array of computernames...list them manually here, use a file, or query AD/NT

for each $server in $serverlist 
  For each $mac in GetMAC($Server)
    ? $Server + " : " + $mac+ " : "
    if GetIPOptions("DNSServers",$Server,$mac)=$olddnsservers
      $RC=setipoptions("DNSServers",$newdnsservers,$server,$mac) 
      @serror
    endif  
  next
next
_________________________
(... better days ahead)

Top
#174911 - 2007-03-23 12:35 PM Re: Change DNS settings [Re: Allen]
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Hi,

Thanks for your help. It works now :-)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.017 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org