routemap.texi 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. @node Route Map
  2. @chapter Route Map
  3. Route maps provide a means to both filter and/or apply actions to
  4. route, hence allowing policy to be applied to routes.
  5. @menu
  6. * Route Map Command::
  7. * Route Map Match Command::
  8. * Route Map Set Command::
  9. * Route Map Call Command::
  10. * Route Map Exit Action Command::
  11. * Route Map Examples::
  12. @end menu
  13. Route-maps are an ordered list of route-map entries. Each entry may
  14. specify up to four distincts sets of clauses:
  15. @table @samp
  16. @item Matching Policy
  17. This specifies the policy implied if the @samp{Matching Conditions} are
  18. met or not met, and which actions of the route-map are to be taken, if
  19. any. The two possibilities are:
  20. @itemize @minus
  21. @item
  22. @samp{permit}: If the entry matches, then carry out the @samp{Set
  23. Actions}. Then finish processing the route-map, permitting the route,
  24. unless an @samp{Exit Action} indicates otherwise.
  25. @item
  26. @samp{deny}: If the entry matches, then finish processing the route-map and
  27. deny the route (return @samp{deny}).
  28. @end itemize
  29. The @samp{Matching Policy} is specified as part of the command which
  30. defines the ordered entry in the route-map. See below.
  31. @item Matching Conditions
  32. A route-map entry may, optionally, specify one or more conditions which
  33. must be matched if the entry is to be considered further, as governed
  34. by the Match Policy. If a route-map entry does not explicitely specify
  35. any matching conditions, then it always matches.
  36. @item Set Actions
  37. A route-map entry may, optionally, specify one or more @samp{Set
  38. Actions} to set or modify attributes of the route.
  39. @item Call Action
  40. Call to another route-map, after any @samp{Set Actions} have been
  41. carried out. If the route-map called returns @samp{deny} then
  42. processing of the route-map finishes and the route is denied,
  43. regardless of the @samp{Matching Policy} or the @samp{Exit Policy}. If
  44. the called route-map returns @samp{permit}, then @samp{Matching Policy}
  45. and @samp{Exit Policy} govern further behaviour, as normal.
  46. @item Exit Policy
  47. An entry may, optionally, specify an alternative @samp{Exit Policy} to
  48. take if the entry matched, rather than the normal policy of exiting the
  49. route-map and permitting the route. The two possibilities are:
  50. @itemize @minus
  51. @item
  52. @samp{next}: Continue on with processing of the route-map entries.
  53. @item
  54. @samp{goto N}: Jump ahead to the first route-map entry whose order in
  55. the route-map is >= N. Jumping to a previous entry is not permitted.
  56. @end itemize
  57. @end table
  58. The default action of a route-map, if no entries match, is to deny.
  59. I.e. a route-map essentially has as its last entry an empty @samp{deny}
  60. entry, which matches all routes. To change this behaviour, one must
  61. specify an empty @samp{permit} entry as the last entry in the route-map.
  62. To summarise the above:
  63. @multitable {permit} {action} {No Match}
  64. @headitem @tab Match @tab No Match
  65. @item @emph{Permit} @tab action @tab cont
  66. @item @emph{Deny} @tab deny @tab cont
  67. @end multitable
  68. @table @samp
  69. @item action
  70. @itemize @minus
  71. @item
  72. Apply @emph{set} statements
  73. @item
  74. If @emph{call} is present, call given route-map. If that returns a @samp{deny}, finish
  75. processing and return @samp{deny}.
  76. @item
  77. If @samp{Exit Policy} is @emph{next}, goto next route-map entry
  78. @item
  79. If @samp{Exit Policy} is @emph{goto}, goto first entry whose order in the list
  80. is >= the given order.
  81. @item
  82. Finish processing the route-map and permit the route.
  83. @end itemize
  84. @item deny
  85. @itemize @minus
  86. @item
  87. The route is denied by the route-map (return @samp{deny}).
  88. @end itemize
  89. @item cont
  90. @itemize @minus
  91. @item
  92. goto next route-map entry
  93. @end itemize
  94. @end table
  95. @node Route Map Command
  96. @section Route Map Command
  97. @deffn {Command} {route-map @var{route-map-name} (permit|deny) @var{order}} {}
  98. Configure the @var{order}'th entry in @var{route-map-name} with
  99. @samp{Match Policy} of either @emph{permit} or @emph{deny}.
  100. @end deffn
  101. @node Route Map Match Command
  102. @section Route Map Match Command
  103. @deffn {Route-map Command} {match ip address @var{access_list}} {}
  104. Matches the specified @var{access_list}
  105. @end deffn
  106. @deffn {Route-map Command} {match ip next-hop @var{ipv4_addr}} {}
  107. Matches the specified @var{ipv4_addr}.
  108. @end deffn
  109. @deffn {Route-map Command} {match as-path @var{as_path}} {}
  110. Matches the specified @var{as_path}.
  111. @end deffn
  112. @deffn {Route-map Command} {match metric @var{metric}} {}
  113. Matches the specified @var{metric}.
  114. @end deffn
  115. @deffn {Route-map Command} {match local-preference @var{metric}} {}
  116. Matches the specified @var{local-preference}.
  117. @end deffn
  118. @deffn {Route-map Command} {match community @var{community_list}} {}
  119. Matches the specified @var{community_list}
  120. @end deffn
  121. @node Route Map Set Command
  122. @section Route Map Set Command
  123. @deffn {Route-map Command} {set ip next-hop @var{ipv4_address}} {}
  124. Set the BGP nexthop address.
  125. @end deffn
  126. @deffn {Route-map Command} {set local-preference @var{local_pref}} {}
  127. Set the BGP local preference.
  128. @end deffn
  129. @deffn {Route-map Command} {set weight @var{weight}} {}
  130. Set the route's weight.
  131. @end deffn
  132. @deffn {Route-map Command} {set metric @var{metric}} {}
  133. @anchor{routemap set metric}
  134. Set the BGP attribute MED.
  135. @end deffn
  136. @deffn {Route-map Command} {set as-path prepend @var{as_path}} {}
  137. Set the BGP AS path to prepend.
  138. @end deffn
  139. @deffn {Route-map Command} {set community @var{community}} {}
  140. Set the BGP community attribute.
  141. @end deffn
  142. @deffn {Route-map Command} {set ipv6 next-hop global @var{ipv6_address}} {}
  143. Set the BGP-4+ global IPv6 nexthop address.
  144. @end deffn
  145. @deffn {Route-map Command} {set ipv6 next-hop local @var{ipv6_address}} {}
  146. Set the BGP-4+ link local IPv6 nexthop address.
  147. @end deffn
  148. @node Route Map Call Command
  149. @section Route Map Call Command
  150. @deffn {Route-map Command} {call @var{name}} {}
  151. Call route-map @var{name}. If it returns deny, deny the route and
  152. finish processing the route-map.
  153. @end deffn
  154. @node Route Map Exit Action Command
  155. @section Route Map Exit Action Command
  156. @deffn {Route-map Command} {on-match next} {}
  157. @deffnx {Route-map Command} {continue} {}
  158. Proceed on to the next entry in the route-map.
  159. @end deffn
  160. @deffn {Route-map Command} {on-match goto @var{N}} {}
  161. @deffnx {Route-map Command} {continue @var{N}} {}
  162. Proceed processing the route-map at the first entry whose order is >= N
  163. @end deffn
  164. @node Route Map Examples
  165. @section Route Map Examples
  166. A simple example of a route-map:
  167. @example
  168. @group
  169. route-map test permit 10
  170. match ip address 10
  171. set local-preference 200
  172. @end group
  173. @end example
  174. This means that if a route matches ip access-list number 10 it's
  175. local-preference value is set to 200.
  176. See @ref{BGP Configuration Examples} for examples of more sophisticated
  177. useage of route-maps, including of the @samp{call} action.