I have a virtual machine running Windows Server 2019, which is a terminal server with many network interfaces. It is actually a trunk, which is being configured for many vlan interfaces, leading to this many interfaces - but this shouldn't matter to my question. Now, coming to the strange part:
PS C:\Users\XXXX> netstat -n | findstr "192.168.4.80:445"
TCP 10.0.200.90:49531 192.168.4.80:445 ESTABLISHED
TCP 10.0.200.90:49532 192.168.4.80:445 ESTABLISHED
TCP 10.0.200.90:49533 192.168.4.80:445 ESTABLISHED
TCP 10.0.200.90:49534 192.168.4.80:445 ESTABLISHED
TCP 192.168.4.90:49528 192.168.4.80:445 ESTABLISHED
TCP 192.168.4.90:49529 192.168.4.80:445 ESTABLISHED
TCP 192.168.4.90:49530 192.168.4.80:445 ESTABLISHED
TCP 192.168.4.90:55959 192.168.4.80:445 ESTABLISHED
Both interfaces in question here are configured with a /24
netmask - and the 10.0.200.90/24
interface holds the default gateway. The routing table is quite large, as there are many interfaces, but there is no conflicting route for the 192.168.4.0/24 subnet. Here are the relevant parts of it:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.0.200.250 10.0.200.90 271
10.0.200.0 255.255.255.0 On-link 10.0.200.90 271
10.0.200.90 255.255.255.255 On-link 10.0.200.90 271
10.0.200.255 255.255.255.255 On-link 10.0.200.90 271
192.168.4.0 255.255.255.0 On-link 192.168.4.90 271
192.168.4.90 255.255.255.255 On-link 192.168.4.90 271
192.168.4.255 255.255.255.255 On-link 192.168.4.90 271
===========================================================================
How is it possible that some connections are being sent via the default gateway, and some connections take the proper interface route? I noticed this on the firewall (the default gateway), inside the packet filter logging, so this is not just a display issue, some packets really are being sent over the default gateway - And I checked via the resource monitor, the connections belong to PID 4 (System), which is most likely the mapped network drives.
For all what I know about routing, the metric is only taken into account if there are two routes with the same subnet - in such a case, the route with the lower metric would win. But the default gateway route should never win over a interface route, no matter what metric is configured - correct?
My first thought was that this must be a bug inside windows - maybe a race condition between the process bringing the interface up and the process mapping the network drive. But this is pure speculation, I was hoping someone could enlighten me with a deeper insight...