Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Static Routes - Create or Remove



Static Routes - Create or Remove

How to Create or Remove Static Routes in Windows 7 and 8
Published by Shadowjk
05 Feb 2014
Published by

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


information   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:
Name:  Router Table.png
Views: 2475
Size:  74.7 KB
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:
Name:  client routing table.png
Views: 2475
Size:  38.6 KB
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.
Name:  ipconfig.png
Views: 2484
Size:  49.4 KB
______________________________________________________________________________

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   Warning
You need to be an Administrator to complete this.


Tip   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   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
1. Open an Elevated Command Prompt.
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
Name:  Route add.png
Views: 2422
Size:  31.7 KB
3. To verify enter in the following command to view the IPv4 routing table.
route print -4


Name:  verify route.png
Views: 2418
Size:  47.4 KB
______________________________________________________________________




Delete
Delete a Static Route from the Routing Table
1. Open an Elevated Command Prompt.
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
Name:  route delete.png
Views: 2452
Size:  32.2 KB
3. To verify enter in the following command to view the IPv4 routing table.
route print -4

Name:  route removed.png
Views: 2468
Size:  38.3 KB
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
.

05 Feb 2014   #1
Britton30
Microsoft MVP

Windows 7 Ultimate X64 SP1
 
 

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

My System SpecsSystem Spec
.

06 Feb 2014   #2
Shadowjk

Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
 
 

Quote   Quote: Originally Posted by Britton30 View Post
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 System SpecsSystem Spec
06 Feb 2014   #3
Britton30
Microsoft MVP

Windows 7 Ultimate X64 SP1
 
 

Oh, I see now. You can possibly set multiple static routes to one gateway then?
My System SpecsSystem Spec
06 Feb 2014   #4
Shadowjk

Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
 
 

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 System SpecsSystem Spec
06 Feb 2014   #5
Britton30
Microsoft MVP

Windows 7 Ultimate X64 SP1
 
 

Cool stuff, thanks.
My System SpecsSystem Spec
06 Feb 2014   #6
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

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 System SpecsSystem Spec
06 Feb 2014   #7
Shadowjk

Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
 
 

Quote   Quote: Originally Posted by Kaktussoft View Post
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 System SpecsSystem Spec
06 Feb 2014   #8
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

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 System SpecsSystem Spec
06 Feb 2014   #9
Shadowjk

Windows 7 Professional x64 SP1 ; Windows Server 2012 R2 Standard
 
 

Quote   Quote: Originally Posted by Kaktussoft View Post
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 System SpecsSystem Spec
Comment

 Static Routes - Create or Remove




Tutorial Tools



Similar help and support threads for2: Static Routes - Create or Remove
Windows 7 Tutorial Category
Solved Configuring Static Routes Network & Sharing
Static Routes on Windows - PC with 2 NICs connected to 2 routed nets Network & Sharing
User Group - Create New or Delete Tutorials
Upgrade Routes Installation & Setup
How can you create both a static and dynamic network? Network & Sharing

Our Sites

Site Links

About Us

Find 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 01:46 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33