@c -*-texinfo-*-
@c This is part of the GNU Zebra Manual.
@c Copyright (C) 1999, 2000 Kunihiro Ishiguro
@c See file zebra.texi for copying conditions.
@node bgpd, vtysh, ospf6d, Top
@comment  node-name,  next,  previous,  up
@chapter bgpd

@code{bgpd} is a Border Gateway Protocol 4 (BGP-4) protocol daemon.
BGP-4 is described in RFC1771.  bgpd also supports Multiprotocol
Extension for BGP-4 (sometimes known as BGP-4+ or MBGP) which is
described in RFC2283.

BGP-4 is one of the EGPs (Exterior Gateway Protocols) and is used for
inter-domain routing.

@menu
* Configuring bgpd::            
* BGP router::                  
* BGP peer::                    
* BGP network::                 
* Redistribute to BGP::         
* Peer configuration::          
* Peer filtering::              
* BGP terminal mode commands::  
* BGP Log Format::              
* Multiple Protocol Extension for BGP::  
* Route Reflector::             
* Route Server::                
* How to set up a 6-Bone connection::  
* Dump BGP packets and table::   
@end menu

@node Configuring bgpd, BGP router, bgpd, bgpd
@comment  node-name,  next,  previous,  up
@section Configuring bgpd

Default configuration file of @command{bgpd} is @file{bgpd.conf}.
@command{bgpd} searches the current directory first then
@value{INSTALL_PREFIX_ETC}/bgpd.conf.  All of bgpd's command must be
configured in @file{bgpd.conf}.

@command{bgpd} specific invocation options are described below.  Common
options may also be specified (@pxref{Common Invocation Options}).

@table @samp
@item -p @var{PORT}
@itemx --bgp_port=@var{PORT}
Set the bgp protocol's port number.

@item -r
@itemx --retain
When program terminates, retain BGP routes added by zebra.
@end table

@node BGP router, BGP peer, Configuring bgpd, bgpd
@comment  node-name,  next,  previous,  up
@section BGP router

  First of all you must configure BGP router with @command{router bgp}
command.  To configure BGP router, you need AS number.  AS number is an
identification of autonomous system.  BGP protocol uses the AS number
for detecting whether the BGP connection is internal one or external one.

  AS number is a digit between 1 and 65535.  The use of AS numbers is
described in RFC1930.  AS numbers 64512 through 65535 are defined as
private AS numbers.  Private AS numbers must not to be advertised in the
global Internet.

@deffn Command {router bgp @var{as-number}} {}
Enable a BGP protocol process with the specified @var{as-number}.  After
this statement you can input any @code{BGP Commands}.  You can not
create different BGP process under different @var{as-number} without
specifying @code{multiple-instance} (@pxref{Multiple instance}).
@end deffn

@deffn Command {no router bgp @var{as-number}} {}
Destroy a BGP protocol process with the specified @var{as-number}.
@end deffn

@deffn {BGP Command} {bgp router-id @var{router-id}} {}
This command specifies the router-ID.  If @command{bgpd} connects to @command{zebra} it gets
interface and address information.  In that case default router ID value
is selected as the largest IP Address of the interfaces.  When
@code{router zebra} is not enabled @command{bgpd} can't get interface information
so @code{router-id} is set to 0.0.0.0.  So please set router-id by hand.
@end deffn



@node BGP peer, BGP network, BGP router, bgpd
@comment  node-name,  next,  previous,  up
@section BGP peer

@deffn {BGP Command} {neighbor @var{peer} remote-as @var{as-number}} {}
Creates a new neighbor whose remote-as is @var{as-number}.  @var{peer}
can be an IPv4 address or an IPv6 address.
@example
@group
router bgp 1
 neighbor 10.0.0.1 remote-as 2
@end group
@end example
In this case my router, in AS-1, is trying to peer with AS-2 at
10.0.0.1.

This command must be the first command used when configuring a neighbor.
If the remote-as is not specified, @command{bgpd} will complain like this:
@example
can't find neighbor 10.0.0.1
@end example
@end deffn

@node BGP network, Redistribute to BGP, BGP peer, bgpd
@comment  node-name,  next,  previous,  up
@section BGP network

