1 System Administration Commands route(1M) 2 3 4 5 NAME 6 route - manually manipulate the routing tables 7 8 SYNOPSIS 9 route [-fnvq] sub-command [ [modifiers] args] 10 11 12 route [-fnvq] [-p [-R root-dir]] add | delete [modifiers] destination gateway 13 [args] 14 15 16 route [-fnvq] change | get [modifiers] destination 17 [gateway [args]] 18 19 20 route [-fn] monitor [modifiers] 21 22 23 route [-fnvq] flush [modifiers] 24 25 26 route -p [-R root-dir] show 27 28 29 DESCRIPTION 30 route manually manipulates the network routing tables. These 31 tables are normally maintained by the system routing daemon, 32 such as in.routed(1M) and in.ripngd(1M). 33 34 35 route supports a limited number of general options, but a 36 rich command language. Users can specify an arbitrary 37 request that can be delivered by means of the programmatic 38 interface discussed in route(7P). 39 40 41 route uses a routing socket and the new message types 42 RTM_ADD, RTM_DELETE, RTM_GET, and RTM_CHANGE. While only 43 superusers can modify routing tables, the RTM_GET operation 44 is allowed for non-privileged users. 45 46 OPTIONS 47 -f Flush the routing tables of all gateway 48 entries. If you use the -f option in conjunc- 49 tion with any of the route sub-commands, 50 route flushes the gateways before performing 51 the sub-command. Specify the table to flush 52 by placing the -inet or -inet6 modifier 53 immediately after the -f option. If unspeci- 54 fied, flushing IPv4 (-inet) routes is the 55 default. 56 57 58 59 60 SunOS 5.11 Last change: 26 Jun 2006 1 61 62 63 64 65 66 67 System Administration Commands route(1M) 68 69 70 71 -n Prevent attempts to print host and network 72 names symbolically when reporting actions. 73 This option is useful when name servers are 74 unavailable. 75 76 77 -p Make changes to the network route tables per- 78 sistent across system restarts. The operation 79 is applied to the network routing tables 80 first and, if successful, is then applied to 81 the list of saved routes used at system 82 startup. In determining whether an operation 83 was successful, a failure to add a route that 84 already exists or to delete a route that is 85 not in the routing table is ignored. Particu- 86 lar care should be taken when using host or 87 network names in persistent routes, as 88 network-based name resolution services are 89 not available at the time routes are added at 90 startup. 91 92 93 -q Suppress all output. 94 95 96 -R root-dir Specify an alternate root directory where 97 route applies changes. This option is ignored 98 unless used in conjunction with the -p 99 option. When -R is specified, route changes 100 are applied only to the list of saved routes 101 to be used at startup, not to the network 102 routing tables. In addition, certain checks, 103 such as the existence of network interfaces 104 used with -ifp, are skipped. This can be use- 105 ful from within JumpStart scripts, where the 106 root directory of the system being modified 107 is in a location other than /. 108 109 110 -v Print additional details in verbose mode. 111 112 113 Subcommands 114 The following subcommands are supported: 115 116 add Add a route. 117 118 119 change Change aspects of a route (such as its gateway). 120 121 122 123 124 125 126 SunOS 5.11 Last change: 26 Jun 2006 2 127 128 129 130 131 132 133 System Administration Commands route(1M) 134 135 136 137 delete Delete a specific route. 138 139 140 flush Remove all gateway entries from the routing 141 table. 142 143 144 get Look up and display the route for a destination. 145 146 147 monitor Continuously report any changes to the routing 148 information base, routing lookup misses, or 149 suspected network partitionings. 150 151 152 show Display the list of routes to be applied at sys- 153 tem startup. Can be used only in conjunction with 154 the -p option. 155 156 157 158 The add and delete sub-commands have the following syntax: 159 160 route [ -fnvq ] cmd destination gateway [metric/netmask] 161 162 163 164 165 where cmd is add or delete, destination is the destination 166 host or network, and gateway is the next-hop intermediary 167 through which packets should be routed. Modifiers described 168 in OPERANDS can be placed anywhere on the command line. 169 170 171 The get and change sub-commands have the following syntax: 172 173 route [ -fnvq ] cmd destination [gateway [metric/netmask]] 174 175 176 177 178 where cmd is get or change, destination is the destination 179 host or network, and gateway is the next-hop intermediary 180 through which packets should be routed. Modifiers described 181 in OPERANDS can be placed anywhere on the command line. 182 183 184 The monitor sub-command has the following syntax: 185 186 route monitor [ -inet | -inet6 ] 187 188 189 190 191 192 SunOS 5.11 Last change: 26 Jun 2006 3 193 194 195 196 197 198 199 System Administration Commands route(1M) 200 201 202 203 OPERANDS 204 route executes its sub-commands on routes to destinations by 205 way of gateways. 206 207 Destinations and Gateways 208 By default, destination and gateway addresses are inter- 209 preted as IPv4 addresses. All symbolic names are tried first 210 as a host name, using getipnodebyname(3SOCKET). If this 211 lookup fails in the AF_INET case, getnetbyname(3SOCKET) 212 interprets the name as that of a network. 213 214 215 Including an optional modifier on the command line before 216 the address changes how the route sub-command interprets it. 217 218 219 The following modifiers are supported: 220 221 -inet Force the address to be interpreted as an IPv4 222 address, that is, under the AF_INET address fam- 223 ily. 224 225 226 -inet6 Force the address to be interpreted as an IPv6 227 address, that is, under the AF_INET6 address fam- 228 ily. 229 230 231 232 For IPv4 addresses, routes to a particular host are by 233 default distinguished from those to a network by interpret- 234 ing the Internet address specified as the destination. If 235 the destination has a local address part (that is, the por- 236 tion not covered by the netmask) of 0, or if the destination 237 is resolved as the symbolic name of a network, then the 238 route is assumed to be to a network; otherwise, it is 239 presumed to be a route to a host. 240 241 242 You can force this selection by using one of the following 243 modifiers: 244 245 -host Force the destination to be interpreted as a host. 246 247 248 -net Force the destination to be interpreted as a net- 249 work. 250 251 252 253 For example: 254 255 256 257 258 SunOS 5.11 Last change: 26 Jun 2006 4 259 260 261 262 263 264 265 System Administration Commands route(1M) 266 267 268 269 Destination Destination Equivalent 270 __________________________________________________________ 271 128.32 -host 128.0.0.32 272 128.32.130 -host 128.32.0.130 273 -net 128.32 128.32.0.0 274 -net 128.32.130 128.32.130.0 275 276 277 278 Two modifiers avoid confusion between addresses and keywords 279 (for example., host used as a symbolic host name). You can 280 distinguish a destination by preceding it with the -dst 281 modifier. You can distinguish a gateway address by using the 282 -gateway modifier. If the destination is directly reachable 283 by way of an interface requiring no intermediary IP router 284 to act as a gateway, this can be indicated by using the 285 -interface or -iface modifier. 286 287 288 In the following example, the route does not refer to an 289 external gateway (router), but rather to one of the 290 machine's interfaces. Packets with IP destination addresses 291 matching the destination and mask on such a route are sent 292 out on the interface identified by the gateway address. For 293 interfaces using the ARP protocol, this type of route is 294 used to specify that all matching destinations are local to 295 the physical link. That is, a host could be configured to 296 ARP for all addresses, without regard to the configured 297 interface netmask, by adding a default route using this com- 298 mand. For example: 299 300 example# route add default hostname -interface 301 302 303 304 305 where gateway address hostname is the name or IP address 306 associated with the network interface over which all match- 307 ing packets should be sent. On a host with a single network 308 interface, hostname is usually the same as the nodename 309 returned by the uname -n command. See uname(1). 310 311 312 For backward compatibility with older systems, directly 313 reachable routes can also be specified by placing a 0 after 314 the gateway address: 315 316 example# route add default hostname 0 317 318 319 320 321 322 323 324 SunOS 5.11 Last change: 26 Jun 2006 5 325 326 327 328 329 330 331 System Administration Commands route(1M) 332 333 334 335 This value was once a route metric, but this metric is no 336 longer used. If the value is specified as 0, then the desti- 337 nation is directly reachable (equivalent to specifying 338 -interface). If it is non-zero but cannot be interpreted as 339 a subnet mask, then a gateway is used (default). 340 341 342 With the AF_INET address family or an IPv4 address, a 343 separate subnet mask can be specified. This can be specified 344 in one of the following ways: 345 346 o IP address following the gateway address . This is 347 typically specified in decimal dot notation as for 348 inet_addr(3SOCKET) rather than in symbolic form. 349 350 o IP address following the -netmask qualifier. 351 352 o Slash character and a decimal length appended to 353 the destination address. 354 355 356 If a subnet mask is not specified, the mask used is the sub- 357 net mask of the output interface selected by the gateway 358 address, if the classful network of the destination is the 359 same as the classful network of the interface. Otherwise, 360 the classful network mask for the destination address is 361 used. 362 363 364 Each of the following examples creates an IPv4 route to the 365 destination 192.0.2.32 subnet with a subnet mask of 366 255.255.255.224: 367 368 example# route add 192.0.2.32/27 somegateway 369 example# route add 192.0.2.32 -netmask 255.255.255.224 somegateway 370 example# route add 192.0.2.32 somegateway 255.255.255.224 371 372 373 374 375 For IPv6, only the slash format is accepted. The following 376 example creates an IPv6 route to the destination 33fe:: with 377 a netmask of 16 one-bits followed by 112 zero-bits. 378 379 example# route add -inet6 3ffe::/16 somegateway 380 381 382 383 384 In cases where the gateway does not uniquely identify the 385 output interface (for example, when several interfaces have 386 the same address), you can use the -ifp ifname modifier to 387 388 389 390 SunOS 5.11 Last change: 26 Jun 2006 6 391 392 393 394 395 396 397 System Administration Commands route(1M) 398 399 400 401 specify the interface by name. For example, *-ifp lo0* 402 associates the route with the *lo0* interface. If the named 403 interface is an underlying interface in an IPMP group, then 404 requests to add a route will automatically be translated to 405 the corresponding IPMP IP interface, and requests to delete 406 or change a route on an underlying interface will fail. 407 408 409 Routing Flags 410 Routes have associated flags that influence operation of the 411 protocols when sending to destinations matched by the 412 routes. These flags can be set (and in some cases cleared, 413 indicated by ~) by including the following modifiers on the 414 command line: 415 416 417 418 Modifier Flag Description 419 ______________________________________________________________________ 420 -interface ~RTF_GATEWAY Destination is directly reachable 421 -iface ~RTF_GATEWAY Alias for interface modifier 422 -static RTF_STATIC Manually added route 423 -nostatic ~RTF_STATIC Pretend route was added by kernel or 424 routing daemon 425 -reject RTF_REJECT Emit an ICMP unreachable when matched 426 -blackhole RTF_BLACKHOLE Silently discard packets duing updates 427 -proto1 RTF_PROTO1 Set protocol specific routing flag #1 428 -proto2 RTF_PROTO2 Set protocol specific routing flag #2 429 -private RTF_PRIVATE Do not advertise this route 430 -multirt RTF_MULTIRT Creates the specified redundant route 431 -setsrc RTF_SETSRC Assigns the default source address 432 433 434 435 The optional modifiers -rtt, -rttvar, -sendpipe, -recvpipe, 436 -mtu, -hopcount, -expire, and -ssthresh provide initial 437 values to quantities maintained in the routing entry by 438 transport level protocols, such as TCP. These can be indivi- 439 dually locked either by preceding each modifier to be locked 440 by the -lock meta-modifier, or by specifying that all ensu- 441 ing metrics can be locked by the -lockrest meta-modifier. 442 443 444 Some transport layer protocols can support only some of 445 these metrics. The following optional modifiers are sup- 446 ported: 447 448 -expire Lifetime for the entry. This optional modifier 449 is not currently supported. 450 451 452 -hopcount Maximum hop count. This optional modifier is 453 not currently supported. 454 455 456 -mtu Maximum MTU in bytes. 457 458 459 460 461 SunOS 5.11 Last change: 26 Jun 2006 7 462 463 464 465 466 467 468 System Administration Commands route(1M) 469 470 471 472 -recvpipe Receive pipe size in bytes. 473 474 475 -rtt Round trip time in microseconds. 476 477 478 -rttvar Round trip time variance in microseconds. 479 480 481 -sendpipe Send pipe size in bytes. 482 483 484 -ssthresh Send pipe size threshold in bytes. 485 486 487 -secattr Security attributes of the route. This modifier 488 is available only if the system is configured 489 with the Solaris Trusted Extensions feature. 490 491 The -secattr modifier has the following format: 492 493 min_sl=val,max_sl=val,doi=val,cipso 494 495 or: 496 497 sl=VAL,doi=VAL,cipso 498 499 In the first form, above, the val for min_sl 500 and max_sl is a sensitivity label in either hex 501 or string form. The val for doi is a non- 502 negative integer. The route will apply only for 503 packets with the same domain of interpretation 504 as defined by the doi value and within the 505 accreditation range defined by the min_sl and 506 max_sl values. The cipso keyword is optional 507 and set by default. Valid min_sl, max_sl and 508 doi keyword/value pairs are mandatory. Note 509 that if val contains a space, it must be pro- 510 tected by double quotes. 511 512 The second form, above, is equivalent to speci- 513 fying the first form with the same VAL for 514 min_sl and max_sl. The second form should be 515 used for the get command, because get uses only 516 a single sensitivity label. 517 518 519 Compatibility 520 The modifiers host and net are taken to be equivalent to 521 -host and -net. To specify a symbolic address that matches 522 one of these names, use the dst or gateway keyword to dis- 523 tinguish it. For example: -dst host 524 525 526 527 SunOS 5.11 Last change: 26 Jun 2006 8 528 529 530 531 532 533 534 System Administration Commands route(1M) 535 536 537 538 The following two flags are also accepted for compatibility 539 with older systems, but have no effect. 540 541 542 543 Modifier Flag 544 __________________________________________________________ 545 -cloning RTF_CLONING 546 -xresolve RTF_XRESOLVE 547 548 549 550 The -ifa hostname modifier is also accepted, but has no 551 effect. 552 553 FILES 554 /etc/defaultrouter List of default routers 555 556 557 /etc/hosts List of host names and net addresses 558 559 560 /etc/networks List of network names and addresses 561 562 563 ATTRIBUTES 564 See attributes(5) for descriptions of the following attri- 565 butes: 566 567 568 569 ____________________________________________________________ 570 | ATTRIBUTE TYPE | ATTRIBUTE VALUE | 571 |_____________________________|_____________________________| 572 | Availability | SUNWcsu | 573 |_____________________________|_____________________________| 574 575 576 SEE ALSO 577 uname(1), in.ripngd(1M), in.routed(1M), netstat(1M), 578 routed(1M), ioctl(2), getipnodebyname(3SOCKET), 579 getnetbyname(3SOCKET), inet_addr(3SOCKET), defaultrouter(4), 580 hosts(4), networks(4), attributes(5), ARP(7P), ip(7P), 581 route(7P), routing(7P) 582 583 DIAGNOSTICS 584 add [ host| network] destination:gateway flags 585 586 The specified route is being added to the tables. The 587 values printed are from the routing table entry supplied 588 in the ioctl(2) call. If the gateway address used was 589 not the primary address of the gateway (the first one 590 591 592 593 SunOS 5.11 Last change: 26 Jun 2006 9 594 595 596 597 598 599 600 System Administration Commands route(1M) 601 602 603 604 returned by getipnodebyname(3SOCKET)) the gateway 605 address is printed numerically as well as symbolically. 606 607 608 delete [ host| network] destination:gateway flags 609 change [ host| network] destination:gateway flags 610 611 As add, but when deleting or changing an entry. 612 613 614 destination done 615 616 When the -f flag is specified, or the flush sub-command 617 is used, each routing table entry deleted is indicated 618 with a message of this form. 619 620 621 Network is unreachable 622 623 An attempt to add a route failed because the gateway 624 listed was not on a directly-connected network. Give the 625 next-hop gateway instead. 626 627 628 not in table 629 630 A delete operation was attempted for an entry that is 631 not in the table. 632 633 634 entry exists 635 636 An add operation was attempted for a route that already 637 exists in the kernel. 638 639 640 routing table overflow 641 642 An operation was attempted, but the system was unable to 643 allocate memory to create the new entry. 644 645 646 insufficient privileges 647 648 An attempt to add, delete, change, or flush a route 649 failed because the calling process does not have 650 appropriate privileges. 651 652 653 NOTES 654 Specifying that destinations are local (with the -inter- 655 facemodifier) assumes that the routers implement proxy ARP, 656 657 658 659 SunOS 5.11 Last change: 26 Jun 2006 10 660 661 662 663 664 665 666 System Administration Commands route(1M) 667 668 669 670 meaning that they respond to ARP queries for all reachable 671 destinations. Normally, using either router discovery or RIP 672 is more reliable and scalable than using proxy ARP. See 673 in.routed(1M) for information related to RIP. 674 675 676 Combining the all destinations are local route with subnet 677 or network routes can lead to unpredictable results. The 678 search order as it relates to the all destinations are local 679 route are undefined and can vary from release to release. 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 SunOS 5.11 Last change: 26 Jun 2006 11 726 727 728