Jump to content
crp

changing nic gateway settings from command line

Recommended Posts

crp

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Temmu

suggest when using route, to put -p at the end so when u rebooth, the route stays put.lilbambi, impressive. :ph34r:

Share this post


Link to post
Share on other sites
LilBambi

Thanks :)Yes, good idea about the -p if you are making it permanent.Even more arguments listed here for Route.

Share this post


Link to post
Share on other sites
crp
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.

Share this post


Link to post
Share on other sites
kkehoe

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

Share this post


Link to post
Share on other sites
Temmu

you can also type route printto see what you've done to yourself.

Share this post


Link to post
Share on other sites
crp
[...]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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Temmu

good catch, kkeoh!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...