IP "Alternate configuration"

Discussion in 'Scripting' started by SubnetJO, May 20, 2009.

  1. SubnetJO

    SubnetJO Guest

    Hi all.

    Surely you know that if you set a network interface to be configured
    dinamically by a DHCP server, you have the "Alternate Configuration" TAB
    where you can place a static IP configuration in the case the dynamic
    configuration process fails (for any reason).

    I'd like to set the (IP) "alternate configuration" programmatically, using a
    script (VBS, VB, PowerShell, Netsh... doesn't matter), and I couldn't find a
    documentation about.

    Can any of you provide me a way to accomplish this task?
    A sample code would be great!

    Really thank you for your help.
    SubnetJO, Italy
     
    SubnetJO, May 20, 2009
    #1
    1. Advertisements

  2. I cannot see any "Alternate Configuration" tab on my machine. Regardless of
    this, the usual command to set IP parameters is netsh.exe. You can use it to
    set fixed IP addresses or use DHCP.
     
    Pegasus [MVP], May 21, 2009
    #2
    1. Advertisements

  3. SubnetJO

    SubnetJO Guest

    Thank for your reply.

    I mean...
    Take a WinXPpro machine.
    Control Panel > Network Connections

    On an Ethernet Interface:
    Right click > properties

    On the general tab, choose "Internet Protocol (TCP/IP)" and then click the
    Properties button.

    In the "Internet Protocol (TCP/IP) Properties" window, If the interface is
    configured to "Obtain an IP address automatically" (on the "General tab"),
    you can see the "alternate configuration" tab too.

    On this tab you can set a static IP configuration for the case the automatic
    configuration (DHCP) fails.

    I can set the IP configuration in many ways, including the Netsh.exe
    utility, but I didn't find a way to programmatically place the alternate IP
    configuration.

    Thanks,
    SubnetJO, Italy
     
    SubnetJO, May 21, 2009
    #3
  4. SubnetJO

    SubnetJO Guest

    Thank for your reply.

    I mean...
    Take a WinXPpro machine.
    Control Panel > Network Connections

    On an Ethernet Interface:
    Right click > properties

    On the general tab, choose "Internet Protocol (TCP/IP)" and then click the
    Properties button.

    In the "Internet Protocol (TCP/IP) Properties" window, If the interface is
    configured to "Obtain an IP address automatically" (on the "General tab"),
    you can see the "alternate configuration" tab too.

    On this tab you can set a static IP configuration for the case the automatic
    configuration (DHCP) fails.

    I can set the IP configuration in many ways, including the Netsh.exe
    utility, but I didn't find a way to programmatically place the alternate IP
    configuration.

    Thanks,
    SubnetJO, Italy
     
    SubnetJO, May 21, 2009
    #4
  5. "Tabs" are used in GUIs (Graphical User Interfaces). Since you're after a
    scriptable solution you need something that controls the same parameters
    that your tab does. As I mentioned before, netsh.exe can do this. The
    following command is an example: It will set the adapter to DHCP mode.

    netsh interface ip set address "Local Area Connection" DHCP

    If you want to alter between DHCP and a fixed address then you need two
    netsh commands: One to enable DHCP, the other to set fixed addresses (which
    are embedded in your command).
     
    Pegasus [MVP], May 21, 2009
    #5
  6. SubnetJO

    SubnetJO Guest

    Sure...
    I want to programmatically change the parameters usually altered via GUI, in
    the TAB "Alternate Conguration".

    Yes.
    I want a script that changes that parameters and then re-open the tab and
    find them configured.

    I hope I have been more clear, now.

    What you suggest is not what I mean.
    I'm already able to configure an interface via Netsh, and I don't want to
    "alternate" between two interface configurations (fixed and dynamic).

    I want to configure my interface to obtain the configuration automatically
    via DHCP.
    OK, assuming I have called my interface "LAN", I can use the command "set
    addr LAN DHCP" under the netsh to accomplish this.

    Now I have my interface "LAN" DHCP enabled...
    In the case of a failure of the DHCP service (after 1 munute), the interface
    "LAN" will be (automatically, silently) configured with the values (IP subnet
    mask, gateway...) set on the ALTERNATE CONFIGURATION TAB.

    I don't want to fix the LAN interface configuration!
    I want to still have it configured via DHCP!
    I want to set that ALTERNATE (fixed) IP configuration.

    Doing this via GUI is an easy job, I want to do the same via VBS (preferred).

    Is it possible?

    I hobe I was clearer

    SubnetJO, Italy
     
    SubnetJO, May 21, 2009
    #6
  7. SubnetJO

    \Rems Guest

    The script (startup script) should edit the registry on the client,
    First determine the currently connected NIC and retrieve the interface's GUID.
    Then the script will,
    - add the Alternate Configurations to a new subkey under the DHCP service
    configuration with a reference to the interface's GUID. The full
    configuration is stored in one Binary registry entry in this subkey.
    - Then to enable the Option for Alternate Config for the actual network
    interface, create a reference to the new subkey under the existing
    interface's GUID subkey of the tcpip Service parameters in the registry.


    \Rems
     
    \Rems, May 27, 2009
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.