@deffn {BGP Command} {network @var{network}} {}
This command adds the announcement network.
@example
@group
router bgp 1
 network 10.0.0.0/8
@end group
@end example
This configuration example says that network 10.0.0.0/8 will be
announced to all neighbors.  Some vendors' routers don't advertise
routes if they aren't present in their IGP routing tables; @code{bgp}
doesn't care about IGP routes when announcing its routes.
@end deffn

@deffn {BGP Command} {no network @var{network}} {}
@end deffn

@deffn {BGP Command} {aggregate-address @var{network}} {}
This command specifies an aggregate address.
@end deffn

@deffn {BGP Command} {no aggregate-address @var{network}} {}
@end deffn

@node Redistribute to BGP, Peer configuration, BGP network, bgpd
@comment  node-name,  next,  previous,  up
@section Redistribute to BGP

@deffn {BGP Command} {redistribute kernel} {}
Redistribute kernel route to BGP process.
@end deffn

@deffn {BGP Command} {redistribute static} {}
Redistribute static route to BGP process.
@end deffn

@deffn {BGP Command} {redistribute connected} {}
Redistribute connected route to BGP process.
@end deffn

@deffn {BGP Command} {redistribute rip} {}
Redistribute RIP route to BGP process.
@end deffn

@deffn {BGP Command} {redistribute ospf} {}
Redistribute OSPF route to BGP process.
@end deffn

@node Peer configuration, Peer filtering, Redistribute to BGP, bgpd
@comment  node-name,  next,  previous,  up
@section Peer configuration

In a @code{router bgp} clause there are neighbor specific configurations
required.

@deffn {BGP Command} {neighbor @var{peer} shutdown} {}
@deffnx {BGP Command} {no neighbor @var{peer} shutdown} {}
Shutdown the peer.  We can delete the neighbor's configuration by
@code{no neighbor @var{peer} remote-as @var{as-number}} but all
configuration of the neighbor will be deleted.  When you want to
preserve the configuration, but want to drop the BGP peer, use this
syntax.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} ebgp-multihop} {}
@deffnx {BGP Command} {no neighbor @var{peer} ebgp-multihop} {}
@end deffn

@deffn {BGP Command} {neighbor @var{peer} description ...} {}
@deffnx {BGP Command} {no neighbor @var{peer} description ...} {}
Set description of the peer.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} version @var{version}} {}
Set up the neighbor's BGP version.  @var{version} can be @var{4},
@var{4+} or @var{4-}.  BGP version @var{4} is the default value used for
BGP peering.  BGP version @var{4+} means that the neighbor supports
Multiprotocol Extensions for BGP-4.  BGP version @var{4-} is similar but
the neighbor speaks the old Internet-Draft revision 00's Multiprotocol
Extensions for BGP-4.  Some routing software is still using this
version.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} interface @var{ifname}} {}
@deffnx {BGP Command} {no neighbor @var{peer} interface @var{ifname}} {}
When you connect to a BGP peer over an IPv6 link-local address, you have
to specify the @var{ifname} of the interface used for the connection.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} next-hop-self} {}
@deffnx {BGP Command} {no neighbor @var{peer} next-hop-self} {}
This command specifies an announced route's nexthop as being equivalent
to the address of the bgp router.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} update-source} {}
@deffnx {BGP Command} {no neighbor @var{peer} update-source} {}
@end deffn

@deffn {BGP Command} {neighbor @var{peer} default-originate} {}
@deffnx {BGP Command} {no neighbor @var{peer} default-originate} {}
@command{bgpd}'s default is to not announce the default route (0.0.0.0/0) even it
is in routing table.  When you want to announce default routes to the
peer, use this command.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} port @var{port}} {}
@deffnx {BGP Command} {neighbor @var{peer} port @var{port}} {}
@end deffn

@deffn {BGP Command} {neighbor @var{peer} send-community} {}
@deffnx {BGP Command} {neighbor @var{peer} send-community} {}
@end deffn

@deffn {BGP Command} {neighbor @var{peer} weight @var{weight}} {}
@deffnx {BGP Command} {no neighbor @var{peer} weight @var{weight}} {}
This command specifies a default @var{weight} value for the neighbor's
routes.
@end deffn

