Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script to set Netbios name to be DNS name.

Posted on 1998-08-13
9
Medium Priority
?
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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 600 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 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