Forrest logo
back to the route tool

route:tldr:25d82

route: Add a route to a /24 subnet through a gateway.
$ sudo route add "${subnet_ip_address}/24" "${gateway_address}"
try on your machine

This command is used to add a new entry to the routing table on a Unix-like operating system using the "route" command. Here's what each part of the command means:

  • "sudo": It is a command used to execute the following command with administrative privileges or root access. It requests elevated privileges to add the route.

  • "route": It is a command-line utility used to view and manipulate the IP routing table on a Unix-like system.

  • "add": It is a flag used with the "route" command to specify that a new route should be added.

  • "${subnet_ip_address}/24": This is the subnet IP address followed by "/24". The "${subnet_ip_address}" is a placeholder that represents the actual subnet IP address, and "/24" is a netmask that tells the system that the IP addresses within this subnet belong to the same network. For example, if the "${subnet_ip_address}" is 192.168.1.0, then the subnet IP address becomes 192.168.1.0/24.

  • "${gateway_address}": This is another placeholder that represents the actual gateway address. The "${gateway_address}" specifies the IP address of the default gateway, which is used to forward network traffic to destinations that are not directly connected to the local network.

So, to summarize, the "sudo route add" command is used to add a new entry to the routing table. The "${subnet_ip_address}/24" specifies the subnet for which the route should be added, and "${gateway_address}" specifies the IP address of the default gateway for that subnet.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the route tool