@deffn {BGP Command} {neighbor @var{peer} maximum-prefix @var{number}} {}
@deffnx {BGP Command} {no neighbor @var{peer} maximum-prefix @var{number}} {}
@end deffn

@node Peer filtering, BGP terminal mode commands, Peer configuration, bgpd
@comment  node-name,  next,  previous,  up
@section Peer filtering

@deffn {BGP Command} {neighbor @var{peer} distribute-list @var{name} [in|out]} {}
This command specifies a distribute-list for the peer.  @var{direct} is
@samp{in} or @samp{out}.
@end deffn

@deffn {BGP command} {neighbor @var{peer} prefix-list @var{name} [in|out]} {}
@end deffn

@deffn {BGP command} {neighbor @var{peer} filter-list @var{name} [in|out]} {}
@end deffn

@deffn {BGP Command} {neighbor @var{peer} route-map @var{name} [in|out]} {}
Apply a route-map on the neighbor.  @var{direct} must be @code{in} or
@code{out}.
@end deffn

@node BGP terminal mode commands, BGP Log Format, Peer filtering, bgpd
@comment  node-name,  next,  previous,  up
@section BGP terminal mode commands

@deffn {Command} {show ip bgp [@var{network}]} {}
Lists all BGPd routes.
@end deffn

@deffn {Command} {show ip bgp regexp @var{as-regexp}} {}
@end deffn

@deffn {Command} {show ip bgp summary} {}
@end deffn

@deffn {Command} {show ip bgp neighbor [@var{peer}]} {}
@end deffn

@deffn {Command} {clear ip bgp @var{peer}} {}
Clear peers which have addresses of X.X.X.X
@end deffn

@deffn {Command} {clear ip bgp @var{peer} soft in} {}
Clear peer using soft reconfiguration.
@end deffn

@deffn {Command} {show debug} {}
@end deffn

@deffn {Command} {debug event} {}
@end deffn

@deffn {Command} {debug update} {}
@end deffn

@deffn {Command} {debug keepalive} {}
@end deffn

@deffn {Command} {no debug event} {}
@end deffn

@deffn {Command} {no debug update} {}
@end deffn

@deffn {Command} {no debug keepalive} {}
@end deffn

@node BGP Log Format, Multiple Protocol Extension for BGP, BGP terminal mode commands, bgpd
@comment  node-name,  next,  previous,  up
@section BGP Log Format

BGPd outputs logging information to a terminal or to the specified file.
It includes routing updates and peer status change information.  It also
includes date, time, packet type, the peer's IP address, and other
routing information.

@example
1999/03/29 17:42:18 Update:[202.216.226.1] 130.58.0.0/16 med: 0 lpref: 0 nexthop: 202.216.226.1 aspath: 4691 3561 5119 3576 3782 i
@end example

@node Multiple Protocol Extension for BGP, Route Reflector, BGP Log Format, bgpd
@comment  node-name,  next,  previous,  up
@section Multiprotocol Extension for BGP

  When adding IPv6 routing information exchange feature to BGP.  There
were some proposals.  @acronym{IETF} @acronym{IDR} working group finally
take a proposal called Multiprotocol Extension for BGP.  The
specification is described in RFC2283.  The protocol does not define new
protocols.  It defines new attributes to existing BGP.  When it is used
exchanging IPv6 routing information it is called BGP-4+.  When it is
used for exchanging multicast routing information it is called MBGP.

  @command{bgpd} supports Multiprotocol Extension for BGP.  So if remote peer
supports the protocol, @command{bgpd} can exchange IPv6 and/or multicast routing
information.

  Traditional BGP does not have the feature to detect remote peer's
capability whether it can handle other than IPv4 unicast routes.  This
is a big problem using Multiprotocol Extension for BGP to operational
network.  @cite{draft-ietf-idr-bgp4-cap-neg-04.txt} is proposing a
feature called Capability Negotiation.  @command{bgpd} use this Capability
Negotiation to detect remote peer's capabilities.  If the peer is only
configured as IPv4 unicast neighbor, @command{bgpd} does not send these Capability
Negotiation packets.

  By default, Zebra will bring up peering with minimal common capability
