In this Oracle Solaris release, the route command is the only way that you can manually configure routes, persistent or otherwise. For details, see the route(8) man page.
When adding routes persistently make sure that the routes do not already exist in the persistent configuration. If these routes already exist in the persistent configuration, the network routing tables could change without actually updating the persistent route. For example, typically in an Oracle Solaris setup, the system's default route is mapped to the system's primary interface. If you subsequently change the system's primary interface to another interface, then the system's default route should also be updated persistently. In this case, delete the current persistent route configuration prior to adding the new route. For more information, see Troubleshooting Issues When Adding a Persistent Route in Troubleshooting Network Administration Issues in Oracle Solaris 11.4.
The following list shows how you use the route command to manage routes:
Use the –p option to add a persistent route:
$ route -p add default ip-address
Use the –name option to add a persistent route by specifying a name rather than destination and gateway:
$ route -p add destination-address gateway-address -name name
Use the route –p show command to display all of the persistent routes:
$ route -p show
To display the currently active routes on a system, use the netstat command as follows:
$ netstat -rn
See the netstat(8) and route(8) man pages.
Before You Begin
Ensure that your role has the appropriate rights profile to perform this procedure. See Using Rights Profiles to Perform Network Configuration.
$ netstat -rn
$ route flush
$ route -p add -net network-address -gateway gateway-address
Creates a static route that persists across system reboots. If you want the route to persist only for the current session, do not use the –p option.
Specifies that the route goes to the network with the address that is specified in network-address.
Indicates that the gateway system for the specified route has the IP address that is specified in gateway-address.
The following example shows how to add a persistent (static) route to a router (Router 2). The static route is needed for the AS's border router, 203.0.113.150. See the illustration used in Example 1, Configuring a System as a Router of this particular setup.
You can view the routing table on Router 2 as follows:
$ netstat -rn Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- --------------- -------- ------ -------- ----------- default 198.51.100.10 UG 1 249 ce0 224.0.0.0 198.51.100.10 U 1 0 ce0 203.0.113.0 203.0.113.20 U 1 78 bge0 127.0.0.1 127.0.0.1 UH 1 57 lo0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If ------------------------ ---------------- ------ ---- ------ ----- ::1 ::1 UH 2 0 lo0
The routing table indicates that there are two routes that Router 2 knows about. The default route uses Router 2's 198.51.100.10 interface as its gateway. The second route, 203.0.113.0, was discovered by the in.routed daemon that is running on Router 2. The gateway for this route is Router 1 and it has the IP address 203.0.113.20.
You can add a second route to network 203.0.113.0, which has its gateway as the border router, as follows:
$ route -p add -net 203.0.113.0/24 -gateway 203.0.113.150 add net 203.0.113.0: gateway 203.0.113.150
The routing table now has a route for the border router, which has the IP address 203.0.113.150.
$ netstat -rn Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- --------------- -------- ------ -------- ----------- default 198.51.100.10 UG 1 249 ce0 224.0.0.0 198.51.100.10 U 1 0 ce0 203.0.113.0 203.0.113.20 U 1 78 bge0 203.0.113.0 203.0.113.150 U 1 375 bge0 127.0.0.1 127.0.0.1 UH 1 57 lo0 Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If ------------------------ ---------------- ------ ---- ------ ----- ::1 ::1 UH 2 0 lo0
When you add a persistent route, you can provide a name for it by using the –name option. You can specify any name other than default, which has a special meaning within the context of routing configuration. See the route(8) man page.
If you use the –name option, then you can refer to the route's name whenever you issue commands related to that route.
You cannot use the –name option to name an existing route or to change the name of a route. Instead, you must first delete the route and then add it again while specifying the –name option.
Before You Begin
Ensure that your role has the appropriate rights profile to perform this procedure. See Using Rights Profiles to Perform Network Configuration.
$ route -p add destination-address gateway-address -name name
$ route get -name route-name
You can also display information about the route as follows:
$ route -p show
The following example shows how to add a persistent route, route1, by specifying a name.
$ route -p add 9.9.9.9 3.3.3.9 -name route1 persistent: route add 9.9.9.9 3.3.3.9 -name route1
$ route get -name route1 route to : 9.9.9.9 name : route1 destination : 9.9.9.9 mask : 255.255.255.25 gateway : 3.3.3.9 interface : net0 flags : <UP,GATEWAY,HOST,DONE,STATIC> recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu expire 0 0 0 0 0 0 1500 0Example 4 Changing Information for a Persistent Route by Specifying the Route's Name
The following example shows how to modify information for a persistent route by specifying its name. In this example, the gateway information is changed. Note that the persistent route must be added by specifying the –name option initially.
$ route -p show persistent: route add 9.9.9.9 3.3.3.9 -name route1 $ route change -name route1 9.9.8.8 change host -name route1 9.9.9.9: gateway 9.9.8.8Example 5 Deleting a Persistent Route by Specifying the Route's Name
The following example shows how to delete a persistent route by specifying its name. Note that the persistent route must be added by specifying the –name option initially.
$ route -p delete -name route1 delete host -name route1 9.9.9.9: gateway 3.3.3.9: not in table delete persistent host -name route1 9.9.9.9: gateway 3.3.3.9
If you do not specify the –p option with the –name option, the route is removed from the routing tables only, as shown in the following example:
$ route delete -name route1 delete host -name route1 9.9.9.9: gateway 3.3.3.9