Solved

Script to set Netbios name to be DNS name.

Posted on 1998-08-13
9
369 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
 
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
Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a trade show? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Several part series to implement Internet Explorer 11 Enterprise Mode
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now