Please Support by checking out some of the sponsors to the right

Wednesday, February 25, 2009

How to change IP from command prompt

A few days ago I was wondering about how to change IP address from a command prompt. I use windows vista and it has essentially made every process lengthier than it used to be. I often winder how things wrk and especially IP related tasks that used to be so simple like right clicking on the network icon and changed the properties. and in Vista, the process has gone even more complicated.

If you have been thinking about how to change IP address from a command line prompt then this article is for you

The process of changing an IP address is pretty simple with commad prompt. It simplifies the process and you can even use it with a batcjh file. First let us take a look at the command line to change IP address

IP address configuration command s calld "netsh".

The syntax of the command is

netsh interface set ip address "Local Area Connection" static/dhcp ip address subnet mask gateway

Let us assume now that you want to release the ip address then use the following command line from the command prompt.

netsh interface set ip address "Local Area Connection"

When you use this command you will get an error message saying " Elevation required.

In windows vista this is an important issue with everything. Dear Friends welcome to the Administrator everything hell.

Ok lets start again

click the start icon. Type cmd and see the cmd.exe come on the top. Right click on the cmd.exe icon above and click run as administrator.
Type the command in it and voila. your IP settings will be emptied.


To check type ipconfig in the same command prompt and get your ip address fields empty.

Anopther point to be noted here is that your DNS entries are not deleted or changed this way so dont worry.

Ok let us suppose now you want to change you Local Area Connection 2's properties we want to change the ip address to 192.168.0.10/24 or simply subnet mask 255.255.255.0 and gateway

So the command would be
interface set ip address "Local Area Connection 2" static 192.168.0.10 255.255.255.0 192.168.0.1

We have successfuly changed the properties of Local Area Connction 2. Check it with ipconfig command.

Note: Do not forget that netsh command wont function properly without administrator rights.

Now we have set static address
Lets see if we have DHCP and we want to automatically assign new address

There are two ways to accomplish this task from command prompt.

First
Run the cmd.exe with adminitrator privilages then type these commands in order

1. ipconfig /release
2. ipconfig /renew
To check the new IP type ipconfig /all

Second
Run the cmd.exe with adminitrator privilages then type these commands

1. netsh interface set ip address "Local Area Connection"
2. netsh interface set ip address "Local Area Connection" dhcp
3. ipconfig

Now you can successfully change your IP address from the command prompt. In the next article I will explain how to use this in batch file


References

How to use a batch file on command prompt lines







Search the Web:

No comments:

Post a Comment