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 address. It is the primary component in the configuration of routers to ensure internetwork connectivity as packets are routed to their destination. For a 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:

Router Table

When the router receives a packet with a destination IP address of 172.16.1.X (‘X’ being a value between 1and 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:

client routing table

Any traffic destined to 10.1.1.X will be sent out the interface configured with the IP address of 192.168.0.30to 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.

ipconfig

______________________________________________________________________________

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 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

Route add

3. To verify enter in the following command to view the IPv4 routing table.

route print -4

verify route

______________________________________________________________________

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

route delete

3. To verify enter in the following command to view the IPv4 routing table.

route print -4

route removed

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 keyHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes

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.

Print Friendly

Comments

comments

Bài viết liên quan