RayRay459 has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know of a way to set the ip address, subnet mask and default gateway using perl?
Thanks in advance
Ray
  • Comment on setting ip address on win32 machine in perl

Replies are listed 'Best First'.
Re: setting ip address on win32 machine in perl
by joefission (Monk) on Aug 17, 2001 at 21:44 UTC
    Never seen any modules to do this. Here's how I'd do it on NT 4 (and I hope there's an easier way than this...)

    You'll want to use Win32::TieRegistry. Connect to
    HKLM/SYSTEM/CurrentControlSet/Control/Services/Tcpip/Linkage/

    Look at the Bind (maybe Export, but Bind should work) value. The device is contained in the data.
    Now, connect to
    HKLM/SYSTEM/CurrentControlSet/Control/Services/$device/Parameters/TcpipThe IP address, subnet mask, and default gateway are values within.

    Use regedt32 to see these values, it will help you write the regex for the device.

      Thats what my original idea was. A Reg Hack. I too was looking for something more perlish :). Thanks again for your input though. I do appreciate it. Ray
Re: setting ip address on win32 machine in perl
by ralphie (Friar) on Aug 18, 2001 at 03:43 UTC
    the registry is where a win32 machine is going to store that information. if you want to modify the ip settings, you'll have to do it there. it's as perlish as modifying whatever networks file in which a given linux distro would store the information.