The route command is used to show/manipulate the IP routing table. The simplest command with ‘route’ is to run it without any options or arguments which will return the IP routing table. The equivalent command with ip is as follows:
$ ip r
where r stands for route.
The route command was deprecated in CentOS 7 minimal installation and most of the Linux distributions. The ip command can be used instead of route command. The following steps describes installation of route command on CentOS/RHEL 7.
# route -n -bash: route: command not found #
Step 1. Route command binary installation: Run the following command to install route command:
# yum install net-tools Loaded plugins: fastestmirror ..... Installed: net-tools.x86_64 0:2.0-0.24.20131004git.el7 Complete! #
Step 2. Verify the installation: Run the following commands to verify the installation:
# which route /usr/sbin/route #
Display the routing table using 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 ens33 192.168.43.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33 #
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.