Forrest logo
back to the ip tool

ip-route:tldr:ea0d7

ip-route: Add a default route using gateway forwarding.
$ sudo ip route add default via ${gateway_ip}
try on your machine

This command adds a default route to the system's IP routing table using the ip route add command. It allows the system to send all traffic that doesn't have a specific route defined to a default gateway.

Here's an explanation of each component of the command:

  • sudo: The sudo command is used to run the following command as a superuser or administrator. It prompts the user for their password before executing the command.
  • ip: This is the command to manage various aspects of IP networking in Linux.
  • route: This is a subcommand of the ip command for manipulating the IP routing table.
  • add: This is an option for the route subcommand that specifies that a new route should be added to the routing table.
  • default: This specifies the destination of the new route, which is the default route.
  • via: This keyword is followed by the next hop IP address or gateway IP address through which the traffic should be sent.
  • ${gateway_ip}: This is a placeholder for the actual IP address of the gateway. In practice, you would replace ${gateway_ip} with the actual IP address of the gateway you want to use as the default route.

By running this command with the appropriate gateway IP address, you can configure the system to send all traffic to that gateway if no specific route is defined for the destination.

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 ip tool