<< Previous Contents Index Next >>

7. Configuration file generation

ipacc is capable of extracting some of its own configuration information, or running external scripts to build configuration files.

The route-file and generate statements (see below) generate files. Use the provide statement in the host block to choose which host will run the file generation process. See Distributing files.

7.1. Extracting routing information: the route-file block

The route-file filename [kernel|routes|bgp] ... end route-file block defines the extraction of routing information into a file, which can subsequently be read using the ip statement.

The file format is:

with the timestamp indicating the last time the route was found in the routing table. The file can be included into the configuration inside an ip statement, i.e ip @filename. The route-expire timeout statement controls how long routes are kept in the output file after they have disappeared from the routing table. The default is two days.

7.1.1. Routing sources

The types of routes to be extracted are defined by the route-file statement's keywords. kernel (the default) means to extract routes from the local routing table by parsing the output of a netstat -rn shell command, while the routes and bgp keywords cause the output of the Cisco/Quagga commands show ip route and show ip bgp respectively to be parsed.

The route-source source statement, if provided, specifies the source containing the router address and router password statements (at a minimum) required to connect to a Cisco router and dump its routing or BGP table.

If no route-source statement is provided, and the extraction type is routes or bgp, the local Quagga database is connected to via the vtysh utility. For this to work, the ipacc user must be able to access the Zebra or BGP process's command socket. Typically, this is done by adding the ipacc user to the Quagga group in /etc/group, e.g.

7.1.2. Route filtering/selection

Routes are selected using the route-select netname filter .. statement. filter can be:

Any filter keyword may be negated by preceding it with a '!'.

Note that not all keywords are meaningful given a particular route extraction mechanism. For example, bgp extracts do not provide an interface; kernel and routes do not provide BGP AS paths, and kernel routes generally are not aware of the routing processes that put them there.

Where multiple filters are specified on one route-select line, they are treated as a logical AND; where the same keyword is provided, they form a logical OR within that keyword. For example, the statement:

would match any route within 192.168.0.0/16 or 10.0.0.0/8, as long as it went via the interface eth0. Where overlapping filters (or overlapping data in the same filter) are applied, the last entry takes priority.

BGP paths are selected using a regular expression. Regular expressions are as described under Regular expressions except that the '_' character has special meaning. '_' can match the start of a line, the end of a line, any whitespace or the ',', '{', '}', '(', and ')' characters. Note that if a regular expression contains spaces, it must be quoted.

The route-ignore [!]filter ... statement allows some routes to be selected that will be ignored. Selections are as for route-select. The route-ignore list is processed before the route-select list.

Note that the default route, i.e. 0.0.0.0/0 is specifically excluded from the output, so routing tables containing a default route can be parsed by route-file processing. Routes to multicast, invalid and loopback addresses are similarly rejected.

The route-remove netname address-range ... statement provides the same functionality as route-ignore ip address-range, however the statement format makes it compatible with include files in the form netname address .... Note that netname is ignored.

The nexthop netname address-range ... statement provides an abbreviated form of the route-select statement, largely for backwards compatibility. For example, the statement

is exactly equivalent to:

7.1.3. Filtering existing IP list

A route-file block can be used to filter an existing list of network names and IP addresses against the routing table, e.g. to split a list of customer IP addresses based on where those addresses have been provisioned on the network.

The route-list name address-range statement adds an entry into the list of IP addresses to filter. If this list exists, the list will be consulted after reading the routing table, and only those entries for which a corresponding routing table entry was found will be output.

The route-list-select filter statement specifies the filter criteria for the networks specified by route-list. filter is as for the route-select statement.

The route-list and route-list-select statements must not be used with the route-select or nexthop statements. route-ignore mat be used with both.

7.1.4. Timing

By default, route-source statements are processes every hour, however this can be modified with a frequency statement.
<< Previous Contents Index Next >>