• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1327
  • Last Modified:

Ip addition in command prompt

How i can add an IP and remove an IP in my local LAN card  thorugh command prompt, i know it can be done through NETSH command,but unable to find the command,
can anybody let me know the syntax for both addition and deletion .
  • 7
  • 6
  • 4
  • +5
1 Solution
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

hi, there

Route add

Manipulates network routing tables.

ROUTE [-f] [-p] [command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]

  -f           Clears the routing tables of all gateway entries.  If this is
               used in conjunction with one of the commands, the tables are
               cleared prior to running the command.
  -p           When used with the ADD command, makes a route persistent across
               boots of the system. By default, routes are not preserved
               when the system is restarted. Ignored for all other commands,
               which always affect the appropriate persistent routes. This
               option is not supported in Windows 95.
  command      One of these:
                 PRINT     Prints  a route
                 ADD       Adds    a route
                 DELETE    Deletes a route
                 CHANGE    Modifies an existing route
  destination  Specifies the host.
  MASK         Specifies that the next parameter is the 'netmask' value.
  netmask      Specifies a subnet mask value for this route entry.
               If not specified, it defaults to
  gateway      Specifies gateway.
  interface    the interface number for the specified route.
  METRIC       specifies the metric, ie. cost for the destination.

All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.

If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.

If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The '*' matches any string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.
Diagnostic Notes:
    Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
    Example> route ADD MASK IF 1
             The route addition failed: The specified mask parameter is invalid.
 (Destination & Mask) != Destination.


    > route PRINT
    > route ADD MASK METRIC 3 IF 2
             destination^      ^mask      ^gateway     metric^    ^
      If IF is not given, it tries to find the best interface for a given
    > route PRINT
    > route PRINT 157*          .... Only prints those matching 157*
    > route CHANGE MASK METRIC 2 IF 2

      CHANGE is used to modify gateway and/or metric only.
    > route PRINT
    > route DELETE
    > route PRINT


jajatiAuthor Commented:
i want to add a local IP with subnetmask .wat can be the syntax
hi, there

please make a route print and poste it here then I will help you out.

jajatiAuthor Commented:

IPv4 Route Table
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 13 20 23 4b 45 ...... Intel(R) PRO/100 VE Network Connection - Packet
Scheduler Miniport
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
      1      1     20     20     20     20      1
Default Gateway:
Persistent Routes:
NETSH INT IP ADD ADDRESS "Name of your network adapter"

Get the name to be used by typing:



Route add mask

jajatiAuthor Commented:
thanks JHans,but this process is nt working, as we have a different scene here.there are some issue with our server,and its LAN card and other plug and play devices are not visisble,so when i am trying thru NETSH it is showing unable to locate the interface.so we are trying thru route command,that may help us
jajatiAuthor Commented:
D:\Documents and Settings\jajati>Route add mask
Error: Cannot Open Networks Database file rt
Error: Cannot Open Networks Database file rt
hi, there

Looks like the TCP/IP is broken if you can not openb the networks database file.....

Here is a former article number: http://www.experts-exchange.com/Networking/Microsoft_Network/Q_21587096.html?qid=21587096

We will thank Jack for the solution if this works out.

Ok I think I found an answer...

Quoted from Earthquake on October 26th...

"The problem is in a DataBasePath value under
containing environment variables on a REG_SZ value.

You may fix it by either deleting DataBasePath value an re-create it as
REG_MULTI_SZ and using "%SystemRoot%\System32\drivers\etc" as value
(without double quotes), or either keep the REG_SZ and hardcode the
%SystemRoot% variable, that is, use C:\WINDOWS\System32\drivers\etc"
(or whatever path you have Windows folder).

For mine,
I replaced the %systemroot% with c:\windows and it worked immediately

Here  is where I found this text:

I looked on the MS Knowledge base to see whats up, - hoping to find that a recent patch did this....
I didn't find that, but it does say the value should be REG_EXPAND_SZ which makes sense as it would expand %systemroot% to it's proper value.

Thank you to Jack from the old article number

Rob WilliamsCommented:
If you wish to do it from a command line, you have to use a couple of lines so I usually use a batch file:

rem Reset network Settings for static IP
netsh interface ip set address name = "Local Area Connection" source = static addr = mask =
netsh interface ip set address name = "Local Area Connection" gateway = gwmetric = 1
netsh interface ip set dns name = "Local Area Connection" source = static addr =
netsh interface ip add dns name = "Local Area Connection" addr =
netsh interface ip show config


rem Reset network settings for DHCP
netsh interface ip set address name = "Local Area Connection" source = dhcp
netsh interface ip set dns name = "Local Area Connection" source = dhcp
netsh interface ip show config
jajatiAuthor Commented:
we have an unquie issue, we are unable to see our LAN card and plug and paly devices are not also visible,
we traied thru NETSH, it is also not working, it i saying invalid interface
do u mean that u wana release ur ip add?
ipconfig /release

then after that ipconfig /renew

in order to get a new ip add..
make sure ur network cable is being plugged in to do so..
jajatiAuthor Commented:
let me clear it more,
we have like 2 servers one is XXX and other YYY in same VLAN ,
if we will remove any IP from XXX and put it in YYY server, then our issue can be solved.

but the issue with XXX is we are unable to see our LAN card and plug and paly devices are not also visible,
we traied thru NETSH, it is also not working, it i saying invalid interface

so we are trying through CMD. as we tried through NETSH but it is also not working saying invalid interface.

also one thing we tried we put the XXX server off and then tried to put a IP which was in XXX server in YYY server, then also it did nt work,it did not take that IP.our LAN card in YYY server tells (IP acquiring)

so only solutuon to me is taking the XXX out of the same V lan server and put the server off(which is imposible) and other solution is remove the IP through CMD prompt and put the IP in YYY server.

Hope this time you guys got my issue..

so need some solution for this.
remove the nic from svr xxx, after that it can't tie up the ip & svr yyy can use it

"but the issue with XXX is we are unable to see our LAN card and plug and paly devices are not also visible"

this indicates a big issue if you can't see hardware in devmgmt.msc, you may need to open the registry & delete the entire ENUM folders or particular related hardware subhives under it:

the command to add ip address to your server

netsh interface ip set address Local static  {gateway  ip}

to remove ip address just replace the ip address with

If you are unable to see to see your NIC card there is a registry key to make the icon visible
HKLM\system\current control set\control\Network
Inside this there will be varios GUID's for for Network adapters, Network client, Network Protocol etc.
when you select one the "Default" key shows the type of Network device.
Select Network adapters
Inside this there will be more keys for each NIC card that you have. open the key, inside it there will be a key called connection
Inside this connection key there will be a DWORD "ShowIcon". Check if the value for this key is set to 1. If the key is not there or the value is something else then create a New DWORD with name ShowIcon & set the value to "1"

Reboot the machine, your NI card should be visible now.
jajatiAuthor Commented:
we are unable to see our LAN card also in the device manger i am unable to see anything.our RPC service is also down..
like i said if you can't see your nic or any pnp dev's in devmgr, either a virus or something changed your system, you can try deleting all hardware from the registry & rebooting to reinstall them
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 4
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now