VPN with Static Route



加 route 用 IF 的好處



Client    -->    vpn.datahunter.org -->


route -p add a.b.c.d/<CIDR> IF <interface number>

IF support interface is up / down => add / remove route


# "20" 是 VPN NIC 的 ID, 在 VPN up 時可以用 route print 查看

route print

Interface List
 19...xx xx xx xx xx xx ......Realtek PCIe GbE Family Controller #3


  • xx 係佢的 MAC
  • NIC Num 與 VPN 連接的順序有關, 它們的 ID 係順序的, 所以不是固定

# VPN 後, 在 NIC 52 存在時

route add mask IF 52 -p

route print         # win10

IPv4 Route Table
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
    ...     26
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
    ...       1


route add mask IF 27

route print | findstr 192.168.130     26

route add mask IF 27

route print | findstr 192.168.130         On-link     26         On-link    281


It means that the destination network is directly attached to the interface

meaning traffic that matches this route entry will trigger an ARP request

that should be sent from this link to resolve the destination IP directly