Solved

Script to set Netbios name to be DNS name.

Posted on 1998-08-13
9
375 Views
Last Modified: 2013-12-16
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
Comment
Question by:sherwood
9 Comments
 

Expert Comment

by:gosowski
ID: 1757634
this is a security issue with 128 bit encryption,,,,,  

what is it precisely you need it for????
0
 
LVL 1

Author Comment

by:sherwood
ID: 1757635
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
 
LVL 32

Expert Comment

by:jhance
ID: 1757636
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Expert Comment

by:sugdenj
ID: 1757637
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
 
LVL 10

Expert Comment

by:MasseyM
ID: 1757638
I would like to see the reverse DNS lookup part... Can you send it to me at masseym@hotmail.com


0
 
LVL 32

Expert Comment

by:jhance
ID: 1757639
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
 
LVL 1

Accepted Solution

by:
durcaj01 earned 300 total points
ID: 1757640
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
 
LVL 1

Expert Comment

by:durcaj01
ID: 1757641
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
 
LVL 1

Expert Comment

by:durcaj01
ID: 1757642
Sorry. The comment is what is meant to be in the answer but my firewall fouled up.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question