Routing table persistent route not working (Windows)

3

0

Hi I configured the following persistent routes on my Windows Server.

route -p ADD 10.32.1.40 MASK 255.255.255.255 172.16.8.254
route -p ADD 10.192.1.40 MASK 255.255.255.255 172.16.8.254

They work fine initially, but when I reboot they do not work anymore and no longer show up as an active route. How could this be?

My route print output looks like this

Tracing route to 10.192.1.40
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  10.129.81.11
  2    <1 ms    <1 ms    <1 ms  10.222.129.5
  3    17 ms     4 ms     4 ms  10.48.1.121
  4     1 ms     1 ms     1 ms  10.222.13.13
  5     4 ms     4 ms     4 ms  10.222.13.14
  6     *        *        *     Request timed out.
  7     *        *        *     Request timed out.
  8     *        *        *     Request timed out.
  9     *        *        *     Request timed out.
 10     *        *        *     Request timed out.
 11  PS C:\Users\Administrator> route print
===========================================================================
Interface List
 12 ...00 50 56 bb 76 d2 ...... Intel(R) PRO/1000 MT Network Connection #2
 11 ...00 50 56 bb 47 c4 ...... Intel(R) PRO/1000 MT Network Connection
  1 ........................... Software Loopback Interface 1
 14 ...00 00 00 00 00 00 00 e0  isatap.{B96D2DBB-444E-4452-ADD3-E20B7A534D11}
 13 ...00 00 00 00 00 00 00 e0  isatap.{7D99C8C8-276A-4232-A137-BA84ACBD738D}
 10 ...02 00 54 55 4e 01 ...... Teredo Tunneling Pseudo-Interface
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0     10.129.81.10    10.129.81.234    266
      10.10.110.0    255.255.255.0     172.16.6.254     172.16.6.234     11
      10.129.81.0    255.255.255.0         On-link     10.129.81.234    266
    10.129.81.234  255.255.255.255         On-link     10.129.81.234    266
    10.129.81.255  255.255.255.255         On-link     10.129.81.234    266
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
       172.16.0.0      255.255.0.0     172.16.6.254     172.16.6.234     11
       172.16.6.0    255.255.255.0         On-link      172.16.6.234    266
     172.16.6.234  255.255.255.255         On-link      172.16.6.234    266
     172.16.6.255  255.255.255.255         On-link      172.16.6.234    266
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0         On-link      172.16.6.234    266
        224.0.0.0        240.0.0.0         On-link     10.129.81.234    266
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255         On-link      172.16.6.234    266
  255.255.255.255  255.255.255.255         On-link     10.129.81.234    266
===========================================================================
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
      10.10.110.0    255.255.255.0     172.16.6.254       1
       172.16.0.0      255.255.0.0     172.16.6.254       1
       10.32.1.40  255.255.255.255     172.16.8.254       1
      10.192.1.40  255.255.255.255     172.16.8.254       1
          0.0.0.0          0.0.0.0     10.129.81.10  Default
===========================================================================

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    306 ::1/128                  On-link
  1    306 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

According to this post the most specific subnet mask should get priority. Pretty sure I can't get more specific than 255.255.255.255

More information: I can ping the gateway I'm trying to rig

PS C:\Users\Administrator> ping 172.16.8.254

Pinging 172.16.8.254 with 32 bytes of data:
Reply from 172.16.8.254: bytes=32 time=3ms TTL=255
Reply from 172.16.8.254: bytes=32 time=1ms TTL=255
Reply from 172.16.8.254: bytes=32 time=4ms TTL=255
Reply from 172.16.8.254: bytes=32 time=2ms TTL=255

Result of a tracert:

PS C:\Users\Administrator> tracert 10.32.1.40

Tracing route to pen-srv1 [10.32.1.40]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  10.129.81.11
  2    <1 ms    <1 ms    <1 ms  10.222.129.5
  3     1 ms     1 ms     1 ms  172.29.150.10
  4     2 ms     1 ms     1 ms  172.29.150.9
  5     *        *        *     Request timed out.

It keeps jumping to the wrong network.

Gilles Lesire

Posted 2017-09-14T12:33:19.823

Reputation: 111

As you can read at the very end of the Article you posted with your first link "persistent routes". ---- That’s all easy enough, but there is one extra little catch. When you add a static route, by default it only lasts until the next time you start Windows. The reason for this is that many companies use a coordinated list of static routes that gets updated fairly often. Rather than adding and updating all those routes on every machine, they just distribute a batch script file that adds the newest routes during Windows startup. This keeps the routing table relatively uncluttered. – konqui – 2017-09-14T12:44:16.000

I made the route persistent using the "-p" parameter. As you can see it is also showing up in the routing table. It's just not in the active routing table. So somehow it is being overruled by one of the other routes. I just have no clue which one. – Gilles Lesire – 2017-09-14T12:46:28.147

1Persistent routes sometimes don't persist and with no explanation. Try to add the interface parameter to the route command. But if the problem still returns, you might consider adding a boot script that reestablishes these routes. – harrymc – 2017-09-17T18:26:17.450

Hmmm indeed, I just removed the persistent route and readded it, after reboot it just functions as it should. The fact that persistent routes not always persist is quite worrying though. I use it to persist a route to the Active Directory Domain Controller. If that route goes out, no more logging in. :/ – Gilles Lesire – 2017-09-18T07:10:32.357

A boot scrip may be an overkill, but is good assurance. – harrymc – 2017-09-19T10:16:44.670

Yeah that's what I did now. After another reboot the persistent routes were gone again. I was hoping there would have been a cleaner solution. Startupscripts often get overlooked. – Gilles Lesire – 2017-09-19T10:39:13.273

Answers

1

So after trying to play with the subnet masks, interface parameter, change the metrics of the other routes etc, I gave up, removed the persistent routes and wrote a simple batch script wich adds the routes (non persistent) to the routing table on startup of the server.

Sometimes software name is just being software name.

So I created a .bat file with the 2 route ADD commands (without the -p parameter which would make them persistent). Saved that to C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup folder and added the .bat script to the startup scripts.

Contents of the .bat file are simply:

route ADD 10.32.1.40 MASK 255.255.255.255 172.16.8.254
route ADD 10.192.1.40 MASK 255.255.255.255 172.16.8.254

Thanks @harrymc for the suggestions. Bounty awarded!

Gilles Lesire

Posted 2017-09-14T12:33:19.823

Reputation: 111

2Had the same problem for months now. Created a bash script to add the routes but didn't bother to remove the permanent flag in case one day they start working as they should. Windows (correctly) says that the routes already exist when trying to add them, but it still kicks them back into life. – Nick – 2018-09-08T17:08:47.230

1I'm in a same situation but I don't use the script, I just type the route print command and it works. My guess is that there is some mechanism/algorithm that speedups the routing process which may produces a false-positive result (not the best route) – Han – 2020-02-14T03:28:18.727

1

Persistent routes sometimes don't persist and with no explanation.

Try to add the interface parameter to the route command, but if the problem still returns, you might consider adding a boot script that reestablishes these routes.

harrymc

Posted 2017-09-14T12:33:19.823

Reputation: 306 093

Awarded the bounty but I'll leave my answer as the correct one since it contains more information. – Gilles Lesire – 2017-09-19T10:59:11.943