The old command to set the default route is route. If no options are used, it will display a list of all routes that are currently defined on this host. When using the route command without options, it will always try to resolve the name for a given IP address, which takes some time. If you don’t want any name resolution to be performed, use the option -n, which makes the command a lot faster. The equivalent command with ip is as follows:
$ ip r
where r stands for route.
By default route command is not available in CentOS/RHEL 8 minimal installation and other Linux distributions. route command is available by installing package net-tools. ip route show command can be used instead of route command to check listening ports and services on CentOS/RHEL 8 minimal installation.
This post describes How to resolve “-bash: route: command not found” on CentOS/RHEL 8.
The error below shows that the route command is not installed on the system.
# route -n -bash: route: command not found #
Step 1. Package Installation: Run the following command to install net-tools package:
# dnf install net-tools CentOS-8 – AppStream ……………………. Installed: net-tools-2.0-0.51.20160912git.el8.x86_64 Complete! #
Step 2. Verification: Verify the installation: Run the following commands to verify the installation:
# which netstat /usr/sbin/route #
To display the routing table, use the below command:
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.43.1 0.0.0.0 UG 100 0 0 eth0 0.0.0.0 192.168.43.1 0.0.0.0 UG 101 0 0 eth1 192.168.43.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 192.168.43.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1 #
Final Thoughts
As mentioned in the previous section, the ip utility is a replacement for several utilities including ifconfig and ‘route’, it is included in the iproute2 package. Routes can be seen by running ip route or ip r for short. There are additional route commands for adding or deleting such as ip route del unreachable 10.1.0.0/24, where “unreachable” is the route name and “10.1.0.0/24” is the route.