Linux route command
The Linux route command is used to view and manipulate the IP routing table. It allows you to display the current routing table, add new routes, delete existing routes, and make changes to the routing table. The syntax for the route command includes specifying the target network, gateway, netmask, and interface. By using different options, you can customize the behavior of the command. Understanding how to use the route command is essential for network administrators and anyone working with network configurations in a Linux environment.
route Syntax:
Options:
Option | Description |
---|---|
-n | Show numerical addresses |
-v | Verbose output |
-e | Display other/more details |
-A family | Specify the address family |
Parameters:
Parameter | Description |
---|---|
add | Add a new route |
del | Delete a route |
flush | Remove all entries from the routing table |
destination | Network destination for the route |
gateway | Gateway for the route |
route Usage:
Display the routing table
Displays the current routing table on the system.
Add a new route
Adds a new route for the network 192.168.10.0 with the specified netmask and gateway.
Delete a specific route
Deletes the route for the network 10.0.0.0 with the specified netmask.
Set the default gateway
Sets the default gateway to 192.168.1.1 for outgoing traffic.
How do I use route in Linux?
To use the route command in Linux, execute the following command:
How can I display the routing table in Linux?
To display the routing table in Linux, use the following command:
How do I add a static route in Linux?
To add a static route in Linux, use the following command:
How do I delete a specific route in Linux?
To delete a specific route in Linux, use the following command:
How can I change the default gateway in Linux using the route command?
To change the default gateway in Linux using the route command, use the following command:
How do I show kernel routing information in Linux?
To show kernel routing information in Linux, use the following command:
How can I see the IP addresses for local and foreign connections in Linux using the route command?
To see the IP addresses for local and foreign connections in Linux using the route command, use the following command:
Applications of the route command
- Display the routing table:
- Add a new route to the routing table:
- Delete a route from the routing table:
- Change attributes of an existing route:
- Show the IP routing table statistics:
- Flush all routes from the routing table:
- Display the kernel IP routing table with more information:
- Print the route for the target host or network:
- Show the routing cache:
- Display multicast routing information: