route Command


Manually manipulates the routing tables.


route -f ] [  -n ] [  -q ] [ -C  ] [ -v Command Family ] [ [  -net -host Destination [ -prefixlen  n] [ -netmask Address ] ] Gateway ] [  Arguments ] [- i] [-@ WparName]


The route command allows you to make manual entries into the network routing tables. The route command distinguishes between routes to hosts and routes to networks by interpreting the network address of the Destination variable, which can be specified either by symbolic name or numeric address. The route command resolves all symbolic names into addresses, using either the /etc/hosts file or the network name server.

Routes to a particular host are distinguished from those to a network by interpreting the Internet address associated with the destination. The optional phs -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, it is presumed to be a route to a host.

For example, 128.32 is interpreted as -host; 128.32.130 is interpreted as -host; -net 128.32 is interpreted as; and -net 128.32.130 is interpreted as

If the route is by way of an interface rather than through a gateway, the -interface argument should be specified. The specified gateway is the address of the host on the common network, indicating the interface to be used for transmission.

The -netmask argument must be followed by an address parameter (to be interpreted as a network mask). One can override the implicit network mask generated in the -inet case by making sure this option follows the Destination parameter.

All symbolic names specified for a destination or gateway are looked up first as a host name, using the gethostbyname subroutine. If this fails, the getnetbyname subroutine is then used to interpret the name as a network name.

Note: Route uses a routing socket and the new message types RTM_ADD, RTM_DELETE, and RTM_CHANGE. As such, only the root user may modify the routing tables.

If the flush or -f command is specified, route will "flush," or clear, the routing tables of all gateway entries. One can choose to flush only those routes whose destinations are of a given address family, by specifying an optional ph describing which address family.

The netstat -r command displays the current routing information contained in the routing tables.

Note: You must use the same set of commands (route, smitty, ifconfig and chdev commands) for creating or deleting the routing table. If you create the routing table by using the smitty or chdev command, and delete it by using the route command, the route entry is not deleted from Object Data Manager (ODM), and if the system gets restarted, the routing table gets builds from ODM, due to which you can see the same route entry again.


Item Description
-f Purges all entries in the routing table that are not associated with network interfaces.
-i Enables workload-partition-specific routing for the workload partition (WPAR). By default, outgoing network traffic from a WPAR is routed as if it were being sent from the global environment:
  • Traffic between addresses that are hosted on the same global system is sent through the loopback interface.
  • Routing table entries that are configured in the global system, including the default route, are used to transmit workload partition traffic.
If you enable WPAR-specific routing by specifying the -i flag, the WPAR creates and uses its own routing table for the outgoing traffic. Routing entries are created automatically for each of the network addresses of the WPAR to accommodate broadcast, loopback, and subnet routes.
-n Displays host and network names numerically, rather than symbolically, when reporting results of a flush or of any action in verbose mode.
-q Specifies quiet mode and suppresses all output.
-C Specifies preference for ioctl calls over routing messages for adding and removing routes.
-v Specifies verbose mode and prints additional details.
-net Indicates that the Destination parameter should be interpreted as a network.
-netmask Specifies the network mask to the destination address. Make sure this option follows the Destination parameter.
-host Indicates that the Destination parameter should be interpreted as a host.
-prefixlen n Specifies the length of a destination prefix (the number of bits in the netmask).
-@WparName Displays the network statistics that are associated with the WPAR that is, (@WparName flag). If the @WparName flag is not specified, the network statistics for all the WPARs are displayed.

The route default is a host (a single computer on the network). When neither the -net parameter nor the -host parameter is specified, but the network portion of the address is specified, the route is assumed to be to a network. The host portion of the address is 0 (zero).


