Solved

Script to set Netbios name to be DNS name.

Posted on 1998-08-13
9
367 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

12 Experts available now in Live!

Get 1:1 Help Now