What is the difference between `/sbin/ip route` and `/sbin/route`?
Solution 1
route
is the old traditional tool and available on numerous Unix systems. ip
belongs to the iproute2 suite which is a Linux only tool and uses the Netlink API, which is a socket like interface for accessing kernel information about interfaces, address assignments and routes. It replaces most of the functionality of ifconfig
, route
, netstat
and a few others.
I assume you're on Linux, then you should use ip
since route
and ifconfig
are deprecated, although still widely used.
Further reading:
- ifconfig vs iproute2
- iproute2: Life after ifconfig
- Deprecated Linux networking commands and their replacements
Solution 2
Different commands, different syntax.
route
stems from very very long ago and still exists mostly because it has always existed and some stuff still expects it to be there.
ip
belongs to the iproute2
package and can do everything route
and ifconfig
can and much, much, MUCH more.
Full documentation on the ip
command can be found here among other places.
TL;DR: Always use ip
.
Brandon Condrey
Consider opposing apartheid in Palestine and signing onto the BDS Movement; #1 User for DBA.SE 2017. Available for contracting: 281.901.0011 PostgreSQL & PostGIS / MySQL / SQL Server JavaScript, Typescript, Rx.js, Node.js, Angular Also: C / Perl / Python / Rust / x86 Assembly
Updated on September 18, 2022Comments
-
Brandon Condrey over 1 year
Linux comes with two utilities
/sbin/route
/sbin/ip route
What is the difference between the two and what is the rule of thumb to use when you decide which one of the two you should use? I know they're both documented in two separate locations,
man 8 route
man 8 ip-route
-
Jpark822 almost 11 years+1 for mentioning it is Linux only. On a site named Unix & Linux that is worth mentioning.
-
Alicia almost 11 yearsI always wondered why stick only to the non-portable Linux utilities, specially when they require you to be much more verbose. I find more comfortable to write
ifconfig eth0 up 192.168.0.1/24
thanip link set dev eth0 up && ip addr change dev eth0 192.168.0.1/24
. -
Marco almost 11 years@ntrrgc You can shorten this to
ip l s eth0 up && ip a c dev eth0 192.168.0.1/24
. Furthermore the/24
syntax is not implemented in allifconfig
versions, on some systems you have to writenetmask 255.255.255.0
which makes it rather verbose. But I agreeifconfig
is often shorter.