2
I have Windows Server 2012R2 with VPN Server (RRAS)
When some user connected I want setup routing to his network.
Everything work fine when I use route add, but when I use New-NetRoute routing don't works as needed.
For example (networks 192.168.110.0/24 and 192.168.111.0/24. both accessible via connection when I use route add command)
PS C:\tools> Get-NetRoute
ifIndex DestinationPrefix NextHop RouteMetric PolicyStore
------- ----------------- ------- ----------- -----------
22 192.168.111.0/24 192.168.99.199 1 ActiveStore
22 192.168.110.0/24 192.168.99.199 1 ActiveStore
Routing to network 192.168.110.0/24 was added with command
route add 192.168.110.0/24 192.168.99.199
Routing to network 192.168.111.0/24 was added with command
New-NetRoute -DestinationPrefix 192.168.111.0/24 -NextHop 192.168.99.199 -PolicyStore ActiveStore -RouteMetric 1 -InterfaceIndex 22
When I trying to ping host on network I receive next output:
PS C:\tools> ping 192.168.110.1 -n 1
Pinging 192.168.110.1 with 32 bytes of data:
Reply from 192.168.110.1: bytes=32 time=61ms TTL=63
Ping statistics for 192.168.110.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 61ms, Maximum = 61ms, Average = 61ms
PS C:\tools> ping 192.168.111.1 -n 1
Pinging 192.168.111.1 with 32 bytes of data:
General failure.
Ping statistics for 192.168.111.1:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
So when I use route add I have no problems and everything works as needed, but when I use New-NetRoute I have problems with General failure error.
route add
adds the route to IP stack routing table.New-NetRoute
(it seems) adds the route to RRAS table. Check does the route added viaNew-NetRoute
is visible incmd - route print
output... – Akina – 2018-09-06T06:43:41.373@Akina: Hmm, so how do you add live IP routes via PowerShell cmdlets? – user1686 – 2018-09-06T07:04:54.713
I have detected those "difference" (routes addition via
route add
and via MMC-RRAS) when Windows Server 2000 was the most recent OS. From that time I do not use routing table edition other thanroute.exe
- I like when I can predict the result. – Akina – 2018-09-06T07:23:08.683@Akina output of route print same for both routes and route added via New-NetRoute is visible with route print. – igor.kuzuro – 2018-09-06T21:14:03.630
@grawity I also saw this problem a couple of years ago... but now time to play with this problem again. Concerning how to add live IP routes via PowerShell cmdlets... just use call to route.exe... I do it this way. – igor.kuzuro – 2018-09-06T21:20:36.160