for the both sides.  For example, local router has unicast and multicast 
capabilitie and remote router has unicast capability.  In this case,
the local router will establish the connection with unicast only capability.
When there are no common capabilities, Zebra sends Unsupported Capability
error and then resets the connection.

  If you want to completely match capabilities with remote peer.  Please
use @command{strict-capability-match} command.
  
@deffn {BGP Command} {neighbor @var{peer} strict-capability-match} {}
@deffnx {BGP Command} {no neighbor @var{peer} strict-capability-match} {}
Strictly compares remote capabilities and local capabilities.  If capabilities
are different, send Unsupported Capability error then reset connection.
@end deffn

  You may want to disable sending Capability Negotiation OPEN message
optional parameter to the peer when remote peer does not implement
Capability Negotiation.  Please use @command{dont-capability-negotiate}
command to disable the feature.

@deffn {BGP Command} {neighbor @var{peer} dont-capability-negotiate} {}
@deffnx {BGP Command} {no neighbor @var{peer} dont-capability-negotiate} {}
Suppress sending Capability Negotiation as OPEN message optional
parameter to the peer.  This command only affects the peer is configured
other than IPv4 unicast configuration.
@end deffn

  When remote peer does not have capability negotiation feature, remote
peer will not send any capabilities at all.  In that case, bgp configures
the peer with configured capabilities.

  You may prefer locally configured capabilities more than the negotiated
capabilities even though remote peer sends capabilities.  If the peer is
configured by @command{override-capability}, @command{bgpd} ignores received
capabilities then override negotiated capabilities with configured values.

@deffn {BGP Command} {neighbor @var{peer} override-capability} {}
@deffnx {BGP Command} {no neighbor @var{peer} override-capability} {}
Override the result of Capability Negotiation with local configuration.
Ignore remote peer's capability value.
@end deffn

@node Route Reflector, Route Server, Multiple Protocol Extension for BGP, bgpd
@comment  node-name,  next,  previous,  up
@section Route Reflector

@deffn {BGP Command} {bgp cluster-id @var{a.b.c.d}} {}
@end deffn

@deffn {BGP Command} {neighbor @var{peer} route-reflector-client} {}
@deffnx {BGP Command} {no neighbor @var{peer} route-reflector-client} {}
@end deffn

@node Route Server, How to set up a 6-Bone connection, Route Reflector, bgpd
@comment  node-name,  next,  previous,  up
@section Route Server

At an Internet Exchange point, many ISPs are connected to each other by
external BGP peering.  Normally these external BGP connection are done by
@code{full mesh} method.  As with internal BGP full mesh formation,
this method has a scaling problem.

This scaling problem is well known.  Route Server is a method to resolve
the problem.  Each ISP's BGP router only peers to Route Server.  Route
Server serves as BGP information exchange to other BGP routers.  By
applying this method, numbers of BGP connections is reduced from
O(n*(n-1)/2) to O(n).

Unlike normal BGP router, Route Server must have several routing tables
for managing different routing policies for each BGP speaker.  We call the
routing tables as different @code{view}s.  @command{bgpd} can work as
normal BGP router or Route Server or both at the same time.

@menu
* Multiple instance::           
* BGP instance and view::       
* Routing policy::              
* Viewing the view::            
@end menu

@node Multiple instance, BGP instance and view, Route Server, Route Server
@comment  node-name,  next,  previous,  up
@subsection Multiple instance

To enable multiple view function of @code{bgpd}, you must turn on
multiple instance feature beforehand.

@deffn {Command} {bgp multiple-instance} {}
Enable BGP multiple instance feature.  After this feature is enabled,
you can make multiple BGP instances or multiple BGP views.
@end deffn

@deffn {Command} {no bgp multiple-instance} {}
Disable BGP multiple instance feature.  You can not disable this feature
when BGP multiple instances or views exist.
@end deffn

@node BGP instance and view, Routing policy, Multiple instance, Route Server
@comment  node-name,  next,  previous,  up
@subsection BGP instance and view

BGP instance is a normal BGP process.  The result of route selection
goes to the kernel routing table.  You can setup different AS at the
same time when BGP multiple instance feature is enabled.

@deffn {Command} {router bgp @var{as-number}} {}
Make a new BGP instance.  You can use arbitrary word for the @var{name}.
@end deffn

@example
@group
bgp multiple-instance
!
router bgp 1
 neighbor 10.0.0.1 remote-as 2
 neighbor 10.0.0.2 remote-as 3
!
router bgp 2
 neighbor 10.0.0.3 remote-as 4
 neighbor 10.0.0.4 remote-as 5
@end group
@end example

BGP view is almost same as normal BGP process. The result of
route selection does not go to the kernel routing table.  BGP view is
only for exchanging BGP routing information.

@deffn {Command} {router bgp @var{as-number} view @var{name}} {}
Make a new BGP view.  You can use arbitrary word for the @var{name}.  This
view's route selection result does not go to the kernel routing table.
@end deffn

With this command, you can setup Route Server like below.

@example
@group
bgp multiple-instance
!
router bgp 1 view 1
 neighbor 10.0.0.1 remote-as 2
 neighbor 10.0.0.2 remote-as 3
!
router bgp 2 view 2
 neighbor 10.0.0.3 remote-as 4
 neighbor 10.0.0.4 remote-as 5
@end group
@end example

@node Routing policy, Viewing the view, BGP instance and view, Route Server
@comment  node-name,  next,  previous,  up
@subsection Routing policy

You can set different routing policy for a peer.  For example, you can
set different filter for a peer.

@example
@group
bgp multiple-instance
!
router bgp 1 view 1
 neighbor 10.0.0.1 remote-as 2
 neighbor 10.0.0.1 distribute-list 1 in
!
router bgp 1 view 2
 neighbor 10.0.0.1 remote-as 2
 neighbor 10.0.0.1 distribute-list 2 in
@end group
@end example

This means BGP update from a peer 10.0.0.1 goes to both BGP view 1 and view
2.  When the update is inserted into view 1, distribute-list 1 is
applied.  On the other hand, when the update is inserted into view 2,
distribute-list 2 is applied.

@node Viewing the view,  , Routing policy, Route Server
@comment  node-name,  next,  previous,  up
@subsection Viewing the view

To display routing table of BGP view, you must specify view name.

@deffn {Command} {show ip bgp view @var{name}} {}
Display routing table of BGP view @var{name}.
@end deffn

@node How to set up a 6-Bone connection, Dump BGP packets and table, Route Server, bgpd
@comment  node-name,  next,  previous,  up
@section How to set up a 6-Bone connection

@example
@group
zebra configuration 
=================== 
!  
! Actually there is no need to configure zebra 
!

bgpd configuration
==================
!
! This means that routes go through zebra and into the kernel.
!
router zebra
!
! BGP-4+ configuration
!
router bgp 7675
 bgp router-id 10.0.0.1
!
ipv6 bgp network 3ffe:506::/32
ipv6 bgp neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 remote-as @var{as-number}
ipv6 bgp neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 route-map set-nexthop out
ipv6 bgp neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 remote-as @var{as-number}
ipv6 bgp neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 route-map set-nexthop out
!
ipv6 access-list all permit any
!
! Set output nexthop address.
!
route-map set-nexthop permit 10
 match ipv6 address all
 set ipv6 nexthop global 3ffe:1cfa:0:2:2c0:4fff:fe68:a225
 set ipv6 nexthop local fe80::2c0:4fff:fe68:a225
!
! logfile FILENAME is obsolete.  Please use log file FILENAME
!
log file bgpd.log
!
@end group
@end example

@node Dump BGP packets and table,  , How to set up a 6-Bone connection, bgpd
@comment  node-name,  next,  previous,  up
@section Dump BGP packets and table

@deffn Command {dump bgp all @var{path}} {}
@deffnx Command {dump bgp all @var{path} @var{interval}} {}
Dump all BGP packet and events to @var{path} file.
@end deffn 

@deffn Command {dump bgp updates @var{path}} {}
@deffnx Command {dump bgp updates @var{path} @var{interval}} {}
Dump BGP updates to @var{path} file.
@end deffn

@deffn Command {dump bgp routes @var{path}} {}
@deffnx Command {dump bgp routes @var{path}} {}
Dump whole BGP routing table to @var{path}.  This is heavy process.
@end deffn
