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 existance 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 symbollic 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 associ- 402 ates the route with the lo0 interface. 403 404 Routing Flags 405 Routes have associated flags that influence operation of the 406 protocols when sending to destinations matched by the 407 routes. These flags can be set (and in some cases cleared, 408 indicated by ~) by including the following modifiers on the 409 command line: 410 411 412 413 Modifier Flag Description 414 ______________________________________________________________________ 415 -interface ~RTF_GATEWAY Destination is directly reachable 416 -iface ~RTF_GATEWAY Alias for interface modifier 417 -static RTF_STATIC Manually added route 418 -nostatic ~RTF_STATIC Pretend route was added by kernel or 419 routing daemon 420 -reject RTF_REJECT Emit an ICMP unreachable when matched 421 -blackhole RTF_BLACKHOLE Silently discard packets duing updates 422 -proto1 RTF_PROTO1 Set protocol specific routing flag #1 423 -proto2 RTF_PROTO2 Set protocol specific routing flag #2 424 -private RTF_PRIVATE Do not advertise this route 425 -multirt RTF_MULTIRT Creates the specified redundant route 426 -setsrc RTF_SETSRC Assigns the default source address 427 428 429 430 The optional modifiers -rtt, -rttvar, -sendpipe, -recvpipe, 431 -mtu, -hopcount, -expire, and -ssthresh provide initial 432 values to quantities maintained in the routing entry by 433 transport level protocols, such as TCP. These can be indivi- 434 dually locked either by preceding each modifier to be locked 435 by the -lock meta-modifier, or by specifying that all ensu- 436 ing metrics can be locked by the -lockrest meta-modifier. 437 438 439 Some transport layer protocols can support only some of 440 these metrics. The following optional modifiers are sup- 441 ported: 442 443 -expire Lifetime for the entry. This optional modifier 444 is not currently supported. 445 446 447 -hopcount Maximum hop count. This optional modifier is 448 not currently supported. 449 450 451 -mtu Maximum MTU in bytes. 452 453 454 455 456 SunOS 5.11 Last change: 26 Jun 2006 7 457 458 459 460 461 462 463 System Administration Commands route(1M) 464 465 466 467 -recvpipe Receive pipe size in bytes. 468 469 470 -rtt Round trip time in microseconds. 471 472 473 -rttvar Round trip time variance in microseconds. 474 475 476 -sendpipe Send pipe size in bytes. 477 478 479 -ssthresh Send pipe size threshold in bytes. 480 481 482 -secattr Security attributes of the route. This modifier 483 is available only if the system is configured 484 with the Solaris Trusted Extensions feature. 485 486 The -secattr modifier has the following format: 487 488 min_sl=val,max_sl=val,doi=val,cipso 489 490 or: 491 492 sl=VAL,doi=VAL,cipso 493 494 In the first form, above, the val for min_sl 495 and max_sl is a sensitivity label in either hex 496 or string form. The val for doi is a non- 497 negative integer. The route will apply only for 498 packets with the same domain of interpretation 499 as defined by the doi value and within the 500 accreditation range defined by the min_sl and 501 max_sl values. The cipso keyword is optional 502 and set by default. Valid min_sl, max_sl and 503 doi keyword/value pairs are mandatory. Note 504 that if val contains a space, it must be pro- 505 tected by double quotes. 506 507 The second form, above, is equivalent to speci- 508 fying the first form with the same VAL for 509 min_sl and max_sl. The second form should be 510 used for the get command, because get uses only 511 a single sensitivity label. 512 513 514 Compatibility 515 The modifiers host and net are taken to be equivalent to 516 -host and -net. To specify a symbolic address that matches 517 one of these names, use the dst or gateway keyword to dis- 518 tinguish it. For example: -dst host 519 520 521 522 SunOS 5.11 Last change: 26 Jun 2006 8 523 524 525 526 527 528 529 System Administration Commands route(1M) 530 531 532 533 The following two flags are also accepted for compatibility 534 with older systems, but have no effect. 535 536 537 538 Modifier Flag 539 __________________________________________________________ 540 -cloning RTF_CLONING 541 -xresolve RTF_XRESOLVE 542 543 544 545 The -ifa hostname modifier is also accepted, but has no 546 effect. 547 548 FILES 549 /etc/defaultrouter List of default routers 550 551 552 /etc/hosts List of host names and net addresses 553 554 555 /etc/networks List of network names and addresses 556 557 558 ATTRIBUTES 559 See attributes(5) for descriptions of the following attri- 560 butes: 561 562 563 564 ____________________________________________________________ 565 | ATTRIBUTE TYPE | ATTRIBUTE VALUE | 566 |_____________________________|_____________________________| 567 | Availability | SUNWcsu | 568 |_____________________________|_____________________________| 569 570 571 SEE ALSO 572 uname(1), in.ripngd(1M), in.routed(1M), netstat(1M), 573 routed(1M), ioctl(2), getipnodebyname(3SOCKET), 574 getnetbyname(3SOCKET), inet_addr(3SOCKET), defaultrouter(4), 575 hosts(4), networks(4), attributes(5), ARP(7P), ip(7P), 576 route(7P), routing(7P) 577 578 DIAGNOSTICS 579 add [ host| network] destination:gateway flags 580 581 The specified route is being added to the tables. The 582 values printed are from the routing table entry supplied 583 in the ioctl(2) call. If the gateway address used was 584 not the primary address of the gateway (the first one 585 586 587 588 SunOS 5.11 Last change: 26 Jun 2006 9 589 590 591 592 593 594 595 System Administration Commands route(1M) 596 597 598 599 returned by getipnodebyname(3SOCKET)) the gateway 600 address is printed numerically as well as symbolically. 601 602 603 delete [ host| network] destination:gateway flags 604 change [ host| network] destination:gateway flags 605 606 As add, but when deleting or changing an entry. 607 608 609 destination done 610 611 When the -f flag is specified, or the flush sub-command 612 is used, each routing table entry deleted is indicated 613 with a message of this form. 614 615 616 Network is unreachable 617 618 An attempt to add a route failed because the gateway 619 listed was not on a directly-connected network. Give the 620 next-hop gateway instead. 621 622 623 not in table 624 625 A delete operation was attempted for an entry that is 626 not in the table. 627 628 629 entry exists 630 631 An add operation was attempted for a route that already 632 exists in the kernel. 633 634 635 routing table overflow 636 637 An operation was attempted, but the system was unable to 638 allocate memory to create the new entry. 639 640 641 insufficient privileges 642 643 An attempt to add, delete, change, or flush a route 644 failed because the calling process does not have 645 appropriate privileges. 646 647 648 NOTES 649 Specifying that destinations are local (with the -inter- 650 facemodifier) assumes that the routers implement proxy ARP, 651 652 653 654 SunOS 5.11 Last change: 26 Jun 2006 10 655 656 657 658 659 660 661 System Administration Commands route(1M) 662 663 664 665 meaning that they respond to ARP queries for all reachable 666 destinations. Normally, using either router discovery or RIP 667 is more reliable and scalable than using proxy ARP. See 668 in.routed(1M) for information related to RIP. 669 670 671 Combining the all destinations are local route with subnet 672 or network routes can lead to unpredictable results. The 673 search order as it relates to the all destinations are local 674 route are undefined and can vary from release to release. 675 676 677 678 679 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 SunOS 5.11 Last change: 26 Jun 2006 11 721 722 723