How to install route command on CentOS / RHEL 7

I am trying to use route command command on a CentOS Enterprise Linux/Red Hat Enterprise Linux version 7 (RHEL 7). But, I am getting the following error:
    bash: route: command not found
How do I install router command on CentOS/RHEL 7 and use it?

The route command deprecated in CentOS/RHEL 7/Fedora and many other Linux distributions. You need to use the ip command instead of route command. However, it is possible to install router and other deprecated command for compatibility reasons. This page shows how to install route command on CentOS/RHEL 7 server.

How to find out what package provides route command

Type the following yum command:
# yum whatprovides route
The output indicate that I need to install net-tools package. To get more info on the net-tools, run:
# yum info net-tools
yum whatprovides route command on CentOS RHEL Fedora server

How to install route command using yum

Simply type the following yum command:
# yum install net-tools
Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * remi-safe:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package               Arch               Version                               Repository        Size
 net-tools             x86_64             2.0-0.22.20131004git.el7              base             305 k
Transaction Summary
Install  1 Package
Total download size: 305 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.22.20131004git.el7.x86_64.rpm                                   | 305 kB  00:00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.22.20131004git.el7.x86_64                                           1/1 
  Verifying  : net-tools-2.0-0.22.20131004git.el7.x86_64                                           1/1 
  net-tools.x86_64 0:2.0-0.22.20131004git.el7                                                          

How to use route command

To see current route type:
# route -n
Sample outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0   U     0      0        0 eth0     U     1013   0        0 eth0

You can use ip command for same purpose:
# ip r
Sample outputs:

default via dev eth0 dev eth0 proto kernel scope link src dev eth0 scope link metric 1013

How to add default gateway/router IP

Run command:
route add default gw {IP-ADDRESS} {INTERFACE-NAME}
route add default gw eth0

You can also use ip command as follows to set default routing/gateway on Linux:
# ip route add default via
Verify it:
# route -n
# ip r

How to delete the default route

To deletes the current default route, which is labeled “default” or in the destination field of the current routing table.
# route del default
For more info read the route command man page:
$ man route

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum