![Forrest logo](/images/logo.png)
route:tldr:1bf49
This command is used to add a static route to the IP routing table on a Unix-like system. Let's break it down:
-
sudo
: This command is used to execute the following command as the superuser or root user. It is necessary because modifying the IP routing table typically requires administrative privileges. -
route
: This is the command to manage the IP routing table. It allows you to view, manipulate, and add IP routes. -
add
: This option is used to instruct theroute
command to add a new route to the routing table. -
-net ${ip_address}
: This part specifies the network destination address for the route.${ip_address}
should be replaced with the actual IP address of the network you want to add the route for. For example,-net 192.168.1.0
indicates the destination network is 192.168.1.0. -
netmask ${netmask_address}
: Here,${netmask_address}
should be replaced with the netmask for the destination network. The netmask is used to determine the network and host portions of an IP address. For example,netmask 255.255.255.0
indicates a netmask of 255.255.255.0 (or /24 in CIDR notation). -
gw ${gw_address}
: This specifies the gateway address or the next hop for the route.${gw_address}
should be replaced with the actual IP address of the gateway or next hop. The gateway is the device responsible for forwarding packets to other networks. For example,gw 192.168.1.1
indicates that the IP address 192.168.1.1 is the gateway.
By running this command with appropriate values for ${ip_address}
, ${netmask_address}
, and ${gw_address}
, you can add a static route to the IP routing table, allowing your system to forward packets destined for the specified network via the specified gateway.