Announcement

Collapse
No announcement yet.

Add Gateway using CMD

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add Gateway using CMD

    Hello

    I'm trying to create a batch file the would automatically add a static gateway to a DHCP enabled NIC.

    We control internet usage at our office by adding or removing the gateway from the workstations.

    I already found the command to remove the gateway, and it is this:
    Code:
    netsh interface ip delete address "Local Area Connection" gateway=all
    I made sure my NIC is named "Local Area Connection".

    I read this wonderful article, but to no avail. I tried to manipulate the following line:
    Code:
    netsh interface ip set dns "Local Area Connection" static 192.168.0.200
    I tried changing the "dns" parameter to "gateway" and to "gw", either with a metric at the end of the ip address or without. All four combinations did not work, so I must be doing something wrong...

    I also tried:
    Code:
    netsh interface ip set address "Local Area Connection" gateway=(gateway address) (metric)
    Didn't work too...

    Can anyone help please?

    Thanks a lot.

  • #2
    Re: Add Gateway using CMD

    http://support.microsoft.com/kb/157025
    ________
    Chevrolet Opala
    Last edited by DYasny; 6th March 2011, 18:47.
    Real stupidity always beats Artificial Intelligence (c) Terry Pratchett

    BA (BM), RHCE, MCSE, DCSE, Linux+, Network+

    Comment


    • #3
      Re: Add Gateway using CMD

      This is the batch file we use here:
      Code:
      set address name="Local Area Connection" source=static addr=[IP Address] mask=255.255.255.0
      set address name="Local Area Connection" gateway=[GW IP Address] gwmetric=0
      It is part of a bigger batch, so it doesn't have much meaning like this. But this is the command. We saved this as IPCONFIG.TXT file and run it with the command: netsh exec ipconfig.txt .
      Hope this is what you were looking for.

      Sorin Solomon


      In order to succeed, your desire for success should be greater than your fear of failure.
      -

      Comment


      • #4
        Re: Add Gateway using CMD

        Thank you very much!

        The complete command is:
        Code:
        netsh interface ip set address name="Local Area Connection" gateway=[ip address of gateway] gwmetric=0

        Comment

        Working...
        X