BGP supports two basic types of sessions between neighbours, internal (sometimes refered to as IBGP) and external. Internal sessions are run between routers in the same autonomous system, while external sessions run between routers in different autonomous systems. When sending routes to an external peer the local AS number is prepended to the AS path, hence routes received from an external peer are guaranteed to have the AS number of that peer at the start of the path. Routes received from an internal neighbour will not in general have the local AS number prepended to the AS path, and hence will in general have the same AS path that the route had when the originating internal neighbour received the route from an external peer. Routes with no AS numbers in the path may be legitimately received from internal neighbours; these indicate that the received route should be considered internal to your own AS.
The BGP implementation supports three versions of the BGP protocol, versions 2, 3 and 4. BGP versions 2 and 3 are quite similar in capability and function. They will only propagate classed network routes, and the AS path is a simple array of AS numbers. BGP 4 will propagate fully general address-and-mask routes, and the AS path has some structure to represent the results of aggregating dissimilar routes.
External BGP sessions may or may not include a single metric, which BGP calls the Multi-Exit Discriminator, in the path attributes. For BGP versions 2 and 3 this metric is a 16-bit unsigned integer, for BGP version 4 it is a 32-bit unsigned integer. In either case smaller values of the metric are to be preferred. Currently this metric is only used to break ties between routes with equal preference from the same neighbour AS. Internal BGP sessions carry at least one metric in the path attributes, which BGP calls the LocalPref. The size of the metric is identical to the MED. For BGP versions 2 and 3 this metric is considered better when its value is smaller, for version 4 it is better when it is larger. BGP version 4 sessions may optionally carry a second metric on internal sessions, this being an internal version of the Multi-Exit Discriminator. The use of these metrics is dependent on the type of internal protocol processing which is specified.
BGP collapses routes with similar path attributes into a single update for advertisement. Routes that are received in a single update will be readvertised in a single update. The churn caused by the loss of a neighbor will be minimized and the initial advertisement sent during peer establishment will be maximally compressed. BGP does not read information from the kernel message-by-message, but fills the input buffer. It processes all complete messages in the buffer before reading again. BGP also does multiple reads to clear all incoming data queued on the socket. This feature may cause other protocols to be blocked for prolonged intervals by a busy peer connection.
All unreachable messages are collected into a single message and sent prior to reachable routes during a flash update. For these unreachable announcements, the next hop is set to the local address on the connection, no metric is sent and the path origin is set to incomplete. On external connections the AS path in unreachable announcements is set to the local AS, on internal connections the AS path is set to zero length.
The BGP implementation expects external peers to be directly attached to
a shared subnet, and expects those peers to advertise next hops which
are host addresses on that subnet (though this constraint can be relaxed
by configuration for testing). For groups of internal peers, however,
there are several alternatives which may be selected from by specifying
the group type. Type internal
groups expect all peers to
be directly attached to a shared subnet so that, like external peers,
the next hops received in BGP advertisements may be used directly for
forwarding. Type routing
groups instead will determine
the immediate next hops for routes by using the next hop received with
a route from a peer as a forwarding address, and using this to look up
an immediate next hop in an IGP's routes. Such groups support distant
peers, but need to be informed of the IGP whose routes they are using
to determine immediate next hops. Finally, type igp
groups
expect routes from the group peers to not be used for forwarding at
all. Instead they expect that copies of the BGP routes received will
also be received via an IGP, and that the BGP routes will only be used
to determine the path attributes associated with the IGP routes. Such
groups also support distant peers, and also need to be informed of the
IGP they are running with.
For internal BGP group types (and for test groups), where possible a
single outgoing message is built for all group peers based on the common
policy. A copy of the message is sent to every peer in the group,
with possible adjustments to the next hop field as appropriate to each
peer. This minimizes the computational load of running large numbers
of peers in these types of groups. BGP allows unconfigured peers to
connect if an appropriate group has been configured with an
allow
clause.
bgp yes | no | on | off [ { preference preference ; defaultmetric metric ; traceoptions trace_options ; group type ( external peeras autonomous_system ) | ( internal peeras autonomous_system ) | ( igp peeras autonomous_system proto proto ) | ( routing peeras autonomous_system proto proto interface interface_list ) | ( test peeras autonomous_system ) { allow { network network mask mask network masklen number all host host } ; peer host [ metricout metric ] [ localas autonomous_system ] [ nogendefault ] [ gateway gateway ] [ preference preference ] [ preference2 preference ] [ lcladdr local_address ] [ holdtime time ] [ version number ] [ passive ] [ sendbuffer number ] [ recvbuffer number ] [ indelay time ] [ outdelay time ] [ keep [ all | none ] ] [ analretentive ] [ noauthcheck ] [ noaggregatorid ] [ keepalivesalways ] [ v3asloopokay ] [ nov4asloop ] [ logupdown ] [ ttl ttl ] [ traceoptions trace_options ] ; } ; } ] ; external | internal | igp | test
The bgp
statement enables or disables BGP. By default
BGP is disabled. The default metric for announcing routes via BGP is
not to send a metric.
group
or
peer
statments or by import policy.
The proto names the interior protocol to be used to resolve BGP route next hops, and may be the name of any IGP in the configuration. By default the next hop in BGP routes advertised to type routing peers will be set to the local address on the BGP connection to those peers, as it is assumed a route to this address will be propagated via the IGP. The interface_list can optionally provide a list interfaces whose routes are carried via the IGP for which third party next hops may be used instead.
group
clauses and peer
subclauses. Any number of peer subclauses may be specified within a
group. A group clause usually defines default parameters for a group
of peers, these parameters apply to all subsidiary peer subclauses.
Any parameters from the peer subclause may be specified on the group
clause to provide defaults for the whole group (which may be
overridden for individual peers).
peer
statement, or
implicitly configured with the allow
statement. Both are
described here:
peer
connections from
any addresses in the specified range of network and mask pairs.
All parameters for these peers must be configured on the group
clause. The internal peer structures are created when an
incomming open request is received and destroyed when the
connection is broken. For more detail on specifying the
network/mask pairs, see the section on Route Filtering.
peer
clause configures an individual peer. Each
peer inherits all parameters specified on a group as defaults.
Those default may be overridden by parameters explicitly
specified on the peer subclaus.
Within each group
clause, individual peers can be
specified or a group of potential peers can be specified
using allow
. Allow
is used to specify a set of
address masks. If GateD receives a BGP connection request from any
address in the set specified, it will accept it and set up a peer
relationship.
The BGP peer
subclause allows the following parameters,
which can also be specified on the group
clause. All
are optional.
autonomoussystem
statement.
gateway
specifies a router on an attached network to be used as the next
hop router for routes received from this neighbor. This
parameter is not needed in most cases.
bgp
statement, so that GateD can prefer
routes from one peer, or group of peer, over othes. This
preference may be explicitly overriden by import policy.
preference
tie, the second
preference, preference2
may be used to break the
tie. The default value is 0.
gateway
parameter is used. A session with an external peer will only be
opened when an interface with the appropriate local address
(through which the peer or gateway address is directly reachable)
is operating. For other types of peers, a peer session will be
maintained when any interface with the specified local address is
operating. In either case incoming connections will only be
recognized as matching a configured peer if they are addressed to
the configured local address.
Indelay
is the
amount of time a route learned from a BGP peer must be stable
before it is accepted into the gated routing database.
Outdelay
is the amount of time a route must be
present in the gated routing database before it is exported to
BGP. The default value for each is 0, meaning that these
features are disabled.
ESTABLISHED
state.
state
option works with BGP, but does not
provide true state transition information.
Packet tracing options (which may be modified with
detail
, send
and recv
):
OPEN
packets which are used to establish a peer
relationship.
UPDATE
packets which are used to pass network
reachability information.
KEEPALIVE
packets which are used to verify peer reachability.