Updated: April 19, 2023

Manually manipulate the routing tables


route [-dfnqSstv] command { [[modifiers] args] }

Runs on:

QNX Neutrino


Debug only (exits before actually changing the routing).
Remove all routes (as per flush). If used in conjunction with the add, change, delete, or get commands, route removes the routes before performing the command.
Don't print host and network names symbolically when reporting actions. (The process of translating between symbolic names and numerical equivalents can be quite time consuming, and may require correct operation of the network; thus it may be expedient to forgo this, especially when attempting to repair networking operations.)
Be quiet: suppress all output.
Put a space between flags when they're displayed.
Short output (reduces the output by skipping some printf() calls).
Open /dev/null instead of the PF_ROUTE socket.
Be verbose: print additional details.
command [[modifiers] args]
Valid commands are: add, change, delete, flush, and show. See the “Description” section for the syntax and description of each command.


You use the route utility to manually manipulate the network routing tables. Because the routing tables are usually taken care of by the routed daemon, you rarely need to use this utility.

You can have multiple routes to the same destination:

command options

The route utility accepts the following commands:

[-n] add [-net|-host] destination gateway
Add a route.
[-n] change [-net|-host] destination gateway
Change aspects of a route (such as its gateway).
[-n] delete [-net|-host] destination gateway
Delete a specific route.
[-n] flush [family]
(INET and INET6 only) Flush the routing tables of all gateway entries. If you want to delete only routes having destinations with addresses in a specified family, specify -inet or -inet6 as the family variable.
[-n] get [-net|-host] destination gateway
Look up and display the route for a destination.
[-n] monitor
Report changes to the routing information on a continuing basis.
[-n] show
Display route table (similar to netstat -r).
The destination host or network.
The next-hop gateway that packets should be addressed to.
Note: If the keyword, default, or the network address,, is specified, then all packets sent to a remote network that's not defined in the routing tables, are sent to the specified gateway.

If you have an Internet Service Provider (ISP), packets sent to hosts on the Internet are sent to a gateway provided by the ISP. See the defaultroute option in pppd.

Routes to a particular host are distinguished from those to a network by interpreting the Internet address associated with destination. Specifying the optional modifiers -net and -host force the destination to be interpreted as a network or a host, respectively.

If the destination has a “local address part” of INADDR_ANY, or if the destination is the symbolic name of a network, then the route is assumed to be to a network; otherwise, the route is assumed to be to a host. For example:

This destination: Is interpreted as:
128.32 -host
128.32.130 -host
-net 128.32
-net 128.32.130

If the route is via an interface rather than via a gateway, you should specify the -interface modifier; the gateway given is the address of this host on the common network, indicating the interface to be used for transmission.

Here are other optional modifiers:

-linkindex index:type
Manually create a loopback entry on a loopback interface. The loopback entry will have the same internal gateway format as the loopback entry automatically generated by io-pkt when ifconfig sets an IPv6 address on an interface. This modifier takes two arguments: index and type, where index is the index of the interface, and type is the media type of the interface.
-netmask address (IPv4)
Specify an additional address parameter that's interpreted as a network mask. You can use this like an OSI ESIS redirect with the netmask option, or to manually add subnet routes with netmasks different from that of the implied network interface (as would otherwise be communicated using the OSPF or ISIS routing protocols). After -netmask, enter the address parameter you want interpreted as the network mask.
You can override the implicit network mask generated in the INET case by placing this option after the destination parameter.
-prefixlen address (IPv6)
The -prefixlen works the same as -netmask, but for IPv6.
-ifp interface name
When there are multiple route entries which share same destination and gateway address, the interface becomes a differentiator. The -ifp modifier passes an interface name with delete and get commands. So for duplicated route entries, the delete and get command can precisely select one based on the interface name option.

Routes have associated flags which influence operation of the protocols when sending to destinations matched by the routes. These flags may be set (or sometimes cleared) by indicating the following corresponding modifiers:

RTF_CLONING — generates a new route on use
RTF_XRESOLVE — emit mesg on use (for external lookup)
~RTF_GATEWAY — destination is directly reachable
RTF_STATIC — manually added route
~RTF_STATIC — pretend route added by kernel or daemon
RTF_REJECT — emit an ICMP unreachable when matched
RTF_BLACKHOLE — silently discard pkts (during updates)
RTF_PROTO1 — set protocol specific routing flag #1
RTF_PROTO2 — set protocol specific routing flag #2
RTF_LLINFO — validly translates proto addr to link addr

The optional modifiers:

provide initial values to metrics maintained in the routing entry. To lock any of these modifiers, precede the modifier with the -lock meta-modifier; you can also specify the -lockrest meta-modifier to lock all ensuing metrics.

All symbolic names specified for a destination or gateway are looked up first as a hostname using gethostname(). If this lookup fails, getnetbyname() is then used to interpret the name as that of a network.

The route utility uses a routing socket and the new message types RTM_ADD, RTM_DELETE, and RTM_CHANGE. As such, only the superuser may modify the routing tables.


add [host | network ] %s: gateway %s flags %x
The specified route is being added to the tables. The values printed are from the routing table entry supplied in the ioctl() call. If the gateway address used isn't the primary address of the gateway—the first one returned by gethostname() —the gateway address is printed numerically as well as symbolically.
delete [ host &| network ] %s: gateway %s flags %x
As above, but when deleting an entry.
%s %s done
A routing table entry is being deleted by the flush command.
Network is unreachable
An attempt to add a route failed because the gateway listed wasn't on a directly connected network. The next-hop gateway must be given.
not in table
A delete operation was attempted for an entry not present in the tables.
routing table overflow
An add operation was attempted, but the system was low on resources and couldn't allocate memory to create the new entry.
Permission denied
The attempted operation is privileged. Only root may modify the routing tables. These privileges are enforced by the kernel.


This utility is based on copyright software of the Regents of the University of California and of Christos Zoulas; for licensing information, see Licensing information in Typographical Conventions, Support, and Licensing.