Sign in with
Sign up | Sign in
Closed

Is Changing IP Addresses Type in One Click as Per the Available Network Possible?

This Tutorial addresses:
  • IP Address

When working in a Local Area Network, the IP address of the system is to be kept unchanged and is thus set static by the user. However beyond the Local Area Network, keeping the static IP address might cause troubles sometimes. The best solution in such scenarios is to keep the IP address dynamic, i.e. it can automatically obtain the IP address from the DHCP server that is available in the network.

It is a bit tiring process to repeatedly change the IP address from static to dynamic and then back to static each time there is a change in network. Since the process requires the users to go to the Control Panel > Network and Sharing Center and then configuring the IP address, the entire practice is time taking, and not much feasible when it comes to practical grounds. Same problem is encountered in case of DNS address. It also needs to be toggled between automatic and static addresses according to network mode. This address toggling would have been so easy if it could be done by a single-click.

Well!!

Here’s the solution. Apart from going through the lengthy process of changing IP address type from static to dynamic and vice versa through the Control Panel, you can also create two batch files which, when executed using administrative privileges, automatically switch the IP addressing system from one type to another.

Amongst the two batch files, one stores command for setting address type to automatic, whereas the other stores command to reset the address type back to static, assigning the computer a static IP address that has been already specified in the batch file.

Steps for creating the batch file to change the address type to static in a single click:

  1. Open Notepad.
  2. Type the given command (for IP address)
    netsh interface ipv4 address “Local Area Connection” static <IP address> <subnet mask> <default gateway>

  3. Type the given command (for DNS address)
    netsh interface ipv4 set dns servers “Local Area Connection” static <dns address> primary

  4. Save this file as “Static.bat”. (You can save the file with any name you want, but the extension of the file must always be .BAT).


  • Note: This file is used to set static IP address and DNS address to the active LAN card named “Local Area Connection”.

    Steps for creating the batch file to change the address type to dynamic in a single click:

    1. Open Notepad.
    2. Type the given command (for IP address).
      netsh interface ipv4 set address “Local Area Connection” dhcp

    3. Type the given command (for DNS address).
      netsh interface ipv4 set dns servers “Local Area Connection” dhcp

    4. Save this file as “Dynamic.bat”. (You can save the file with any name you want, but the extension of the file must always be .BAT).


  • Note: This file is used to set IP address and DNS address to automatic.
    Can't find your answer ? Ask !