The `route add` command in CMD is used to manually add a route to the local routing table, allowing you to specify the destination network, subnet mask, and gateway for packet routing.
route add <destination> MASK <subnet_mask> <gateway> [metric <metric>] [IF <interface_index>]
Replace `<destination>`, `<subnet_mask>`, `<gateway>`, `<metric>`, and `<interface_index>` with the specific values for your network configuration.
Understanding Networking Basics
What is Networking?
Networking refers to the practice of connecting computers and other devices to share resources and information. At the core of networking are components such as switches, routers, and protocols that work together to facilitate communication. Understanding basic networking concepts is essential as it provides the foundation for effectively managing and troubleshooting network connections.
What are Routes?
A route is a path that network packets follow to reach their destination. Routing enables data to travel across networks, guiding information on the most efficient paths. Configuring routes correctly is crucial for maintaining optimal network performance, minimizing latency, and ensuring reliable connectivity.

What is the `route` Command?
Introduction to the `route` Command
The `route` command is a tool available in Command Prompt (cmd) used to view and modify the IP routing table on a Windows operating system. The routing table holds essential information about how data packets should be directed through the network. Common use cases for the `route` command include adding, deleting, and modifying routing entries.
Syntax of the `route add` Command
The syntax for the `route add` command is as follows:
route ADD destination MASK subnet_mask gateway metric
This structure allows users to specify various parameters to define how the command should execute, detailing where the route leads and which gateway to utilize.

How to Use the `route add` Command
Basic Command Structure
To effectively use the `route add` command, it’s vital to understand the role of each parameter:
- destination: This is the IP address or hostname of the target route. It represents where the data is intended to go.
- subnet_mask: This defines the range of addresses contained in the destination network. A mask of `255.255.255.0` often indicates a class C subnet, usable for smaller networks.
- gateway: This specifies the next-hop IP address through which packets will travel en route to the destination. It’s crucial that this address be reachable on the local network.
- metric: An optional parameter that specifies the cost of using the route, allowing for priority between multiple routes.
Example of Basic Usage
Here’s an example of adding a basic route using the `route add` command:
route ADD 192.168.1.0 MASK 255.255.255.0 192.168.1.1
Explanation: The command above creates a route for the IP range `192.168.1.0` with a subnet mask of `255.255.255.0`, routing traffic through the gateway `192.168.1.1`. This command is particularly useful for directing packets within a local area network (LAN).

Advanced Routing Scenarios
Using Metrics
Importance of Metrics
Metrics play a vital role in route selection by indicating the “cost” associated with using a particular route. Lower metrics are preferred over higher ones. For instance, if you have two routes to the same destination, the system will choose the one with the lower metric.
Example Usage of Metrics
route ADD 10.0.0.0 MASK 255.255.255.0 10.0.0.1 METRIC 5
In this example, the command adds a route to the IP range `10.0.0.0` using `10.0.0.1` as the gateway, with a metric of `5`.
Adding Persistent Routes
What are Persistent Routes?
Persistent routes are routes that remain in the routing table even after a reboot. Having persistent routes can be beneficial for ensuring consistent and reliable routing configurations.
Command to Add a Persistent Route
To add a route that persists across reboots, use the `-p` switch:
route -p ADD 192.168.2.0 MASK 255.255.255.0 192.168.2.1
This command ensures that the route to `192.168.2.0` is maintained in the routing table after a system restart.

Viewing and Modifying Routes
Viewing the Current Routing Table
To view the routing table entries that are currently configured, the following command can be used:
route PRINT
This command provides a detailed list of all routes, including the destination, mask, gateway, and metric, allowing users to verify current configurations.
Modifying Existing Routes
If you need to change an existing route, use the `route CHANGE` command:
route CHANGE 192.168.1.0 MASK 255.255.255.0 192.168.1.254
This example modifies the route for `192.168.1.0`, directing traffic to a new gateway, `192.168.1.254`.
Deleting a Route
To delete a route from the routing table, you can use the `route DELETE` command:
route DELETE 192.168.1.0
This command effectively removes any route entries associated with `192.168.1.0`, ensuring that data packets will no longer be directed through that path.

Common Errors and Troubleshooting
Common Errors with `route add`
Users may encounter common errors when using the `route add` command, such as:
- Mismatched subnet masks: Ensure that the subnet mask accurately represents the route being added.
- Incorrect gateway address: Verify that the specified gateway is reachable; otherwise, packets will be dropped.
How to Troubleshoot with CMD
To troubleshoot routing issues, utilize cmd tools like `ping` and `tracert`. The `ping` command tests connectivity to a specific IP address, while the `tracert` command displays the route packets take to reach a destination, pinpointing any potential bottlenecks or failures.

Conclusion
The `add route cmd` command is an invaluable tool for effectively managing network configurations. By mastering how to add, modify, and delete routes, users can significantly enhance their network efficiency and reliability. Practice using these commands and explore further resources to deepen your understanding of command prompt functionalities related to networking.