Static Routes - Create or Remove

Page 1 of 4 123 ... LastLast
    Static Routes - Create or Remove

    Static Routes - Create or Remove

    How to Create or Remove Static Routes in Windows 7 and 8
    Published by
    Designer Media Ltd


    How to Create or Remove Static Routes in Windows 7 and 8


       Information
    This tutorial will show you how to create or remove static routes used to override the default gateway configured for certain networks. In this section I will be describing what a routing table is and how static routes play a role in this configuration.

    What is a Routing Table?

    A routing table is table that contains dictates who and what interface traffic should be sent to depending on the destination IP address. It is the primary component in the configuration of routers to ensure internetwork connectivity as packets are routed to their destination. For a Windows machine it is used to override the default gateway configured so you can introduce multiple networks and have the two networks be able to communicate with each other.

    For example, consider this small routing table configured on a router:
    Static Routes - Create or Remove-router-table.png
    When the router receives a packet with a destination IP address of 172.16.1.X ('X' being a value between 1 and 254) it will first look at it's routing table to find a corresponding route. With the scenario there is route that matches telling the router to route the packet to 10.1.1.2. From there 10.1.1.2 will look at its routing table and look for a similar route telling it where to forward the packet destined to the 172.16.1.0 network. This will continue until the packet reaches its destination. This is the main concept of how routers work. For Windows machines the same logic applies with the routing table being used to determine what interface and destination gateway/router to send the traffic to.

    For example:
    Static Routes - Create or Remove-client-routing-table.png
    Any traffic destined to 10.1.1.X will be sent out the interface configured with the IP address of 192.168.0.30 to a destination gateway of 192.168.0.110. This may seem no different to normal however when put into perspective it can be seen that the default gateway configured is 192.168.0.1. This routing table overrides this use and allows traffic to be routed to any device you want.
    Static Routes - Create or Remove-ipconfig.png
    ______________________________________________________________________________

    How do static routes come into this?

    By default a routing table will only contain routes relevant to the default gateway and therefore does little to change the routing process. Static routes are manual entries made into the table to override the default gateway for allowing traffic to be exchanged between networks. The previous examples provided were examples of static routes made. They will typically have a gateway different to the default one configured as well as a low value for the metric.


       Warning
    You need to be an Administrator to complete this.


       Tip
    This also works for Windows 8 and 8.1. The same concepts apply to IPv6 as well should you have an environment to support it


       Note
    Any route of '0.0.0.0' with a mask of '0.0.0.0' is a default route and is used for traffic going to your default gateway. DO NOT DELETE it otherwise all network traffic will be dropped.

    Also, remember to configure a similar static route to go back to the source network otherwise reply packets will be dropped or sent to the default gateway and routed to the internet when not desired.





    Add

    Add a Static Route into the Routing Table


    a). Calculate the route you are going to add. You need to know the network, subnet mask and gateway that will be used. For example, I want to add a route for any traffic destined to 10.1.2.0 with a mask of 255.255.255.0 to go to a gateway of 192.168.0.6.
    2. Entering the following command changing the variables as needed:
    route add -p {network} mask {subnet mask} {gateway}
    NOTE: If you do not receive an 'OK!' message then a parameter was wrong or missing
    Static Routes - Create or Remove-route-add.png
    3. To verify enter in the following command to view the IPv4 routing table.
    route print -4


    Static Routes - Create or Remove-verify-route.png
    ______________________________________________________________________




    Delete

    Delete a Static Route from the Routing Table


    2. Entering the following command changing the variables as needed:
    route delete {network} mask {subnet mask} {gateway}
    NOTE: If you do not receive an 'OK!' message then a parameter was wrong or missing
    Static Routes - Create or Remove-route-delete.png
    3. To verify enter in the following command to view the IPv4 routing table.
    route print -4

    Static Routes - Create or Remove-route-removed.png
    Now you're done! Your computer should now be routing traffic to the relevant gateway based on the IP address that you wish to access.

    Hope This Helps,
    Josh :)



  1. Posts : 24,479
    Windows 7 Ultimate X64 SP1
       #1

    Josh this looks well thought out. I personally don't know what it means, but it's well done.
      My Computer


  2. Posts : 2,298
    Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
    Thread Starter
       #2

    Britton30 said:
    Josh this looks well thought out. I personally don't know what it means, but it's well done.
    Cheers Gary! It's for networks where there are two routers that you can use to access other networks. Since you can't configure multiple default gateways you would use static routes to dictate what router to use given the destination network that you wish to reach. For example, I may setup a static route that says, for any traffic going Google it should use my 2nd router but everything else just use the default gateway. Funky scenario but the concept applies

    There was a couple of people that was doing some static routing on the network and sharing forum so I thought to make a tutorial to make it easier to explain and not have to use the post template which doesn't allow images.

    Thanks!,
    Josh :)
      My Computer


  3. Posts : 24,479
    Windows 7 Ultimate X64 SP1
       #3

    Oh, I see now. You can possibly set multiple static routes to one gateway then?
      My Computer


  4. Posts : 2,298
    Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
    Thread Starter
       #4

    Yep, you certainly can! I may setup a static route that says to go to sevenforums and eightforums use one router and to go to vistaforums and nineforums use the other router.

    Quite literaly, the possibilities are endless
      My Computer


  5. Posts : 24,479
    Windows 7 Ultimate X64 SP1
       #5

    Cool stuff, thanks.
      My Computer


  6. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #6

    route -p add 10.10.10.0 mask 255.255.255.0 192.168.1.1

    So add -p .... this will make it permanent (what you want in most cases, otherwise the setting will be gone after reboot). In will be stored in registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes
      My Computer


  7. Posts : 2,298
    Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
    Thread Starter
       #7

    Kaktussoft said:
    route -p add 10.10.10.0 mask 255.255.255.0 192.168.1.1

    So add -p .... this will make it permanent (what you want in most cases, otherwise the setting will be gone after reboot). In will be stored in registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes
    Thanks! Tutorial updated.

    I never had an issue after reboot though personally Though it might have something to do with me using a static IP address on my interface I do not know. Normally I do static routing or use a routing protocol at the router itself rather than client devices. Either way cheers for the heads up :)

    Josh
      My Computer


  8. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #8

    Normally you configure routing in the router! Normaly static routes are defined to connect 2 subnets, let's call it subnetA and subnetB.

    All computers on subnetA have to know where subnetB is..... so configure route to subenetB on subnetA's defaultgateway.

    All computers on subnetB have to know where subnetA is..... so configure route to subenetA on subnetB's defaultgateway.
      My Computer


  9. Posts : 2,298
    Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
    Thread Starter
       #9

    Kaktussoft said:
    Normally you configure routing in the router! Normaly static routes are defined to connect 2 subnets, let's call it subnetA and subnetB.

    All computers on subnetA have to know where subnetB is..... so configure route to subenetB on subnetA's defaultgateway.

    All computers on subnetB have to know where subnetA is..... so configure route to subenetA on subnetB's defaultgateway.
    I would completely agree with you! :) Though my reason for this is that most home routers do not support the use of routing protocols (RIP, OSPF, ISIS you name it) or even static routing. They just have a default route to the internet...

    Still, being able to do it on the client end can be useful for the average techy home user who has multiple subnets. Plus, scalability is typically not an issue for home users so manual configuration shouldn't be an issue.

    Josh :)
      My Computer


 
Page 1 of 4 123 ... LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:45.
Find Us