Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

Script to set Netbios name to be DNS name.

I need a script that will:
Run after DHCP has gotten an IP address
Do a reverse host lookup on the IP address to discover
it's own DNS name.
Check the netbios name to see if it is the same as the
DNS name.
If different then write the DNS name to the registry
and reboot the machine.

Script has to run under both Win95 and WinNT.
0
sherwood
Asked:
sherwood
1 Solution
 
gosowskiCommented:
this is a security issue with 128 bit encryption,,,,,  

what is it precisely you need it for????
0
 
sherwoodAuthor Commented:
What do you mean, it's a security issue?

In my ideal world stupid PC clients get *all* of their
configuration information off a single server.  Even
if a P.C. is set to use DNS for netbios name resolution,
it *doesn't* use it to resolve it's own name.

For simplicity I would like to have the netbios name be the
same as the DNS name.  

I can manage the DNS name through DHCP using fixed addresses
so that a given machine has the same IP address each time.

Now I would like to set the netbios name the same way.

In this way, I can use ghost to replicate systems, and have
no further configuration hassles.

At present I would have to set up a WINS server in addition
to a DHCP server.  This further spreads configuration information
making adding clients more work.
0
 
jhanceCommented:
Would you pay money for such a utility?  I've got all the pieces to do this in my "toolbox" but putting them together to do this task would take some work.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sugdenjCommented:
write it anyway, jhance.  According to a MS DNS White Paper. NETBIOS naming is targeted for disappearance, so computer names will be DNS host names.  Not sure that avoiding WINS at this point saves any work in adding clients.  You didn't say what DNS you are using.  If it's MS, you will need to add an A record when you add a client for which you want to be able to resolve a host name.  That's hard to do if you are using DHCP.  There are products that do dynamic DNS name registration (eg Cisco CDDM).
0
 
MasseyMCommented:
I would like to see the reverse DNS lookup part... Can you send it to me at masseym@hotmail.com


0
 
jhanceCommented:
The reason I asked if sherwood would be willing to pay for it is that I've already written a utility (NetSwitcher for Windows) which does all of the component parts of this request but just doesn't automate them in the way he wants.  I'm busy enough with "real" work that I doubt I'd get around to doing this just for fun.  Sherwood, if you have a real need for this and have funds available for a custom development, please let me know.  You can email me at joe@netswitcher.com.
0
 
durcaj01Commented:
Not a problem but you will need to learn a bit of KIX scriptting to perfect it.

Copy KIX32.EXE, KIX32.dll, kix16.dll to c:\windows\system( on the NT resource KIT)

create a KIX script similar to the following and refine and perfect.....(The KIX script will need to be called from something like the login script or registry run command)



$key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP"
$dnsname = READVALUE($key,"HostName")

shell "NETSTAT -a > c:\IPCFG.TXT"


IF EXIST ("c:\IPCFG.txt")
      IF OPEN(1,"c:\IPCFG.txt") = 0
            $L = READLINE(1)
            WHILE @error = 0
              ; Read all lines until string is found
              $L = READLINE(1)
               IF INSTR($L,":nbname")
                $t = @error = 1 ; exit loop
                ; Get position in string
                $pos = INSTR($L,":nbname")
                $nbname = SUBSTR($l,$pos,-13)
               ENDIF
            LOOP
      ENDIF
   $c = CLOSE(1)      ; Close the open file

   DEL ("c:\IPCFG.txt")

   ; Strip out any spaces in $nbname
   IF INSTR($nbname,CHR(32))
      $loc = INSTR($nbname,CHR(32))
      $nbname = SUBSTR($nbname,1,$loc-1)
   ENDIF
   ; Strip out UDP $def
   IF INSTR($nbname,"UDP")
      $loc = INSTR($nbname,"UDP")
      $nbname = SUBSTR($nbname,1,$loc-3)
   ENDIF

if  $dnsname = $nbname
      exit
else
      WriteValue($key, "hostname",$nbname, REG_SZ)
endif


0
 
durcaj01Commented:
Not a problem but you will need to learn a bit of KIX scriptting to perfect it.

Copy KIX32.EXE, KIX32.dll, kix16.dll to c:\windows\system( on the NT resource KIT)

create a KIX script similar to the following and refine and perfect.....(The KIX script will need to be called from something like the login script or registry run command)



$key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP"
$dnsname = READVALUE($key,"HostName")

shell "NETSTAT -a > c:\IPCFG.TXT"


IF EXIST ("c:\IPCFG.txt")
      IF OPEN(1,"c:\IPCFG.txt") = 0
            $L = READLINE(1)
            WHILE @error = 0
              ; Read all lines until string is found
              $L = READLINE(1)
               IF INSTR($L,":nbname")
                $t = @error = 1 ; exit loop
                ; Get position in string
                $pos = INSTR($L,":nbname")
                $nbname = SUBSTR($l,$pos,-13)
               ENDIF
            LOOP
      ENDIF
   $c = CLOSE(1)      ; Close the open file

   DEL ("c:\IPCFG.txt")

   ; Strip out any spaces in $nbname
   IF INSTR($nbname,CHR(32))
      $loc = INSTR($nbname,CHR(32))
      $nbname = SUBSTR($nbname,1,$loc-1)
   ENDIF
   ; Strip out UDP $def
   IF INSTR($nbname,"UDP")
      $loc = INSTR($nbname,"UDP")
      $nbname = SUBSTR($nbname,1,$loc-3)
   ENDIF

if  $dnsname = $nbname
      exit
else
      WriteValue($key, "hostname",$nbname, REG_SZ)
endif

NOTE: You can use commands like checks for operating system to see which OS. Pipe the variables to screen so you can see you are getting the right variables.

Beyond that, you'd have to pay me.
0
 
durcaj01Commented:
Sorry. The comment is what is meant to be in the answer but my firewall fouled up.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now