Solved

Ip addition in command prompt

Posted on 2006-06-16
22
1,283 Views
Last Modified: 2008-01-09
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 .
0
Comment
Question by:jajati
  • 7
  • 6
  • 4
  • +5
22 Comments
 
LVL 14

Expert Comment

by:FriarTuk
ID: 16918301
0
 
LVL 14

Expert Comment

by:FriarTuk
ID: 16918304
0
 
LVL 14

Expert Comment

by:FriarTuk
ID: 16918309
0
 
LVL 9

Expert Comment

by:cooledit
ID: 16918547
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 255.255.255.255.
  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 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
             The route addition failed: The specified mask parameter is invalid.
 (Destination & Mask) != Destination.

Examples:

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

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

C:\>


Cooledit
0
 

Author Comment

by:jajati
ID: 16918795
hi
i want to add a local IP 192.168.0.168 with subnetmask 255.255.255.0 .wat can be the syntax
0
 
LVL 9

Accepted Solution

by:
cooledit earned 500 total points
ID: 16918804
hi, there

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

Cooledit
0
 

Author Comment

by:jajati
ID: 16918817


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
          0.0.0.0          0.0.0.0      192.168.0.5    192.168.0.187      1
        127.0.0.0        255.0.0.0        127.0.0.1        127.0.0.1      1
      192.168.0.0    255.255.255.0    192.168.0.187    192.168.0.187     20
    192.168.0.187  255.255.255.255        127.0.0.1        127.0.0.1     20
    192.168.0.255  255.255.255.255    192.168.0.187    192.168.0.187     20
        224.0.0.0        240.0.0.0    192.168.0.187    192.168.0.187     20
  255.255.255.255  255.255.255.255    192.168.0.187    192.168.0.187      1
Default Gateway:       192.168.0.5
===========================================================================
Persistent Routes:
  None
0
 
LVL 32

Expert Comment

by:jhance
ID: 16918836
NETSH INT IP ADD ADDRESS "Name of your network adapter" 10.0.0.5 255.0.0.0

Get the name to be used by typing:

NETSH INT IP SHOW IPADDRESS
0
 
LVL 9

Expert Comment

by:cooledit
ID: 16918839


ok,,,,try

Route add 192.168.0.168 mask 255.255.255.0

Cooledit
0
 

Author Comment

by:jajati
ID: 16918845
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
0
 

Author Comment

by:jajati
ID: 16918863
D:\Documents and Settings\jajati>Route add 192.168.0.168 mask 255.255.255.0
Error: Cannot Open Networks Database file rt
Error: Cannot Open Networks Database file rt
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 9

Expert Comment

by:cooledit
ID: 16918899
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
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
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:
http://forum.osnn.net/archive/index.php/t-82503.html

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


Cooledit
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 16919463
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 = 10.0.0.99 mask = 255.255.255.0
netsh interface ip set address name = "Local Area Connection" gateway = 10.0.0.254 gwmetric = 1
netsh interface ip set dns name = "Local Area Connection" source = static addr = 24.222.123.123
netsh interface ip add dns name = "Local Area Connection" addr = 24.222.123.456
netsh interface ip show config
pause

*************************************************

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
pause
0
 
LVL 7

Expert Comment

by:Kumar_Jayant123
ID: 16921471
0
 

Author Comment

by:jajati
ID: 16925346
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
0
 
LVL 4

Expert Comment

by:456838
ID: 16925460
do u mean that u wana release ur ip add?
cmd
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..
0
 

Author Comment

by:jajati
ID: 16925750
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.
0
 
LVL 14

Expert Comment

by:FriarTuk
ID: 16926006
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:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum
0
 
LVL 4

Expert Comment

by:SunshineVK
ID: 16926217
Hi,

the command to add ip address to your server

netsh interface ip set address Local static 192.168.0.168  255.255.255.0  {gateway  ip}

to remove ip address just replace the ip address with 0.0.0.0

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.
0
 

Author Comment

by:jajati
ID: 16932121
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..
0
 
LVL 14

Expert Comment

by:FriarTuk
ID: 16939752
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
0
 
LVL 14

Expert Comment

by:FriarTuk
ID: 17054894
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

What is IRC? IRC (Internet Relay Chat) is a form of communication between multiple users. It is available freely to anyone with inernet access. IRC is a great way to communicate with others e.g. There is an IRC channel for Ubuntu Linux, which is fo…
Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now