Jump to content

changing nic gateway settings from command line


crp

Recommended Posts

When I enter innetsh interface ip set address name="Local Area Connection 2" gateway=nonethe system responds Ok. and the gateway address is empty.But when I enternetsh interface ip set address name="Local Area Connection 2" gateway=192.168.1.3the system responds The syntax supplied for this command is not valid. The same results happen if I enternetsh interface ip set address name="Local Area Connection 2" static 192.168.1.25 255.255.255.0 192.168.1.3So how is one supposed to be able to enable a gateway from the command line?

Link to comment
Share on other sites

Guest LilBambi
netsh interface ip set address "Local Area Connection 2" 192.168.1.x 255.0.0.0 192.168.1.3

x being the ip address for the interfacenote, there is no word static in the commandThat should give the right output.if you just need to add/remove just a gateway separately:

route add 0.0.0.0 192.168.1.3

or

route delete 192.168.1.3

Hope that helps.

Link to comment
Share on other sites

netsh interface ip set address "Local Area Connection 2" 192.168.1.x 255.0.0.0 192.168.1.3

x being the ip address for the interfacenote, there is no word static in the commandThat should give the right output.

hmm , the XP sp3 in our office say to include the word 'static' when not using dhcp.not using "static" did not work either. bug? bad documentation? limited feature?if you just need to add/remove just a gateway separately:
route add 0.0.0.0 192.168.1.3

or

route delete 192.168.1.3

Hope that helps.

wow, it has been a LONG time since I used 'route'. I'll try it when i get a chance. thanks.
Link to comment
Share on other sites

Having never played with this before, this command seemed to work for me, with a response of "Ok.":

netsh interface ip set address name="Local Area Connection" source=static addr=192.168.2.5 gateway=192.168.2.1 mask=255.255.255.0 gwmetric=1

I think it needs the "gwmetric" parameter, since I got the same error as you without it specified. I assume the value of 1 is "auto" but I couldn't find it documented anywhere.After restarting the machine those values were intact.Kevin

Link to comment
Share on other sites

[...]I think it needs the "gwmetric" parameter, since I got the same error as you without it specified. I assume the value of 1 is "auto" but I couldn't find it documented anywhere. [...]Kevin
bing Bing BING !!!Ok , I consider this is a ;) bug and :angry2: poor documentation Even though netsh interface ip set address name="Local Area Connection 2" gateway=none works just fine without the gwmetric, passing in a gateway IP address REQUIRES gwmetric= sonetsh interface ip set address name="Local Area Connection 2" gateway=192.168.1.3 gwmetric=1 does work. :( ThankS
Link to comment
Share on other sites

Guest LilBambi

Excellent! Great find there, kkehoe! :thumbsup:Shouldn't be required at all. It certainly is not required in any other OS either from the commandline.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...