Item Description
Arguments Specifies one or more of the following arguments. Where n is specified as a variable to an argument, the value of the n variable is a positive integer.
Enables Active Dead Gateway Detection on the route.
Clones a new route.
Extracts the length of TSEL, which is used for the generation of cloned routes.
Manipulates interface routing entries.
-rtt n
Specifies round-trip time.
-rttvar n
Specifies round-trip time variance.
-sendpipe n
Specifies send-window size.
-recvpipe n
Specifies receive-window size.
-allowgroup gid
Specifies a group ID that is allowed to use the route. The group ID will be added to a list of allowed groups or deleted from a list of denied groups.
-denygroup gid
Specifies a group ID that is not allowed to use the route. The group ID will be added to a list of denied groups or deleted from a list of allowed groups.
Stops searching if a routing table lookup matches the route, but it is not allowed to use the route due to group routing restrictions.
-mtu n
Specifies maximum transmission unit for this route. Will override interface mtu for TCP applications as long as it does not exceed maximum mtu for the interface. This flag has no affect on mtu for applications using UDP.
-hopcount n
Specifies maximum number of gateways in the route.
-policy n
Specifies the policy to be used for Multipath Routing. n is number between 1 and 5 where these numbers mean the following:
  1. Weighted Round-Robin
  2. Random
  3. Weighted Random
  4. Lowest Utilization
  5. Hash-based
If the policy is not explicitly set and multipath routing is used, then the global no command option called mpr_policy determines the policy that will be used. The default policy is Weighted Round Robin which behaves just like Round-Robin when the weights are all 1. Although the Default policy is Weighted Round-Robin, when the policy is not set, then the network option mpr_policy takes precedence. On the other hand, if the policy is explicitly set to WRR then this setting overrides the mpr_policy setting. For more information about these policies, see the no command.
-weight n
Specifies the weight of the route that will be used for the Weighted policies with the Multipath Routing feature.
-expire n
Specifies expiration metrics used by routing protocol
-ssthresh n
Specifies outbound gateway buffer limit.
Specifies a meta-modifier that can individually lock a metric modifier. The -lock meta-modifier must precede each modifier to be locked.
Specifies a meta-modifier that can lock all subsequent metrics.
-if ifname
Specifies the interface (en0, tr0 ...) to associate with this route so that packets will be sent using this interface when this route is chosen.
Emits a message on use (for external lookup).
Specifies that the destination is directly reachable.
Specifies the manually added route.
Specifies the pretend route that is added by the kernel or daemon.
Emits an ICMP unreachable when matched.
Silently discards packets during updates.
Sets protocol specific routing flag number 1.
Sets protocol specific routing flag number 2.
Command Specifies one of six possibilities:
Adds a route.
flush or -f
Removes all routes.
Deletes a specific route.
Changes aspects of a route (such as its gateway).
Reports any changes to the routing information base, routing lockup misses, or suspected network partitionings.
Lookup and display the route for a destination.
Set the policy and weight attributes of a route.
Family Specifies the address family. The -inet address family is the default. The -inet6 family specifies that all subsequent addresses are in the inet6 family.
Destination Identifies the host or network to which you are directing the route. The Destination parameter can be specified either by symbolic name or numeric address.
Gateway Identifies the gateway to which packets are addressed. The Gateway parameter can be specified either by symbolic name or numeric address.


Attention RBAC users and Trusted AIX® users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.


  1. To establish a route so that a computer on one network can send a message to a computer on a different network, type:
    route add
    The address is that of the receiving computer (the Destination parameter). The address is that of the routing computer (the Gateway parameter).
  2. To establish a route so you can send a message to any user on a specific network, type:
    route add -net
    The address is that of the receiving network (the Destination parameter). The address is that of the routing network (the Gateway parameter).
  3. To establish a default gateway, type:
    route add 0
    The value 0 or the default ph for the Destination parameter means that any packets sent to destinations not previously defined and not on a directly connected network go through the default gateway. The address is that of the gateway chosen to be the default.
  4. To clear the host gateway table, type:
    route -f
  5. To add a route specifying weight and policy information, type:
    route add -weight 5 -policy 4
  6. To set the weight and policy attributes of a preexisting route, type:
    route set -weight 3 -policy