How to Add a Static TCP/IP Route to the Windows Routing Table

To add a static TCP/IP route to the Windows routing table, you can follow these steps:

  1. Open a Command Prompt window as an administrator. To do this, right-click on the Start menu button and select “Command Prompt (Admin)” from the menu.
  2. Type the following command and press Enter:
    php
    route -p add <destination_network> mask <subnet_mask> <gateway> metric <metric_value>

    Replace the following variables with the appropriate values for your network:

    • <destination_network>: The IP address or network ID of the destination network.
    • <subnet_mask>: The subnet mask for the destination network.
    • <gateway>: The IP address of the gateway or next hop for the route.
    • <metric_value>: The metric value for the route (a lower value indicates a more preferred route).

    For example, if you want to add a route for the network 192.168.1.0/24 with a gateway of 192.168.0.1 and a metric value of 2, you would type:

    css
    route -p add 192.168.1.0 mask 255.255.255.0 192.168.0.1 metric 2
  3. Press Enter to run the command. You should see a message indicating that the route was added successfully.
  4. To verify that the route was added, you can use the following command:
    arduino
    route print

    This will display the current routing table, including any static routes that you have added.

Note: The -p option in the route command makes the route persistent, which means it will be saved and restored when you restart your computer. If you don’t use the -p option, the route will only be active until you restart your computer.