7.7 Configuring gatedgated is available from http://www.gated.org . Appendix B, A gated Reference , provides information about downloading and compiling the software. In this section, we use gated release 3.5.5, the version of gated that is currently available without restrictions. There are other, newer versions of gated available to members of the Gated Consortium. If you plan to build products based on gated or you plan to do research on routing protocols using gated , you should join the consortium. For the purposes of this book, release 3.5.5 is fine. gated reads its configuration from the /etc/gated.conf file. The configuration commands in the file resemble C code. All statements end with a semicolon, and associated statements are grouped together by curly braces. This structure makes it simple to see what parts of the configuration are associated with each other, which is important when multiple protocols are configured in the same file. In addition to structure in the language, the /etc/gated.conf file also has a structure. The different configuration statements, and the order in which these statements must appear, divide gated.conf into sections: option statements , interface statements , definition statements , protocol statements , static statements , control statements , and aggregate statements . Entering a statement out of order causes an error when parsing the file. Two other types of statements do not fall into any of these categories. They are directive statements and trace statements . These can occur anywhere in the gated.conf file and do not directly relate to the configuration of any protocol. These statements provide instructions to the parser, and instructions to control tracing from within the configuration file. The gated configuration commands are summarized in Table 7.2 The table lists each command by name, identifies the statement type, and provides a very short synopsis of each command's function. The entire command language is covered in detail in Appendix B .
Just from this brief description, you can see that the gated configuration language has many commands. The language provides configuration control for several different protocols and additional commands to configure the added features of gated itself. All of this can be confusing. To avoid confusion, don't try to understand the details of everything offered by gated . Your routing environment will not use all of these protocols and features. Even if you are providing the gateway at the border between two anonymous systems, you will probably only run two routing protocols: one interior protocol and one exterior protocol. Only those commands that relate to your actual configuration need to be included in your configuration file. As you read this section, skip the things you don't need. For example, if you don't use the BGP protocol, don't study the bgp statement. When you do need more details about a specific statement, look it up in Appendix B . With this in mind, let's look at some sample configurations. 7.7.1 Sample gated.conf ConfigurationsThe details in Appendix B may make gated configuration appear more complex than it is. gated 's rich command language can be confusing, as can its support for multiple protocols and the fact that it often provides a few ways to do the same thing. But some realistic examples will show that individual configurations do not need to be complex. The basis for the sample configurations is the network in Figure 7.4 We have installed a new router that provides our backbone with direct access to the Internet, and we have decided to install new routing protocols. We'll configure a host to listen to RIP-2 updates, an interior gateway to run RIP-2 and OSPF, and an exterior gateway to run OSPF and BGP. Figure 7.4: Sample routing topologyGateway cashew interconnects subnet 172.16.9.0 and subnet 172.16.1.0. To hosts on subnet 9, it advertises itself as the default gateway, because it is the gateway to the outside world. It uses RIP-2 to advertise routes on subnet 9. On subnet 1, gateway cashew advertises itself as the gateway to subnet 9 using OSPF. Gateway brazil provides subnet 1 with access to the Internet through autonomous system 164. Because gateway brazil provides access to the Internet, it announces itself as the default gateway to the other systems on subnet 1 using OSPF. To the external autonomous system, it uses BGP to announce itself as the path to the internal networks it learns about through OSPF. Let's look at the routing configuration of host macadamia , gateway cashew , and gateway brazil . 7.7.1.1 A host configurationThe host routing configuration is very simple. The rip yes statement enables RIP, and that's all that is really required to run RIP. That basic configuration should work for any system that runs RIP. The additional clauses enclosed in curly braces modify the basic RIP configuration. We use a few clauses to create a more interesting example. Here is the RIP-2 configuration for host macadamia :
# # enable rip, don't broadcast updates, # listen for RIP-2 updates on the multicast address, # check that the updates are authentic. # rip yes { nobroadcast ; interface 172.16.9.23 version 2 multicast authentication simple "REALstuff" ; } ;
This sample file shows the basic structure of
gated.conf
configuration statements. Lines beginning with a sharp sign (#) are
comments.
[12]
All statements end with semicolons. Clauses associated with a
configuration statement can span multiple lines and are enclosed in
curly braces (
The keyword
The 7.7.1.2 Interior gateway configurationsGateway configurations are more complicated than the simple host configuration shown above. Gateways always have multiple interfaces and occasionally run multiple routing protocols. Our first sample configuration is for the interior gateway between subnet 9 and the central backbone, subnet 1. It uses RIP-2 on subnet 9 to announce routes to the UNIX hosts. It uses OSPF on subnet 1 to exchange routes with the other gateways. Here's the configuration of gateway cashew :
# Don't time-out subnet 9 interfaces { interface 172.16.9.1 passive ; } ; # Define the OSPF router id routerid 172.16.1.9 ; # Enable RIP-2; announce OSPF routes to # subnet 9 with a cost of 5. rip yes { broadcast ; defaultmetric 5 ; interface 172.16.9.1 version 2 multicast authentication simple "REALstuff" ; } ; # Enable OSPF; subnet 1 is the backbone area; # use password authentication. ospf yes { backbone { authtype simple ; interface 172.16.1.9 { priority 5 ; authkey "It'sREAL" ; } ; } ; } ;
The
The
In the previous example we discussed all the clauses on the
rip
statement except one - the
The
The
The interface that connects this router to the backbone area is defined
by the interface clause. It has two associated subclauses. The
7.7.1.3 Exterior gateway configurationThe configuration for gateway brazil is the most complex because it runs both OSPF and BGP. The configuration file for gateway brazil is:
# Defines our AS number for BGP autonomoussystem 249; # Defines the OSPF router id routerid 172.16.1.1; # Disable RIP rip no; # Enable BGP bgp yes { preference 50 ; group type external peeras 164 { peer 10.6.0.103 ; peer 10.20.0.72 ; }; }; # Enable OSPF; subnet 1 is the backbone area; # use password authentication. ospf yes { backbone { authtype simple ; interface 172.16.1.1 { priority 10 ; authkey "It'sREAL" ; } ; } ; }; # Announce routes learned from OSPF and route # to directly connected network via BGP to AS 164 export proto bgp as 164 { proto direct ; proto ospf ; }; # Announce routes learned via BGP from # AS number 164 to our OSPF area. export proto ospfase type 2 { proto bgp as 164 { all ; }; };
This configuration enables both BGP and OSPF, and sets certain
protocol-specific parameters. BGP needs to know the AS number, which
is 249 for
nuts-net
. OSPF needs to know the router identifier
address. We set it to the address of the router interface that runs
OSPF. The AS number and the router identifier are defined early in the
configuration because
The first protocol statement is the one that turns RIP off. We don't
want to run RIP and the default for
gated
is to turn RIP on.
Therefore we explicitly disable RIP with the
BGP is enabled by the
The
The BGP neighbors from which updates are accepted are indicated by the
peer clauses. Each peer is a member of
the group. Everything related to the group, such as the AS number,
applies to every system in the group. To accept updates from any system, use
The OSPF protocol is enabled by the ospf yes statement. The configuration of OSPF on this router is the same as it is for other routers in the backbone area. The only parameter that has been changed from the previous example is the priority number. Because this route has a particularly heavy load, we have decided to make it slightly less preferred for the designated router election.
The export statements control the routes that
gated
advertises to
other routers. The first export statement directs
gated
to use
BGP (
The second export statement announces the routes learned from the
external autonomous system. The routes are received via BGP and are
advertised via OSPF. Because these are routes from an external
autonomous system, they are advertised as
autonomous system
external
(ASE) routes. That's why the export statement specifies
The source of the routes advertised in the second export statement is
the BGP connection (
All of the routes received from an external autonomous system could
produce a very large routing table. Individual routes are useful when
you have multiple border routers that can reach the outside world.
However, if you have only one border router, a default route may be all
that is needed. To export a default route, insert an
# Announce a default route when peering # with a BGP neighbor. export proto ospfase type 2 { proto default ; }; This export statement tells gated to advertise the border router as the default gateway, but only when it has an active connection to the external system. These few examples show that gated.conf files are usually small and easy to read. Use gated if you need to run a routing protocol on your computer. It allows you to use the same software and the same configuration language on all of your hosts, interior gateways, and exterior gateways. 7.7.2 Testing the ConfigurationTest the configuration file before you try to use it. The gated configuration syntax is complex and it is easy to make a mistake. Create your new configuration in a test file; test the new configuration; then move the test configuration to /etc/gated.conf . Here's how. Assume that a configuration file called test.conf has already been created. It is tested using -f and -c on the command line:
% The -f option tells gated to read the configuration from the named file instead of from /etc/gated.conf . In the sample it reads the configuration from test.conf . The -c option tells gated to read the configuration file and check for syntax errors. When gated finishes reading the file, it terminates; it does not modify the routing table. The -c option turns on tracing, so specify a trace file or the trace data will be displayed on your terminal. In the sample we specified trace.test as the trace file. The -c option also produces a snapshot of the state of gated after reading the configuration file and writes the snapshot to /usr/tmp/gated_dump . You don't need to be superuser or to terminate the active gated process to run gated when the -c option is used. The dump and the trace file ( trace.test ) can then be examined for errors and other information. When you're confident that the configuration is correct, become superuser and move your new configuration ( test.conf ) to /etc/gated.conf . An alternative command for testing the configuration file is gdc , though it must be run by the root user. It includes features for checking and installing a new configuration. gdc uses three different configuration files. The current configuration is /etc/gated.conf . The previous configuration is stored in /etc/gated.conf- . The "next" configuration is stored in /etc/gated.conf+ , which is normally the configuration that needs to be tested. Here's how gdc tests a configuration:
# In this sample the test configuration was copied to /etc/gated.conf+ and tested with the gdc checknew command. If syntax problems are found in the file, a warning message is displayed and the detailed error messages are written to /usr/tmp/gated_parse . There were no syntax errors in the example so we make the test file the current configuration with the gdc newconf command. This command moves the current configuration to gated.conf- and moves the new configuration ( gated.conf+ ) to the current configuration. The gdc restart command terminates gated if it is currently running - it was not in the example - and starts a new copy of gated using the new configuration. 7.7.2.1 Running gated at startupAs with any routing software, gated should be included in your startup file. Some systems come with the code to start gated included in the startup file. If your system doesn't, you'll need to add it. If you already have code in your startup file that runs routed , replace it with code to run gated . gated and routed should not be running at the same time. Our imaginary gateway, almond , is a Solaris system with code in the /etc/init.d/inetinit file that starts routed . We comment out those lines, and add these lines:
if [ -f /usr/sbin/gated -a -f /etc/gated.conf ]; then /usr/sbin/gated; echo -n 'gated' > /dev/console fi This code assumes that gated is installed in /usr/sbin and that the configuration file is named /etc/gated.conf . The code checks that gated is present, and that the configuration file /etc/gated.conf exists. If both files are found, gated begins. The code checks for a configuration file because gated usually runs with one. If gated is started without a configuration file, it checks the routing table for a default route. If it doesn't find one, it starts RIP; otherwise, it just uses the default route. Create an /etc/gated.conf file even if you only want to run RIP. The configuration file documents your routing configuration and protects you if the default configuration of gated changes in the future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|