|
|
gated control statements consist of import control statements and export control statements. These statements include clauses on route filtering and autonomous system (AS) path matching.
Routes are filtered by specifying configuration language that will match a certain set of routes by destination or by destination and mask. Among other places, route filters are used on martians, import, and export statements.
The action taken when no match is found is dependent on the context. For instance, import and export route filters assume an ``all reject ;'' at the end of a list.
A route will match the most specific filter that applies. Specifying more than one filter with the same destination, mask, and modifiers will generate an error. The filtering syntax is as follows:
network network mask mask network mask-length number all host hostThese are all the possible formats for a route filter. Not all of these formats are available in all places; for instance, the host format is not valid for martians.
In most cases, it is possible to specify additional parameters relevant to the
context of the filter. For example, on a martian
statement, it is possible to
specify the allow keyword; on an import
statement, you can specify a preference; and on an
export statement you can specify a metric.
If no additional parameters are specified, any destination that falls in the range given by the network and mask is matched; the mask of the destination is ignored. If a natural network is specified, the network, any subnets, and any hosts will match.
0.0.0.0 mask 0.0.0.0
host mask 255.255.255
An AS path is a list of autonomous systems that routing information has passed through to get to this router and an indicator of the origin of the AS path. This information can be used to prefer one path to a destination network over another. The primary method for doing this with gated is to specify a list of patterns to be applied to AS paths when importing and exporting routes.
Each autonomous system that a route passes through prepends its AS number to the beginning of the AS path.
The origin information details the completeness of AS path information. An origin of igp indicates the route was learned from an interior routing protocol and is most likely complete. An origin of egp indicates the route was learned from an exterior routing protocol that does not support AS paths (EGP, for example) and the path is most likely not complete. When the path information is definitely not complete, an origin of incomplete is used.
AS path regular expressions are defined in RFC 1164, section 4.2.
An AS path is matched using the following syntax:
aspath aspath_regexp origin [ any | igp | egp | incomplete ]This specifies that an AS matching the aspath_regexp with the specified origin is matched.
Technically, an AS path regular expression is a regular expression with the alphabet being the set of AS numbers. An AS path regular expression is composed of one or more AS path expressions. An AS path expression is composed of AS path terms and AS path operators.
An AS path term is one of the following three objects:
autonomous_system ( aspath_regexp )
aspath_term {m,n} aspath_term {m} aspath_term {m,} aspath_term aspath_term + aspath_term ? aspath_term | aspath_term
Importation of routes from routing protocols and installation of the routes in gated's routing database are controlled by import statements. The format of an import statement varies depending on the source protocol.
In all cases, one of two keywords may be specified to control how routes compete with other protocols:
import proto bgp | egp autonomoussystem autonomous_system restrict ; import proto bgp | egp autonomoussystem autonomous_system [ preference preference ] { route_filter [ restrict | ( preference preference ) ] ; } ;EGP importation may be controlled by autonomous_system. BGP also supports controlling propagation by the use of AS path regular expressions, which are documented in the section on matching AS paths. Note that EGP and BGP Versions 2 and 3 only support the propagation of natural networks, so the host and default route filters are meaningless.import proto bgp aspath aspath_regexp origin any | ( [ igp ] [egp ] [ incomplete ] ) restrict ; import proto bgp aspath aspath_regexp origin any | ( [ igp ] [egp ] [ incomplete ] ) [ preference preference ] { route_filter [ restrict | ( preference preference ) ] ; } ;
EGP and BGP both store any routes that were rejected implicitly by not being mentioned in a route filter or explicitly with the restrict keyword in the routing table with a negative preference. A negative preference prevents a route from becoming active, which prevents it from being installed in the forwarding table or exported to other protocols. This alleviates breaking and reestablishing a session upon reconfiguration if importation policy is changed.
import proto rip | redirect [ ( interface interface_list ) | (gateway gateway_list ) ] restrict ; import proto rip | redirect [ ( interface interface_list ) | (gateway gateway_list ) ] [ preference preference ] { route_filter [ restrict | ( preference preference ) ] ; } ;
The importation of RIP and Redirect routes may be controlled by any of protocol, source interface, and source gateway. If more than one is specified, they are processed from most general (protocol) to most specific (gateway).
RIP doesn't support the use of preference to choose between routes
of the same protocol; that is left to the protocol metrics. These protocols do
not save routes that were rejected, because they have short update intervals.
import proto ospfase [ tag ospf_tag ] restrict ; import proto ospfase [ tag ospf_tag ] [ preference preference ] { route_filter [ restrict | ( preference preference ) ] ; } ;
Due to the nature of OSPF,
only the importation of ASE routes may be
controlled. OSPF intra- and inter-area
routes are always imported into the
gated routing table with a preference of 10.
If a tag is specified, the import
clause will apply only to routes with the specified tag. Like the other interior
protocols, preference cannot be used to choose between
OSPF ASE routes;
that is done by the OSPF costs.
Routes that are rejected by policy are stored in
the table with a negative preference.
The import statement controls which routes received from other systems are used by gated, and the export statement controls which routes are advertised by gated to other systems. Like the import statement, the syntax of the export statement varies slightly per protocol. The syntax of the export statement is similar to the syntax of the import statement, and the meanings of many of the parameters are identical. The main difference between the two is that while route importation is controlled just by source information, route exportation is controlled by both destination and source.
The outer portion of a given export statement specifies the destination of the routing information you are controlling. The middle portion restricts the sources of importation that you wish to consider. The innermost portion is a route filter used to select individual routes.
The most specific specification of a metric is the one applied to the route being exported. The values that may be specified for a metric depend on the destination protocol that is referenced by this export statement.
As mentioned above, the syntax of the export statement varies depending on the protocol it is being applied to. One thing that applies in all cases is the specification of a metric. All protocols define a default metric to be used for routes being exported; in most cases, this can be overridden at several levels of the export statement.
The specification of the source of the routing information being exported (the export_list) is described at ``Specifying the source (export_list)''.
export proto bgp | egp as autonomous_system restrict ; export proto bgp | egp as autonomous_system [ metric metric ] { export_list } ;
Exportation to EGP and BGP is controlled by autonomous_system; the same policy is applied to all routers in the AS. EGP metrics range from 0 to 255 inclusive with 0 being the most attractive.
BGP metrics are 16-bit unsigned quantities; that is, they range from 0 to 65535 inclusive with 0 being the most attractive.
If no export policy is specified, only routes to attached interfaces will be exported. If any policy is specified, the defaults are overridden; it is necessary to explicitly specify everything that should be exported.
Note that EGP and BGP Versions 2 and 3 support only the propagation of natural networks, so the host and default route filters are meaningless.
export proto rip [ ( interface interface_list ) | (gateway gateway_list ) ] restrict ; export proto rip [ ( interface interface_list ) | (gateway gateway_list ) ] [ metric metric ] { export_list } ;
Exportation to RIP is controlled by any of protocol, interface, or gateway. If more than one is specified, they are processed from most general (protocol) to most specific (gateway).
It is not possible to set metrics for exporting RIP routes into RIP. Attempts to do this are silently ignored.
If no export policy is specified, RIP and interface routes are exported into RIP. If any policy is specified, the defaults are overridden; it is necessary to explicitly specify everything that should be exported.
RIP Version 1 assumes that all subnets of the shared network have the same subnet mask, so they are only able to propagate subnets of that network. RIP Version 2 removes that restriction and is capable of propagating all routes when not sending Version 1-compatible updates.
To announce routes that specify a next hop of the loopback interface (that is, static and internally generated default routes) via RIP, it is necessary to specify the metric at some level in the export clause. Just setting a default metric such as RIP is not sufficient. This is a safeguard to verify that the announcement is intended.
export proto ospfase [ type 1 | 2 ] [ tag ospf_tag ] restrict ; export proto ospfase [ type 1 | 2 ] [ tag ospf_tag ] [ metric metric ] { export_list } ;
It is not possible to create OSPF intra- or inter-area routes by exporting routes from the gated routing table into OSPF. It is only possible to export from the gated routing table into OSPF ASE routes. It is also not possible to control the propagation of OSPF routes within the OSPF protocol.
There are two types of OSPF ASE route, type 1 and type 2; see the OSPF protocol configuration for a detailed explanation of the two types. The default type is specified by the defaults subclause of the ospf clause. This may be overridden by a specification on the export statement.
OSPF ASE routes also have the provision to carry a tag. This is an arbitrary 32-bit number that can be used on OSPF routers to filter routing information. See the OSPF protocol configuration for detailed information on OSPF tags. The default tag specified by the ospf defaults clause may be overridden by a tag specified on the export statement.
The export_list specifies export based on the origin of a route, and the syntax varies depending on the source.
All the formats below with the variable route_filter allow
route filters. See
``gated route filtering''
for a detailed explanation of how they work.
When no route filtering is
specified (when restrict is specified on the
first line of a statement), all
routes from the specified source will match that statement. If any filters are
specified, only routes that match the specified filters will be exported. Put
differently, if any filters are specified, an ``all restrict ;'' is
assumed at the end of the list.
proto bgp | egp autonomoussystem autonomous_system restrict ; proto bgp | egp autonomoussystem autonomous_system [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
BGP and EGP routes may be specified by source autonomous_system. All routes may be exported by AS path; see below for more information.
proto rip [ ( interface interface_list ) | (gateway gateway_list ) ] restrict ; proto rip [ ( interface interface_list ) | (gateway gateway_list ) ] [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
RIP routes may be exported by protocol, source interface, and/or
source gateway.
proto ospf | ospfase restrict ; proto ospf | ospfase [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
Both OSPF and OSPF ASE routes may be exported into other protocols. See below for information on exporting by tag.
proto direct | static [ (interface interface_list ) ] restrict ; proto direct | static [ (interface interface_list ) ] [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
These protocols may be exported by protocol or by the interface of the next hop. These protocols are:
proto default restrict ; proto default [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
These protocols may only be referenced by protocol. The keyword default refers to routes created by the gendefault option.
proto proto aspath aspath_regexp origin [ any | igp | egp | incomplete ] restrict ; proto proto aspath aspath_regexp origin [ any | igp | egp | incomplete ] [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
When BGP is configured, all routes are assigned an AS path when they are added to the routing table. For all interior routes, this AS path specifies igp as the origin and no ASEs in the AS path (the current AS is added when the route is exported). For EGP routes, this AS path specifies EGP as the origin and the source AS as the AS path. For BGP routes, the AS path is stored as learned from BGP.
proto proto tag tag restrict ; proto proto tag tag [ metric metric ] { route_filter [ restrict | ( metric metric ) ] ; } ;
Both OSPF and RIP Version 2 currently support tags; all other protocols always have a tag of zero. The source of exported routes may be selected based on this tag. This is useful when routes are classified by tag when they are exported into a given routing protocol.