How to force traffic though a chosen interface in Windows 8.1?

Windows 8.1 seems to be able to detect dead routes and picks up the default gateway or next best route for routing.

I have a requirement where I want traffic for specific destinations to "always" go through the Interface that I pick and if that interface is not providing a path from some reason then I want the communication to fail instead of switching to the next best interface.

How do I achieve this? I already tried EnableICMPRedirect and DeadGWDetectDefault registry settings and disabling Auto Metric on the interface through which I want to route this traffic.

Any clues would help.

Thanks

GW

December 1st, 2013 8:04am

What you could do is use the routing table locally to test this. So you can add a route command to add the routes based on your requirements

http://technet.microsoft.com/en-us/library/cc757323(v=WS.10).aspx

Investigate the metric and interface option as you don't want to give a machine only one route. Additionally once you've got those sorted you can use dhcp to distribute the information around your network.

Free Windows Admin Tool Kit Click here and download it now
December 1st, 2013 9:47am

  I would leave the default gateway blank and specify static routes to direct the traffic to the required interface. If that interface is not available, routing should fail.

  Does 8.1 really detect a default gateway if you don't specify one? I admit I have never tried. 

December 2nd, 2013 1:40am

Thanks. I tried that already. I have persistent route going out an interface. Irrespective of whether I provide a gateway or not, this is what happens when I ping the target IP Address. I get a response "Host unreachable" at first instance and then it presumable marks that as a bad route and start going out my default router.

Just in case I created some confusion. I did not intend to say that it detects a default gateway. I just meant that it picks and alternate path to reach the destination.

Thanks

GW

Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2013 3:38am

Thanks. I already have persistent route going out an interface. This is what I am trying to say.

Let us say that I have two connected interfaces. Wi-Fi interface and the Ethernet interface.

The Ethernet interface is a configured for DHCP and also gets a default gateway. Let us say that this is 192.168.1.0/24 with gateway as 192.168.1.254 as the default gateway.

The Wi-Fi interface has a static IP as 10.1.1.1/24 and no gateway specified.

I do "route -p add 200.200.200.200 10.1.1.1"

From the above, it is obvious that 10.1.1.1 cannot take me to 200.200.200.200

When I try pinging 200.200.200.200 from this system, it first tries to go out 10.1.1.1 and then falls back to 192.168.1.1 and hence 192.168.1.254 after getting host unreachable at first instance.

I want this only for this system so cannot make changes on any other device/system.

Thanks

GW

 

Thanks

GW

December 2nd, 2013 3:48am

Hi, somewhere on the 10.1.1.1 will be a router to the 200.200.200.200 address. For example if the router to the 200 network is 10.1.1.254 then you would enter:

route add 200.200.200.200 MASK 255.255.255.255 10.1.1.254 METRIC 1 IF 1

The above will route traffic destined for 200.200.200.200 (only, not 200.200.200.201) to 10.1.1.254. The IF number is the interface number of the NIC (Wi-Fi or Wired) that the route will use.

When you do a "route print" it will list the interfaces.

If you want to route all 200.200.200.0/24 traffic through the 10.x network then you'd enter:

route add 200.200.200.0 MASK 255.255.255.0 10.1.1.254 METRIC 1 IF 1

The metric refers to the route order. For example if you had 2 routes then it would use the lowest metric route first. The gateway is the next hop - after that it's down to the router to send the traffic to the next hop/end destination.

-p will persist the route after reboots.

Hope that helps...

Free Windows Admin Tool Kit Click here and download it now
December 3rd, 2013 10:22pm

Thanks.

Here is what I am trying to say.

I tried to send the traffic to a black hole to test this out. When I add a route and then do a ping to 200.200.200.200, the first response is "destination host unreachable" and then from second ping onwards, I get a response.

When I run sniffer, I see 3 ARP requests going out of that interface (10.x) and after that fails, I see the other interface (192.168.x) sending a ping request to 200.200.200.200.

