Link to home
Start Free TrialLog in
Avatar of jajati
jajati

asked on

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 .
Avatar of FriarTuk
FriarTuk

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
Avatar of jajati

ASKER

hi
i want to add a local IP 192.168.0.168 with subnetmask 255.255.255.0 .wat can be the syntax
ASKER CERTIFIED SOLUTION
Avatar of cooledit
cooledit
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jajati

ASKER



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


ok,,,,try

Route add 192.168.0.168 mask 255.255.255.0

Cooledit
Avatar of jajati

ASKER

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
Avatar of jajati

ASKER

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
hi, there

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

Here is a former article number: https://www.experts-exchange.com/questions/21587096/Error-Cannot-Open-Networks-Database-file-rt.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
Avatar of Rob Williams
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
Avatar of jajati

ASKER

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?
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..
Avatar of jajati

ASKER

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:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum
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.
Avatar of jajati

ASKER

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