I'm Aoddy.

If you lose yourself, you lose everything. — Michael Scofield

How to change default gateway on windows by command line.

by admin on November 10, 2007

    Right, you can change you default gateway on windows by route command , it’s very useful. Other than , you can add route to other network by this command too. I have example for you too. ( I get from link that :) )

Syntax route [-f] [-p] [Command[Destination] [mask Network] [Gateway] [metric Metric]] [if Interface]]

Example:

To display the entire contents of the IP routing table, type:

route print

To display the routes in the IP routing table that begin with 10., type:

route print 10.*

To add a default route with the default gateway address of 192.168.12.1, type:

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0 and the next hop address of 10.27.0.1, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a persistent route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0 and the next hop address of 10.27.0.1, type:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, the next hop address of 10.27.0.1, and the cost metric of 7, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, the next hop address of 10.27.0.1, and using the interface index 0×3, type: 

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0×3

To delete the route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, type:

route delete 10.41.0.0 mask 255.255.0.0

To delete all routes in the IP routing table that begin with 10., type:

route delete 10.*

To change the next hop address of the route with the destination of 10.41.0.0 and the subnet mask of 255.255.0.0 from 10.27.0.1 to 10.27.0.25, type:

route change 10.41.0.0 mask 255.255.0.0 10.27.0.25

Related Posts

  • No Related Post

10 thoughts on “How to change default gateway on windows by command line.

  1. Nexus says:

    I’m still wondering how to change the default gateway on windows by command line

  2. Thiago Suzin says:

    Nexus,

    Use this command:

    route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

    The route default will change to 192.168.12.1 in this case.

    []s,

    Suzin

  3. Thiago Suzin says:

    Just change “add” to “change”.

    route change 0.0.0.0 mask 0.0.0.0 192.168.12.1

    Att.,

    Suzin

  4. Deathcat says:

    Is there a way to keep the default gateway change if you restart?

  5. aoddy says:

    Hi Deathcat,
    You can put your commands into startup.bat. You can create by yourself please see all information at : http://aroundcny.com/technofile/texts/bklauncher98.html

    :D

  6. Arpi says:

    It doesn’t work on Windows XP sp3 or Windows 7. Try clearing the routing table and then put back the default route. Something like this:
    route -f
    route add -p 0.0.0.0 MASK 0.0.0.0 192.168.1.254 METRIC 10

    The routing table (route print) will look ok, but communication won’t work. You’ll have to use the graphic interface in order to enter the default gateway. First you have to change it to something else than 192.168.1.254, and then back to 192.168.1.254.
    I can’t figure out what am I missing. Or this is a bug?

  7. Pinoy says:

    I have this routes in my routing table

    Active Routes:
    Network Destination Netmask Gateway Interface Metric
    0.0.0.0 0.0.0.0 On-link 10.157.35.187 41
    0.0.0.0 0.0.0.0 10.0.0.1 10.0.0.2 4256
    0.0.0.0 128.0.0.0 10.0.0.1 10.0.0.2 4256

    Do you know how to remove only this ” 0.0.0.0 0.0.0.0 10.0.0.1 10.0.0.2 4256″

  8. Swanhild says:

    Very quickly this web site will be famous amid all blogging people, due to it’s fastidious content

  9. My brother suggested I may like this website. He was once totally right.
    This put up actually made my day. You can not imagine just how so much time I had spent for this information!
    Thanks!

  10. monoceros says:

    Hi, is it possible to change metric that has “on-link” gateway?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">