This indicates that the system is able to mark a route bad and switch over to the next available route which in my case is the default gateway.

I want to stop this behaviour and make sure that the traffic either goes out 10.x interface or simply times out.

-GW

December 10th, 2013 12:03pm

I doubt that there is any way to do that. IP routing is based on a "best effort" philosophy.

It first tries the most specific route and if that fails tries the next best. This continues until it succeeds or all efforts fail. 

Free Windows Admin Tool Kit Click here and download it now
December 10th, 2013 10:45pm

Is it really?

I thought this behaviour is okay for a device that is running a routing protocol.

Why should a windows host that does not run a routing protocol identify next available route to a destination?

Thanks

-GW

December 12th, 2013 9:19am

Because it is basic IP routing (or forwarding) practice. The first check is whether the target is in the same IP subnet - if it is it is delivered directly using the target's MAC address. If not the routes in the routing table are tried in order, starting with the most specific (24-bit mask or host address). If none match the default route is used.

 
Free Windows Admin Tool Kit Click here and download it now
December 13th, 2013 1:01am

With PowerShell you should be able to view the applicable routes and modify them accordingly to alter this behavior:

# you can determine your adapters with

Get-NetAdapter -IncludeHidden

# then you can see what routes are associated with what adapter interface (lets assume your wifi interface is 4 and your loopback is 1)

Get-NetRoute -AddressFamily IPv4

# you will get your specific interface index, destination prefix, nexthop and the routemetric

# you can then set a specific route policy using:

New-NetRoute -DestinationPrefix "200.200.200.200/32" -InterfaceIndex 1 -RouteMetric 256

New-NetRoute -DestinationPrefix "200.200.200.200/32" -InterfaceIndex 4 -NextHop 10.1.1.1 -RouteMetric 0

# you can modify the configuration with:

Set-NetRoute -DestinationPrefix "200.200.200.200/32" -InterfaceIndex 4 -NextHop 192.168.10.1 -RouteMetric 0

# finally, you can remove the specific route or all the routes with:

Remove-NetRoute -DestinationPrefix "200.200.200.200/32" -InterfaceIndex 1 -Confirm:$false

Remove-NetRoute -DestinationPrefix "200.200.200.200/32" -Confirm:$false

#

December 17th, 2013 8:59pm

Since I was told that this is how routing works, I tried this out on a Windows XP desktop (Though I was quite confident about it).

I configured a loopback adaptor on Windows XP and assigned IP Address of 10.10.10.10/8 to it (no default gateway). The other Ethernet Interface had a 172.16.x.x series IP Address.

I added a static route "route add 172.16.1.25 10.10.10.10" and then did a "ping -t 172.16.1.25".

The ping just timed out and when I look at the packet capture, it keeps sending ARP request out the loopback adaptor. (Unlike Windows 8.1 where the ARP request is sent out the loopback adaptor 3 times and then the ping command starts using the Ethernet adaptor.)

Brandon, Thanks for your input. However, I noticed that the commands you suggested had the same net effect as "route" command. While the route gets added and shows up in "route print", the system takes the default gateway to reach 172.16.1.25 when ARP times out on the loopback adaptor.

-GW

Free Windows Admin Tool Kit Click here and download it now
January 1st, 2014 6:04am

Did you ever figure out how to stop this behavior?  I am trying to work around the same thing.

Thanks,

Dave

July 9th, 2015 12:14pm

trying to work around the same thing.

In the same area I recently learned about the possibility of having "NoTraffic" for both IPv4 and IPv6 connectivity when I use this PowerShell command:

    Get-NetConnectionProfile

but when I try using the related  Set-NetConnectionProfile  I find that there is no way to change that.  Apparently it is just used as a matching parameter in order to allow changes to just NetworkCategory.

So, perhaps an answer which would help us both would be to:  How do we change the value of  IPv4Connectivity?  Actually another one which would help me is:  How do I stop troubleshooters from changing my preference of  NetworkCategory: Private  to a (troublesome) Public?

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 12:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics