BGP
***

BGP stands for a Border Gateway Protocol.  The lastest BGP version is 4.  It is referred as BGP-4.  BGP-4 is one of the Exterior Gateway Protocols and de-fact standard of Inter Domain routing protocol. BGP-4 is described in RFC1771, A Border Gateway Protocol 4 (BGP-4).

Many extensions have been added to RFC1771.  RFC2858, Multiprotocol Extensions for BGP-4 provides multiprotocol support to BGP-4.

Starting BGP
============

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

bgpd specific invocation options are described below.  Common options may also be specified (see Common Invocation Options).

-p PORT
--bgp_port=PORT
     Set the bgp protocol's port number.

-r
--retain
     When program terminates, retain BGP routes added by zebra.

BGP router
==========

First of all you must configure BGP router with 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.

 -- Command: router bgp ASN
     Enable a BGP protocol process with the specified ASN.  After this statement you can input any BGP Commands.  You can not create different BGP process under different ASN without specifying multiple-instance (see Multiple instance).

 -- Command: no router bgp ASN
     Destroy a BGP protocol process with the specified ASN.

 -- BGP: bgp router-id A.B.C.D
     This command specifies the router-ID.  If bgpd connects to 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 router zebra is not enabled bgpd can't get interface information so router-id is set to 0.0.0.0.  So please set router-id by hand.

BGP distance
------------

 -- BGP: distance bgp <1-255> <1-255> <1-255>
     This command change distance value of BGP.  Each argument is distance value for external routes, internal routes and local routes.

 -- BGP: distance <1-255> A.B.C.D/M
 -- BGP: distance <1-255> A.B.C.D/M WORD
     This command set distance value to

BGP decision process
--------------------

1. Weight check

2. Local preference check.

3. Local route check.

4. AS path length check.

5. Origin check.

6. MED check.

 -- BGP: bgp bestpath as-path confed
     This command specifies that the length of confederation path sets and sequences should should be taken into account during the BGP best path decision process.

 -- BGP: bgp bestpath as-path multipath-relax
     This command specifies that BGP decision process should consider paths of equal AS_PATH length candidates for multipath computation. Without the knob, the entire AS_PATH must match for multipath computation.

BGP route flap dampening
------------------------

 -- BGP: bgp dampening <1-45> <1-20000> <1-20000> <1-255>
     This command enables BGP route-flap dampening and specifies dampening parameters.

     half-life
          Half-life time for the penalty

     reuse-threshold
          Value to start reusing a route

     suppress-threshold
          Value to start suppressing a route

     max-suppress
          Maximum duration to suppress a stable route

     The route-flap damping algorithm is compatible with RFC2439. The use of this command is not recommended nowadays, see RIPE-378.

BGP network
===========

BGP route
---------

 -- BGP: network A.B.C.D/M
     This command adds the announcement network.

          router bgp 1
           network 10.0.0.0/8

     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; bgpd doesn't care about IGP routes when announcing its routes.

 -- BGP: no network A.B.C.D/M

Route Aggregation
-----------------

 -- BGP: aggregate-address A.B.C.D/M
     This command specifies an aggregate address.

 -- BGP: aggregate-address A.B.C.D/M as-set
     This command specifies an aggregate address.  Resulting routes inlucde AS set.

 -- BGP: aggregate-address A.B.C.D/M summary-only
     This command specifies an aggregate address.  Aggreated routes will not be announce.

 -- BGP: no aggregate-address A.B.C.D/M

Redistribute to BGP
-------------------

 -- BGP: redistribute kernel
     Redistribute kernel route to BGP process.

 -- BGP: redistribute static
     Redistribute static route to BGP process.

 -- BGP: redistribute connected
     Redistribute connected route to BGP process.

 -- BGP: redistribute rip
     Redistribute RIP route to BGP process.

 -- BGP: redistribute ospf
     Redistribute OSPF route to BGP process.

BGP Peer
========

Defining Peer
-------------

 -- BGP: neighbor PEER remote-as ASN
     Creates a new neighbor whose remote-as is ASN.  PEER can be an IPv4 address or an IPv6 address.

          router bgp 1
           neighbor 10.0.0.1 remote-as 2

     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, bgpd will complain like this:

          can't find neighbor 10.0.0.1

BGP Peer commands
-----------------

In a router bgp clause there are neighbor specific configurations required.

 -- BGP: neighbor PEER shutdown
 -- BGP: no neighbor PEER shutdown
     Shutdown the peer.  We can delete the neighbor's configuration by no neighbor PEER remote-as 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.

 -- BGP: neighbor PEER ebgp-multihop
 -- BGP: no neighbor PEER ebgp-multihop

 -- BGP: neighbor PEER description ...
 -- BGP: no neighbor PEER description ...
     Set description of the peer.

 -- BGP: neighbor PEER version VERSION
     Set up the neighbor's BGP version.  VERSION can be 4, 4+ or 4-.  BGP version 4 is the default value used for BGP peering.  BGP version 4+ means that the neighbor supports Multiprotocol Extensions for BGP-4.  BGP version 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.

 -- BGP: neighbor PEER interface IFNAME
 -- BGP: no neighbor PEER interface IFNAME
     When you connect to a BGP peer over an IPv6 link-local address, you have to specify the IFNAME of the interface used for the connection. To specify IPv4 session addresses, see the neighbor PEER update-source command below.

     This command is deprecated and may be removed in a future release. Its use should be avoided.

 -- BGP: neighbor PEER next-hop-self [all]
 -- BGP: no neighbor PEER next-hop-self [all]
     This command specifies an announced route's nexthop as being equivalent to the address of the bgp router if it is learned via eBGP. If the optional keyword all is specified the modifiation is done also for routes learned via iBGP.

 -- BGP: neighbor PEER update-source <IFNAME|ADDRESS>
 -- BGP: no neighbor PEER update-source
     Specify the IPv4 source address to use for the BGP session to this neighbour, may be specified as either an IPv4 address directly or as an interface name (in which case the zebra daemon MUST be running in order for bgpd to be able to retrieve interface state).

          router bgp 64555
           neighbor foo update-source 192.168.0.1
           neighbor bar update-source lo0

 -- BGP: neighbor PEER default-originate
 -- BGP: no neighbor PEER default-originate
     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.

 -- BGP: neighbor PEER port PORT
 -- BGP: neighbor PEER port PORT

 -- BGP: neighbor PEER send-community
 -- BGP: neighbor PEER send-community

 -- BGP: neighbor PEER weight WEIGHT
 -- BGP: no neighbor PEER weight WEIGHT
     This command specifies a default WEIGHT value for the neighbor's routes.

 -- BGP: neighbor PEER maximum-prefix NUMBER
 -- BGP: no neighbor PEER maximum-prefix NUMBER

 -- BGP: neighbor PEER local-as AS-NUMBER
 -- BGP: neighbor PEER local-as AS-NUMBER no-prepend
 -- BGP: neighbor PEER local-as AS-NUMBER no-prepend replace-as
 -- BGP: no neighbor PEER local-as
     Specify an alternate AS for this BGP process when interacting with the specified peer.  With no modifiers, the specified local-as is prepended to the received AS_PATH when receiving routing updates from the peer, and prepended to the outgoing AS_PATH (after the process local AS) when transmitting local routes to the peer.

     If the no-prepend attribute is specified, then the supplied local-as is not prepended to the received AS_PATH.

     If the replace-as attribute is specified, then only the supplied local-as is prepended to the AS_PATH when transmitting local-route updates to this peer.

     Note that replace-as can only be specified if no-prepend is.

     This command is only allowed for eBGP peers.

 -- BGP: neighbor PEER ttl-security hops NUMBER
 -- BGP: no neighbor PEER ttl-security hops NUMBER
     This command enforces Generalized TTL Security Mechanism (GTSM), as specified in RFC 5082. With this command, only neighbors that are the specified number of hops away will be allowed to become neighbors. This command is mututally exclusive with ebgp-multihop.

Peer filtering
--------------

 -- BGP: neighbor PEER distribute-list NAME [in|out]
     This command specifies a distribute-list for the peer.  DIRECT is in or out.

 -- BGP command: neighbor PEER prefix-list NAME [in|out]

 -- BGP command: neighbor PEER filter-list NAME [in|out]

 -- BGP: neighbor PEER route-map NAME [in|out]
     Apply a route-map on the neighbor.  DIRECT must be in or out.

BGP Peer Group
==============

 -- BGP: neighbor WORD peer-group
     This command defines a new peer group.

 -- BGP: neighbor PEER peer-group WORD
     This command bind specific peer to peer group WORD.

BGP Address Family
==================

Autonomous System
=================

The AS (Autonomous System) number is one of the essential element of BGP.  BGP is a distance vector routing protocol, and the AS-Path framework provides distance vector metric and loop detection to BGP. RFC1930, Guidelines for creation, selection, and registration of an Autonomous System (AS) provides some background on the concepts of an AS.

The AS number is a two octet value, ranging in value from 1 to 65535. The AS numbers 64512 through 65535 are defined as private AS numbers. Private AS numbers must not to be advertised in the global Internet.

AS Path Regular Expression
--------------------------

AS path regular expression can be used for displaying BGP routes and AS path access list.  AS path regular expression is based on POSIX 1003.2 regular expressions.  Following description is just a subset of POSIX regular expression.  User can use full POSIX regular expression.  Adding to that special character '_' is added for AS path regular expression.

.
     Matches any single character.

*
     Matches 0 or more occurrences of pattern.

+
     Matches 1 or more occurrences of pattern.

?
     Match 0 or 1 occurrences of pattern.

^
     Matches the beginning of the line.

$
     Matches the end of the line.

_
     Character _ has special meanings in AS path regular expression. It matches to space and comma , and AS set delimiter { and } and AS confederation delimiter ( and ).  And it also matches to the beginning of the line and the end of the line.  So _ can be used for AS value boundaries match.  show ip bgp regexp _7675_ matches to all of BGP routes which as AS number include 7675.

Display BGP Routes by AS Path
-----------------------------

To show BGP routes which has specific AS path information show ip bgp command can be used.

 -- Command: show ip bgp regexp LINE
     This commands display BGP routes that matches AS path regular expression LINE.

AS Path Access List
-------------------

AS path access list is user defined AS path.

 -- Command: ip as-path access-list WORD {permit|deny} LINE
     This command defines a new AS path access list.

 -- Command: no ip as-path access-list WORD
 -- Command: no ip as-path access-list WORD {permit|deny} LINE

Using AS Path in Route Map
--------------------------

 -- Route Map: match as-path WORD

 -- Route Map: set as-path prepend AS-PATH
     Prepend the given string of AS numbers to the AS_PATH.

 -- Route Map: set as-path prepend last-as NUM
     Prepend the existing last AS number (the leftmost ASN) to the AS_PATH.

Private AS Numbers
------------------

BGP Communities Attribute
=========================

BGP communities attribute is widely used for implementing policy routing.  Network operators can manipulate BGP communities attribute based on their network policy.  BGP communities attribute is defined in RFC1997, BGP Communities Attribute and RFC1998, An Application of the BGP Community Attribute in Multi-home Routing.  It is an optional transitive attribute, therefore local policy can travel through different autonomous system.

Communities attribute is a set of communities values.  Each communities value is 4 octet long.  The following format is used to define communities value.

AS:VAL
     This format represents 4 octet communities value.  AS is high order 2 octet in digit format.  VAL is low order 2 octet in digit format.  This format is useful to define AS oriented policy value.  For example, 7675:80 can be used when AS 7675 wants to pass local policy value 80 to neighboring peer.

internet
     internet represents well-known communities value 0.

no-export
     no-export represents well-known communities value NO_EXPORT

     (0xFFFFFF01).  All routes carry this value must not be advertised to outside a BGP confederation boundary.  If neighboring BGP peer is part of BGP confederation, the peer is considered as inside a BGP confederation boundary, so the route will be announced to the peer.

no-advertise
     no-advertise represents well-known communities value NO_ADVERTISE
     (0xFFFFFF02).  All routes carry this value must not be advertise to other BGP peers.

local-AS
     local-AS represents well-known communities value NO_EXPORT_SUBCONFED (0xFFFFFF03).  All routes carry this value must not be advertised to external BGP peers.  Even if the neighboring router is part of confederation, it is considered as external BGP peer, so the route will not be announced to the peer.

When BGP communities attribute is received, duplicated communities value in the communities attribute is ignored and each communities values are sorted in numerical order.

BGP Community Lists
-------------------

BGP community list is a user defined BGP communites attribute list. BGP community list can be used for matching or manipulating BGP communities attribute in updates.

There are two types of community list.  One is standard community list and another is expanded community list.  Standard community list defines communities attribute.  Expanded community list defines communities attribute string with regular expression.  Standard community list is compiled into binary format when user define it. Standard community list will be directly compared to BGP communities attribute in BGP updates.  Therefore the comparison is faster than expanded community list.

 -- Command: ip community-list standard NAME {permit|deny} COMMUNITY
     This command defines a new standard community list.  COMMUNITY is communities value.  The COMMUNITY is compiled into community structure.  We can define multiple community list under same name.  In that case match will happen user defined order.  Once the community list matches to communities attribute in BGP updates it return permit or deny by the community list definition.  When there is no matched entry, deny will be returned.  When COMMUNITY is empty it matches to any routes.

 -- Command: ip community-list expanded NAME {permit|deny} LINE
     This command defines a new expanded community list.  LINE is a string expression of communities attribute.  LINE can include regular expression to match communities attribute in BGP updates.

 -- Command: no ip community-list NAME
 -- Command: no ip community-list standard NAME
 -- Command: no ip community-list expanded NAME
     These commands delete community lists specified by NAME.  All of community lists shares a single name space.  So community lists can be removed simpley specifying community lists name.

 -- Command: show ip community-list
 -- Command: show ip community-list NAME
     This command display current community list information.  When NAME is specified the specified community list's information is shown.

          # show ip community-list
          Named Community standard list CLIST
              permit 7675:80 7675:100 no-export
              deny internet
          Named Community expanded list EXPAND
              permit :

          # show ip community-list CLIST
          Named Community standard list CLIST
              permit 7675:80 7675:100 no-export
              deny internet

Numbered BGP Community Lists
----------------------------

When number is used for BGP community list name, the number has special meanings.  Community list number in the range from 1 and 99 is standard community list.  Community list number in the range from 100 to 199 is expanded community list.  These community lists are called as numbered community lists.  On the other hand normal community lists is called as named community lists.

 -- Command: ip community-list <1-99> {permit|deny} COMMUNITY
     This command defines a new community list.  <1-99> is standard community list number.  Community list name within this range defines standard community list.  When COMMUNITY is empty it matches to any routes.

 -- Command: ip community-list <100-199> {permit|deny} COMMUNITY
     This command defines a new community list.  <100-199> is expanded community list number.  Community list name within this range defines expanded community list.

 -- Command: ip community-list NAME {permit|deny} COMMUNITY
     When community list type is not specifed, the community list type is automatically detected.  If COMMUNITY can be compiled into communities attribute, the community list is defined as a standard community list.  Otherwise it is defined as an expanded community list.  This feature is left for backward compability.  Use of this feature is not recommended.

BGP Community in Route Map
--------------------------

In Route Map (see Route Map), we can match or set BGP communities attribute.  Using this feature network operator can implement their network policy based on BGP communities attribute.

Following commands can be used in Route Map.

 -- Route Map: match community WORD
 -- Route Map: match community WORD exact-match
     This command perform match to BGP updates using community list WORD.  When the one of BGP communities value match to the one of communities value in community list, it is match.  When exact-match keyword is spcified, match happen only when BGP updates have completely same communities value specified in the community list.

 -- Route Map: set community none
 -- Route Map: set community COMMUNITY
 -- Route Map: set community COMMUNITY additive
     This command manipulate communities value in BGP updates.  When none is specified as communities value, it removes entire communities attribute from BGP updates.  When COMMUNITY is not none, specified communities value is set to BGP updates.  If BGP updates already has BGP communities value, the existing BGP communities value is replaced with specified COMMUNITY value. When additive keyword is specified, COMMUNITY is appended to the existing communities value.

 -- Route Map: set comm-list WORD delete
     This command remove communities value from BGP communities attribute. The WORD is community list name.  When BGP route's communities value matches to the community list WORD, the communities value is removed.  When all of communities value is removed eventually, the BGP update's communities attribute is completely removed.

Display BGP Routes by Community
-------------------------------

To show BGP routes which has specific BGP communities attribute, show ip bgp command can be used.  The COMMUNITY value and community list can be used for show ip bgp command.

 -- Command: show ip bgp community
 -- Command: show ip bgp community COMMUNITY
 -- Command: show ip bgp community COMMUNITY exact-match
     show ip bgp community displays BGP routes which has communities attribute.  When COMMUNITY is specified, BGP routes that matches COMMUNITY value is displayed.  For this command, internet keyword can't be used for COMMUNITY value.  When exact-match is specified, it display only routes that have an exact match.

 -- Command: show ip bgp community-list WORD
 -- Command: show ip bgp community-list WORD exact-match
     This commands display BGP routes that matches community list WORD.  When exact-match is specified, display only routes that have an exact match.

Using BGP Communities Attribute
-------------------------------

Following configuration is the most typical usage of BGP communities attribute.  AS 7675 provides upstream Internet connection to AS 100. When following configuration exists in AS 7675, AS 100 networks operator can set local preference in AS 7675 network by setting BGP communities attribute to the updates.

     router bgp 7675
      neighbor 192.168.0.1 remote-as 100
      neighbor 192.168.0.1 route-map RMAP in
     !
     ip community-list 70 permit 7675:70
     ip community-list 70 deny
     ip community-list 80 permit 7675:80
     ip community-list 80 deny
     ip community-list 90 permit 7675:90
     ip community-list 90 deny
     !
     route-map RMAP permit 10
      match community 70
      set local-preference 70
     !
     route-map RMAP permit 20
      match community 80
      set local-preference 80
     !
     route-map RMAP permit 30
      match community 90
      set local-preference 90

Following configuration announce 10.0.0.0/8 from AS 100 to AS 7675. The route has communities value 7675:80 so when above configuration exists in AS 7675, announced route's local preference will be set to value 80.

     router bgp 100
      network 10.0.0.0/8
      neighbor 192.168.0.2 remote-as 7675
      neighbor 192.168.0.2 route-map RMAP out
     !
     ip prefix-list PLIST permit 10.0.0.0/8
     !
     route-map RMAP permit 10
      match ip address prefix-list PLIST
      set community 7675:80

Following configuration is an example of BGP route filtering using communities attribute.  This configuration only permit BGP routes which has BGP communities value 0:80 or 0:90.  Network operator can put special internal communities value at BGP border router, then limit the BGP routes announcement into the internal network.

     router bgp 7675
      neighbor 192.168.0.1 remote-as 100
      neighbor 192.168.0.1 route-map RMAP in
     !
     ip community-list 1 permit 0:80 0:90
     !
     route-map RMAP permit in
      match community 1

Following exmaple filter BGP routes which has communities value 1:1. When there is no match community-list returns deny.  To avoid filtering all of routes, we need to define permit any at last.

     router bgp 7675
      neighbor 192.168.0.1 remote-as 100
      neighbor 192.168.0.1 route-map RMAP in
     !
     ip community-list standard FILTER deny 1:1
     ip community-list standard FILTER permit
     !
     route-map RMAP permit 10
      match community FILTER

Communities value keyword internet has special meanings in standard community lists.  In below example internet act as match any.  It matches all of BGP routes even if the route does not have communities attribute at all.  So community list INTERNET is same as above example's FILTER.

     ip community-list standard INTERNET deny 1:1
     ip community-list standard INTERNET permit internet

Following configuration is an example of communities value deletion. With this configuration communities value 100:1 and 100:2 is removed from BGP updates.  For communities value deletion, only permit community-list is used.  deny community-list is ignored.

     router bgp 7675
      neighbor 192.168.0.1 remote-as 100
      neighbor 192.168.0.1 route-map RMAP in
     !
     ip community-list standard DEL permit 100:1 100:2
     !
     route-map RMAP permit 10
      set comm-list DEL delete

BGP Extended Communities Attribute
==================================

BGP extended communities attribute is introduced with MPLS VPN/BGP technology.  MPLS VPN/BGP expands capability of network infrastructure to provide VPN functionality.  At the same time it requires a new framework for policy routing.  With BGP Extended Communities Attribute we can use Route Target or Site of Origin for implementing network policy for MPLS VPN/BGP.

BGP Extended Communities Attribute is similar to BGP Communities Attribute.  It is an optional transitive attribute.  BGP Extended Communities Attribute can carry multiple Extended Community value. Each Extended Community value is eight octet length.

BGP Extended Communities Attribute provides an extended range compared with BGP Communities Attribute.  Adding to that there is a type field in each value to provides community space structure.

There are two format to define Extended Community value.  One is AS based format the other is IP address based format.

AS:VAL
     This is a format to define AS based Extended Community value. AS part is 2 octets Global Administrator subfield in Extended Community value.  VAL part is 4 octets Local Administrator subfield.  7675:100 represents AS 7675 policy value 100.

IP-Address:VAL
     This is a format to define IP address based Extended Community value. IP-Address part is 4 octets Global Administrator subfield. VAL part is 2 octets Local Administrator subfield. 10.0.0.1:100 represents

BGP Extended Community Lists
----------------------------

Expanded Community Lists is a user defined BGP Expanded Community Lists.

 -- Command: ip extcommunity-list standard NAME {permit|deny} EXTCOMMUNITY
     This command defines a new standard extcommunity-list. EXTCOMMUNITY is extended communities value.  The EXTCOMMUNITY is compiled into extended community structure.  We can define multiple extcommunity-list under same name.  In that case match will happen user defined order.  Once the extcommunity-list matches to extended communities attribute in BGP updates it return permit or deny based upon the extcommunity-list definition.  When there is no matched entry, deny will be returned.  When EXTCOMMUNITY is empty it matches to any routes.

 -- Command: ip extcommunity-list expanded NAME {permit|deny} LINE
     This command defines a new expanded extcommunity-list.  LINE is a string expression of extended communities attribute.  LINE can include regular expression to match extended communities attribute in BGP updates.

 -- Command: no ip extcommunity-list NAME
 -- Command: no ip extcommunity-list standard NAME
 -- Command: no ip extcommunity-list expanded NAME
     These commands delete extended community lists specified by NAME.  All of extended community lists shares a single name space.  So extended community lists can be removed simpley specifying the name.

 -- Command: show ip extcommunity-list
 -- Command: show ip extcommunity-list NAME
     This command display current extcommunity-list information.  When NAME is specified the community list's information is shown.

          # show ip extcommunity-list

BGP Extended Communities in Route Map
-------------------------------------

 -- Route Map: match extcommunity WORD

 -- Route Map: set extcommunity rt EXTCOMMUNITY
     This command set Route Target value.

 -- Route Map: set extcommunity soo EXTCOMMUNITY
     This command set Site of Origin value.

Displaying BGP Routes
=====================

Show IP BGP
-----------

 -- Command: show ip bgp
 -- Command: show ip bgp A.B.C.D
 -- Command: show ip bgp X:X::X:X
     This command displays BGP routes.  When no route is specified it display all of IPv4 BGP routes.

     BGP table version is 0, local router ID is 10.1.1.1
     Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
     Origin codes: i - IGP, e - EGP, ? - incomplete

        Network          Next Hop            Metric LocPrf Weight Path
     *> 1.1.1.1/32       0.0.0.0                  0         32768 i

     Total number of prefixes 1

More Show IP BGP
----------------

 -- Command: show ip bgp regexp LINE
     This command display BGP routes using AS path regular expression (see Display BGP Routes by AS Path).

 -- Command: show ip bgp community COMMUNITY
 -- Command: show ip bgp community COMMUNITY exact-match
     This command display BGP routes using COMMUNITY (see Display BGP Routes by Community).

 -- Command: show ip bgp community-list WORD
 -- Command: show ip bgp community-list WORD exact-match
     This command display BGP routes using community list (see Display BGP Routes by Community).

 -- Command: show ip bgp summary

 -- Command: show ip bgp neighbor [PEER]

 -- Command: clear ip bgp PEER
     Clear peers which have addresses of X.X.X.X

 -- Command: clear ip bgp PEER soft in
     Clear peer using soft reconfiguration.

 -- Command: show ip bgp dampened-paths
     Display paths suppressed due to dampening

 -- Command: show ip bgp flap-statistics
     Display flap statistics of routes

 -- Command: show debug

 -- Command: debug event

 -- Command: debug update

 -- Command: debug keepalive

 -- Command: no debug event

 -- Command: no debug update

 -- Command: no debug keepalive

Capability Negotiation
======================

When adding IPv6 routing information exchange feature to BGP.  There were some proposals.  IETF (Internet Engineering Task Force) IDR (Inter Domain Routing) WG (Working group) adopted 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.

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

Traditional BGP did not have the feature to detect remote peer's capabilities, e.g. whether it can handle prefix types other than IPv4 unicast routes.  This was a big problem using Multiprotocol Extension for BGP to operational network.  RFC2842, Capabilities Advertisement with BGP-4 adopted a feature called Capability Negotiation. bgpd use this Capability Negotiation to detect the remote peer's capabilities.  If the peer is only configured as IPv4 unicast neighbor, bgpd does not send these Capability Negotiation packets (at least not unless other optional BGP features require capability negotation).

By default, Quagga 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, Quagga sends Unsupported Capability error and then resets the connection.

If you want to completely match capabilities with remote peer.  Please use strict-capability-match command.

 -- BGP: neighbor PEER strict-capability-match
 -- BGP: no neighbor PEER strict-capability-match
     Strictly compares remote capabilities and local capabilities.  If capabilities are different, send Unsupported Capability error then reset connection.

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 dont-capability-negotiate command to disable the feature.

 -- BGP: neighbor PEER dont-capability-negotiate
 -- BGP: no neighbor 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.

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 override-capability, bgpd ignores received capabilities then override negotiated capabilities with configured values.

 -- BGP: neighbor PEER override-capability
 -- BGP: no neighbor PEER override-capability
     Override the result of Capability Negotiation with local configuration. Ignore remote peer's capability value.

Route Reflector
===============

 -- BGP: bgp cluster-id A.B.C.D

 -- BGP: neighbor PEER route-reflector-client
 -- BGP: no neighbor PEER route-reflector-client

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 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 views.  bgpd can work as normal BGP router or Route Server or both at the same time.

Multiple instance
-----------------

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

 -- Command: bgp multiple-instance
     Enable BGP multiple instance feature.  After this feature is enabled, you can make multiple BGP instances or multiple BGP views.

 -- Command: no bgp multiple-instance
     Disable BGP multiple instance feature.  You can not disable this feature when BGP multiple instances or views exist.

When you want to make configuration more Cisco like one,

 -- Command: bgp config-type cisco
     Cisco compatible BGP configuration output.

When bgp config-type cisco is specified,

``no synchronization'' is displayed. ``no auto-summary'' is displayed.

``network'' and ``aggregate-address'' argument is displayed as ``A.B.C.D M.M.M.M''

Quagga: network 10.0.0.0/8 Cisco: network 10.0.0.0

Quagga: aggregate-address 192.168.0.0/24 Cisco: aggregate-address 192.168.0.0 255.255.255.0

Community attribute handling is also different.  If there is no configuration is specified community attribute and extended community attribute are sent to neighbor.  When user manually disable the feature community attribute is not sent to the neighbor.  In case of bgp config-type cisco is specified, community attribute is not sent to the neighbor by default.  To send community attribute user has to specify neighbor A.B.C.D send-community command.

     !
     router bgp 1
      neighbor 10.0.0.1 remote-as 1
      no neighbor 10.0.0.1 send-community
     !
     router bgp 1
      neighbor 10.0.0.1 remote-as 1
      neighbor 10.0.0.1 send-community
     !

 -- Command: bgp config-type zebra
     Quagga style BGP configuration.  This is default.

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.

 -- Command: router bgp AS-NUMBER
     Make a new BGP instance.  You can use arbitrary word for the NAME.

     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

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.

 -- Command: router bgp AS-NUMBER view NAME
     Make a new BGP view.  You can use arbitrary word for the NAME.  This view's route selection result does not go to the kernel routing table.

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

     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

Routing policy
--------------

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

     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

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.

Viewing the view
----------------

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

 -- Command: show ip bgp view NAME
     Display routing table of BGP view NAME.

How to set up a 6-Bone connection
=================================

     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
     !
     ! MP-BGP configuration
     !
     router bgp 7675
      bgp router-id 10.0.0.1
      neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 remote-as AS-NUMBER
     !
      address-family ipv6
      network 3ffe:506::/32
      neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 activate
      neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 route-map set-nexthop out
      neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 remote-as AS-NUMBER
      neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 route-map set-nexthop out
      exit-address-family
     !
     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
     !

Dump BGP packets and table
==========================

 -- Command: dump bgp all PATH
 -- Command: dump bgp all PATH INTERVAL
     Dump all BGP packet and events to PATH file.

 -- Command: dump bgp updates PATH
 -- Command: dump bgp updates PATH INTERVAL
     Dump BGP updates to PATH file.

 -- Command: dump bgp routes PATH
 -- Command: dump bgp routes PATH
     Dump whole BGP routing table to PATH.  This is heavy process.

BGP Configuration Examples
==========================

Example of a session to an upstream, advertising only one prefix to it.

     router bgp 64512
      bgp router-id 10.236.87.1
      network 10.236.87.0/24
      neighbor upstream peer-group
      neighbor upstream remote-as 64515
      neighbor upstream capability dynamic
      neighbor upstream prefix-list pl-allowed-adv out
      neighbor 10.1.1.1 peer-group upstream
      neighbor 10.1.1.1 description ACME ISP
     !
     ip prefix-list pl-allowed-adv seq 5 permit 82.195.133.0/25
     ip prefix-list pl-allowed-adv seq 10 deny any

A more complex example. With upstream, peer and customer sessions. Advertising global prefixes and NO_EXPORT prefixes and providing actions for customer routes based on community values. Extensive use of route-maps and the 'call' feature to support selective advertising of prefixes. This example is intended as guidance only, it has NOT been tested and almost certainly containts silly mistakes, if not serious flaws.

     router bgp 64512
      bgp router-id 10.236.87.1
      network 10.123.456.0/24
      network 10.123.456.128/25 route-map rm-no-export
      neighbor upstream capability dynamic
      neighbor upstream route-map rm-upstream-out out
      neighbor cust capability dynamic
      neighbor cust route-map rm-cust-in in
      neighbor cust route-map rm-cust-out out
      neighbor cust send-community both
      neighbor peer capability dynamic
      neighbor peer route-map rm-peer-in in
      neighbor peer route-map rm-peer-out out
      neighbor peer send-community both
      neighbor 10.1.1.1 remote-as 64515
      neighbor 10.1.1.1 peer-group upstream
      neighbor 10.2.1.1 remote-as 64516
      neighbor 10.2.1.1 peer-group upstream
      neighbor 10.3.1.1 remote-as 64517
      neighbor 10.3.1.1 peer-group cust-default
      neighbor 10.3.1.1 description customer1
      neighbor 10.3.1.1 prefix-list pl-cust1-network in
      neighbor 10.4.1.1 remote-as 64518
      neighbor 10.4.1.1 peer-group cust
      neighbor 10.4.1.1 prefix-list pl-cust2-network in
      neighbor 10.4.1.1 description customer2
      neighbor 10.5.1.1 remote-as 64519
      neighbor 10.5.1.1 peer-group peer
      neighbor 10.5.1.1 prefix-list pl-peer1-network in
      neighbor 10.5.1.1 description peer AS 1
      neighbor 10.6.1.1 remote-as 64520
      neighbor 10.6.1.1 peer-group peer
      neighbor 10.6.1.1 prefix-list pl-peer2-network in
      neighbor 10.6.1.1 description peer AS 2
     !
     ip prefix-list pl-default permit 0.0.0.0/0
     !
     ip prefix-list pl-upstream-peers permit 10.1.1.1/32
     ip prefix-list pl-upstream-peers permit 10.2.1.1/32
     !
     ip prefix-list pl-cust1-network permit 10.3.1.0/24
     ip prefix-list pl-cust1-network permit 10.3.2.0/24
     !
     ip prefix-list pl-cust2-network permit 10.4.1.0/24
     !
     ip prefix-list pl-peer1-network permit 10.5.1.0/24
     ip prefix-list pl-peer1-network permit 10.5.2.0/24
     ip prefix-list pl-peer1-network permit 192.168.0.0/24
     !
     ip prefix-list pl-peer2-network permit 10.6.1.0/24
     ip prefix-list pl-peer2-network permit 10.6.2.0/24
     ip prefix-list pl-peer2-network permit 192.168.1.0/24
     ip prefix-list pl-peer2-network permit 192.168.2.0/24
     ip prefix-list pl-peer2-network permit 172.16.1/24
     !
     ip as-path access-list asp-own-as permit ^$
     ip as-path access-list asp-own-as permit _64512_
     !
     ! #################################################################
     ! Match communities we provide actions for, on routes receives from
     ! customers. Communities values of <our-ASN>:X, with X, have actions:
     !
     ! 100 - blackhole the prefix
     ! 200 - set no_export
     ! 300 - advertise only to other customers
     ! 400 - advertise only to upstreams
     ! 500 - set no_export when advertising to upstreams
     ! 2X00 - set local_preference to X00
     !
     ! blackhole the prefix of the route
     ip community-list standard cm-blackhole permit 64512:100
     !
     ! set no-export community before advertising
     ip community-list standard cm-set-no-export permit 64512:200
     !
     ! advertise only to other customers
     ip community-list standard cm-cust-only permit 64512:300
     !
     ! advertise only to upstreams
     ip community-list standard cm-upstream-only permit 64512:400
     !
     ! advertise to upstreams with no-export
     ip community-list standard cm-upstream-noexport permit 64512:500
     !
     ! set local-pref to least significant 3 digits of the community
     ip community-list standard cm-prefmod-100 permit 64512:2100
     ip community-list standard cm-prefmod-200 permit 64512:2200
     ip community-list standard cm-prefmod-300 permit 64512:2300
     ip community-list standard cm-prefmod-400 permit 64512:2400
     ip community-list expanded cme-prefmod-range permit 64512:2...
     !
     ! Informational communities
     !
     ! 3000 - learned from upstream
     ! 3100 - learned from customer
     ! 3200 - learned from peer
     !
     ip community-list standard cm-learnt-upstream permit 64512:3000
     ip community-list standard cm-learnt-cust permit 64512:3100
     ip community-list standard cm-learnt-peer permit 64512:3200
     !
     ! ###################################################################
     ! Utility route-maps
     !
     ! These utility route-maps generally should not used to permit/deny
     ! routes, i.e. they do not have meaning as filters, and hence probably
     ! should be used with 'on-match next'. These all finish with an empty
     ! permit entry so as not interfere with processing in the caller.
     !
     route-map rm-no-export permit 10
      set community additive no-export
     route-map rm-no-export permit 20
     !
     route-map rm-blackhole permit 10
      description blackhole, up-pref and ensure it cant escape this AS
      set ip next-hop 127.0.0.1
      set local-preference 10
      set community additive no-export
     route-map rm-blackhole permit 20
     !
     ! Set local-pref as requested
     route-map rm-prefmod permit 10
      match community cm-prefmod-100
      set local-preference 100
     route-map rm-prefmod permit 20
      match community cm-prefmod-200
      set local-preference 200
     route-map rm-prefmod permit 30
      match community cm-prefmod-300
      set local-preference 300
     route-map rm-prefmod permit 40
      match community cm-prefmod-400
      set local-preference 400
     route-map rm-prefmod permit 50
     !
     ! Community actions to take on receipt of route.
     route-map rm-community-in permit 10
      description check for blackholing, no point continuing if it matches.
      match community cm-blackhole
      call rm-blackhole
     route-map rm-community-in permit 20
      match community cm-set-no-export
      call rm-no-export
      on-match next
     route-map rm-community-in permit 30
      match community cme-prefmod-range
      call rm-prefmod
     route-map rm-community-in permit 40
     !
     ! #####################################################################
     ! Community actions to take when advertising a route.
     ! These are filtering route-maps,
     !
     ! Deny customer routes to upstream with cust-only set.
     route-map rm-community-filt-to-upstream deny 10
      match community cm-learnt-cust
      match community cm-cust-only
     route-map rm-community-filt-to-upstream permit 20
     !
     ! Deny customer routes to other customers with upstream-only set.
     route-map rm-community-filt-to-cust deny 10
      match community cm-learnt-cust
      match community cm-upstream-only
     route-map rm-community-filt-to-cust permit 20
     !
     ! ###################################################################
     ! The top-level route-maps applied to sessions. Further entries could
     ! be added obviously..
     !
     ! Customers
     route-map rm-cust-in permit 10
      call rm-community-in
      on-match next
     route-map rm-cust-in permit 20
      set community additive 64512:3100
     route-map rm-cust-in permit 30
     !
     route-map rm-cust-out permit 10
      call rm-community-filt-to-cust
      on-match next
     route-map rm-cust-out permit 20
     !
     ! Upstream transit ASes
     route-map rm-upstream-out permit 10
      description filter customer prefixes which are marked cust-only
      call rm-community-filt-to-upstream
      on-match next
     route-map rm-upstream-out permit 20
      description only customer routes are provided to upstreams/peers
      match community cm-learnt-cust
     !
     ! Peer ASes
     ! outbound policy is same as for upstream
     route-map rm-peer-out permit 10
      call rm-upstream-out
     !
     route-map rm-peer-in permit 10
      set community additive 64512:3200