This document describes how to configure and monitor the Border Gateway Protocol (BGP). It contains the following sections:
Border Group Protocol Overview
How BGP Works
Setting Up BGP
Sample Policy Definitions
BGP Commands
Border Group Protocol Overview
Note:
OpenROUTE Networks recommends that you run BGP with a minimum of 32M RAM.
Exhaustion of Class B address space
Routing table growth
Figure 1 BGP Connections Between Two Autonomous Systems

Figure 2 BGP Connections Among Three Autonomous Systems

Originate, Send and Receive Policies
Decisions on which reachability information to advertise (send) and which to accept (receive) are made on the basis of explicitly defined policy statements. OpenROUTE Networks BGP implementation supports three types of policy statements:
Originate Policies
Send Policies
Receive Policies
Determining the Best Path
BGP uses the following rules of preference to determine the best path to an autonomous system. BGP checks updates it receives against these items in the order shown below. As soon as a criteria shows that one path is superior to another path, BGP selects that path and does not check the rest of the items.
Number of AS Prepends, which lets you control the routing of traffic to your router.
Local Preference, which lets you control the routing of traffic from your router.
Forcing Origin Type, which lets you override the priority given to certain types of traffic that originates from a neighbor. (See item 4.)

For example, when you set up the BGP router in AS 20 in Figure 4, you add two BGP neighbors, one for AS 30 and one for AS 40. When you add a BGP neighbor, you can assign a number as the local preference. If you leave the local preference at the default of 100, BGP does not use local preference as a criteria for determining which route to use. (See Determining the Best Path.)
Figure 4 Local Preference

Local Preference is transparent to the BGP routers in AS 30 and AS 40, it affects only the BGP router in AS 20.BGP Config>add neighbor
Neighbor address [0.0.0.0]? 128.185.1.178
AS [0]? 40
Init timer [12]?
Connect timer [120]?
Hold timer [90]?
TCP segment size [1024]?Local preference (0-9999) [100]? 200
Number of AS prepends when sending (1-20) [1]?
Send Multi-Exit Descriminator (0=No, 1=Yes) [0]?
In some routing situations, you may want the path with the lowest Multi-Exit Discriminator (MED) attribute (criteria 5) to be the best path for a particular neighbor, instead of the path with the lowest origin type (criteria 4).
To force the software to use the lowest MED instead of the lowest origin type, you can artificially set the origin type in packets that BGP aends to the neighbor. To do this, use the change neighbor command and set the Force origin type parameter.
BGP Messages
BGP routers use four kinds of messages to communicate with their neighbors: OPEN, KEEP ALIVE, UPDATE, and NOTIFICATION.
Open messages are the first transmitted when a link to a BGP neighbor comes up and establishes a connection.
BGP routers use keep alive messages to inform one another that a particular connection is alive and working.
Update messages contain the interior routing table information. BGP speakers only send update messages when there is a change in their routing tables.
A BGP speaker sends notification messages whenever the speaker detects a condition that forces it to terminate an existing connection. These messages are advertised before the connection is terminated.
Enabling BGP requires you to specify the BGP router's unique AS Number. AS numbers are assigned by Stanford Research Institute Network Information Center.
BGP Neighbors are BGP routers with which a BGP speaker establishes a TCP connection. Once neighbors are defined, connections to them are established by default.
The policies you establish determine which routes are imported and exported by the BGP speaker.
You can set up policies for different purposes. See Sample Policy Definitions.
The AS number range is 1 to 65535.BGP Config>enable bgp
AS [0]? 167
TCP segment size [1024]?
Adding a BGP neighbor automatically enables it, causing the BGP speaker to send out a connection request to the neighbor.BGP Config>add neighbor
Neighbor address [0.0.0.0]? 192.0.190.178
AS [0]? 178
Init timer [12]? 30
Connect timer [120]?
Hold timer [90]? 30
TCP segment size [1024]? 512Local preference (0-9999) [100]?
Number of AS prepends when sending (1-20) [1]?
Send Multi-Exit Descriminator (0=No, 1=Yes) [0]?
If an AS is behaving as a transit AS, you must define the receive policies to select the routes from any BGP peer before the BGP software can export them to another BGP peer via send policy definitions.
Changing the Order of Policies
The order of policies is important because the router applies aggregates and policies in the order that you create them. If policies are the wrong order, BGP may fail to import or export reachability information in the manner that you intend.
You can change the order of aggregates and policies with the BGP move command.
Sample Policy Definitions
This section provides examples of some specific policies you can set up for a BGP speaker.
Use the BGP add command to define all policies.
Originate Policy Examples
Include All Routes for Advertisement
This example includes all routes in the BGP speaker's IGP routing table for advertisement. In this sense, you can view this command as the "default" originate policy statement for BGP.
Notice that the command specifies a range of addresses, rather than a single address.
BGP Config>add originate-policy inclusive
Network Prefix [0.0.0.0]?
Network Mask [0.0.0.0]?
Address Match (Exact/Range) [Range]? range
Tag [0]?
BGP Config>add originate-policy exclusive
Network Prefix [0.0.0.0]? 194.10.16.0
Network Mask [0.0.0.0]? 255.255.240.0
Address Match (Exact/Range) [Range]? range
Tag [0]?
IGP-metric specifies the metric value with which the accepted routes are imported into the speaker's IGP routing table. You are only prompted to enter a value for IGP-metric when setting up a policy for route inclusion.BGP Config>add receive-policy inclusive
Network Prefix [0.0.0.0]?
Network Mask [0.0.0.0]?
Address Match (Exact/Range) [Range]? range
Originating AS# [0]?
Adjacent AS# [0]?
IGP-metric [0]?
BGP Config>add receive-policy exclusive
Network Prefix [0.0.0.0]?
Network Mask [0.0.0.0]?
Address Match (Exact/Range) [Range]? range
Originating AS# [0]? 168
Adjacent AS# [0]? 165
BGP Config>add send exclusive
Network Prefix [0.0.0.0]? 143.116.0.0
Network Mask [0.0.0.0]? 255.255.0.0
Address Match (Exact/Range) [Range]? range
Tag [0]? 165
Adjacent AS# [0]? 168
BGP Config>add send policy inclusive
Network Prefix [0.0.0.0]?
Network Mask [0.0.0.0]?
Address Match (Exact/Range) [Range]? range
Tag [0]?
Adjacent AS# [0]?
BGP config> prompt.
[M] means the command is available at the BGP> prompt.
Add [C]
Adds BGP information to your configuration.
Syntax: add
add aggregate
Network Prefix [0.0.0.0]? 194.10.16.0
Network Mask [0.0.0.0]? 255.255.240.0
add neighbor
Neighbor address [0.0.0.0]? 192.0.251.165
AS [0]? 165
Init timer [12]?
Connect timer [120]?
Hold timer [90]?
TCP segment size [1024]?Local preference (0-9999) [100]?
Number of AS prepends when sending (1-20) [1]?
Send Multi-Exit Descriminator (0=No, 1=Yes) [0]? 1
Multi-Exit Descriminator, in hex [0xFFFFFFFF]?
no-receive
Use add no-receive to exclude updates from a particular AS.
Example: add no-receive
Enter AS: [0]? 178
The following example includes all routes in the BGP speaker's IGP routing table to be advertised.
Example:
add originate-policy exclusive
Network Prefix [0.0.0.0]?
Network Mask [0.0.0.0]?
Address Match (Exact/Range) [Range]? range
Tag [0]?
receive-policy (exclusive/inclusive)
Creates policies that determine what routes are imported to the BGP speaker's routing table.
Example: add receive-policy exclusive
Network Prefix [0.0.0.0]? 10.0.0.0
Network Mask [0.0.0.0]? 255.0.0.0
Address Match (Exact/Range) [Range]? range
Originating AS# [0]? 168
Adjacent AS# [0]? 165
send-policy (exclusive/inclusive)
Creates policies that determine which of the BGP speaker's learned routes are re-advertised. These routes can be internal or external to the BGP speaker's AS.
Example: add send exclusive
Network Prefix [0.0.0.0]? 180.220.0.0
Network Mask [0.0.0.0]? 255.255.0.0
Address Match (Exact/Range) [Range]? range
Tag [0]?
Adjacent AS# [0]? 25
Change [C]
Changes an BGP configuration item previously installed by the add command.
Syntax: change
Enter index of aggregate to be modified [1]? 1
Network Prefix [128.185.0.0]? 128.128.0.0
Network Mask [255.255.0.0]? 255.192.0.0
Neighbor address to be modified [0.0.0.0]? 192.0.251.165
AS [165]?
Init timer [12]?
Connect timer [60]?
Hold timer [12]? 0
TCP segment size [1024]?Local preference (0-9999) [100]?
Number of AS prepends when sending (1-20) [1]?
Send Multi-Exit Descriminator (0=No, 1=Yes) [0]?
Force origin type (0=NONE, 1=IGP, 2=EGP, 3=OTHER) [0]?
Force origin type, see Forcing Origin Type.
originate-policy
Changes an existing originate policy definition. See add originate-policy.
This example alters the BGP speaker's originate policy. Rather than excluding networks with prefix 194.10.16.0 from the IGP routing table, the policy now includes all routes.
Example:
change originate-policy
Enter index of originate-policy to be modified [1]?
Policy Type (Inclusive/Exclusive) [Exclusive]? inclusive
Network Prefix [194.10.16.0]? 0.0.0.0
Network Mask [255.255.240.0]? 0.0.0.0
Address Match (Exact/Range) [Range]?
Tag [0]?
This example adds a restriction to the BGP speaker's receive-policy. Rather than import route information from every BGP peer into its IGP routing table, it now prevents routes from AS 165 from being imported.
Example:
change receive-policy
Enter index of receive-policy to be modified [1]?
Policy Type (Inclusive/Exclusive) [Inclusive]? exclusive
Network Prefix [0.0.0.0]?
Network Mask [0.0.0.0]?
Address Match (Exact/Range) [Range]?
Originating AS# [0]?
Adjacent AS# [0]? 165
This example adds a restriction to the BGP speaker's send policy. The restriction ensures that all routes in the address range 194.10.16.0 to 194.10.31.255 are excluded when advertising to autonomous system 165.
Example:
change send-policy
Enter index of send-policy to be modified [1]?
Policy Type (Inclusive/Exclusive) [Inclusive]? exclusive
Network Prefix [0.0.0.0]? 194.10.16.0
Network Mask [0.0.0.0]? 255.255.240.0
Address Match (Exact/Range) [Range]?
Tag [0]?
Adjacent AS# [0]? 165
delete aggregate
Enter index of aggregate to be deleted [1]? 1
delete neighbor
Neighbor address to delete [0.0.0.0]? 192.0.251.165
delete no-receive
Enter AS: [0]? 168
delete originate-policy
Enter index of originate-policy to be deleted [1]? 2
delete receive-policy
Enter index of receive-policy to be deleted [1]?
delete send-policy
Enter index of send-policy to be deleted [1]? 4
destinations
Network Mask NextHop AAG AGRAS ORG AS-Path
128.185.0.0 FFFF0000 192.0.251.165 No 0 IGP
142.4.0.0 FFFF0000 192.0.190.178 No 0 IGP seq[178-80]
143.116.0.0 FFFF0000 128.185.252.168 No 0 IGP seq[178-701-72]
192.0.190.0 FFFFFF00 192.0.251.165 No 0 IGP
192.0.251.0 FFFFFF00 192.0.251.165 No 0 IGP
194.10.16.0 FFFFF000 192.0.251.167 No 167 IGP seq[167]
destinations 3.0.0.0
Network Mask NextHop AAG AGRAS ORG AS-Path
3.0.0.0 FF000000 204.6.103.1 No 0 INC seq[174-701-80]
Dest:3.0.0.0, Mask:FF000000, Age:190, Upd#:343959, LastSent:0021:50:37
Eligible paths: 1
PathID: 25011 - (Best Path)
ASpath: seq[174-701-80]
LocalPref: 100, Pathlen: 3, Origin: INC, MED: 0x0 (defaulted)
BGP Neighbor-id: 38.1.3.9
NextHop: 204.6.103.1, Neighbor: 204.6.103.1, IGPMetric: 0,
AtomicAggr: No
destinations net address net mask
Displays detailed information on the specified route or destination network. The command shows how a specific route was learned, the best path to a specific destination, the metric associated with the route, and other information.
This command is useful in cases where multiple network addresses have the same prefix and different masks. In such cases, specifying the network mask narrows the scope of the information presented.
Example: destinations 3.0.0.0 255.0.0.0
Dest:3.0.0.0, Mask:FF000000, Age:190, Upd#:343959, LastSent:0021:52:40
Eligible paths: 1
PathID: 25011 - (Best Path)
ASpath: seq[174-701-80]
LocalPref: 100, Pathlen: 3, Origin: INC, MED: 0x0 (defaulted)
BGP Neighbor-id: 38.1.5.9
NextHop: 204.6.123.1, Neighbor: 204.6.123.1, IGPMetric: 0,
AtomicAggr: No
destinations advertised-to
BGP neighbor address [0.0.0.0]? 192.0.251.165
Destinations advertised to BGP neighbor 192.0.251.165
Network Mask NextHop AAG AGRAS ORG AS-Path
194.10.16.0 FFFFF000 194.10.16.167 No 167 IGP
192.0.190.0 FFFFFF00 192.0.251.165 No 0 IGP seq [165]
142.4.0.0 FFFF0000 192.0.251.165 No 0 IGPseq [165-178]
143.116.0.0 FFFF0000 128.185.250.168 No 0 IGP seq [168]
destinations received-from
BGP neighbor address [0.0.0.0]? 128.185.250.167
Destinations obtained from BGP neighbor 128.185.250.167
Network Mask NextHop AAG AGRAS ORG AS-Path
194.10.16.0 FFFFF000 128.185.250.167 No 167 IGP seq[167]
192.0.190.0 FFFFFF00 128.185.250.167 No 0 IGP seq[167-165]
142.4.0.0 FFFF0000 128.185.250.167 No 0 IGP seq[167-165-178]
disable bgp
disable neighbor
Neighbor address [0.0.0.0]? 192.0.190.178
enable bgp
AS [0]? 165
TCP segment size [1024]?
Enable BGP load-sharing (0=No, 1=Yes) [0]?
enable neighbor
Neighbor address [0.0.0.0] 192.0.190.178
exit
list aggregate
Aggregation:
Index Prefix Mask
1 194.10.16.0 255.255.240.0
list all
BGP Protocol: Enabled AS: 6654
TCP-Segment Size: 1024 BGP load-sharing: Enabled
Configured Neighbors: AS
Neighbor Init Conn Hold TCPSEG Local Pre- MED MED
Address Ena AS Timer Timer Timer Size Pref pends St Value
204.6.10.1 Y 174 12 120 90 1024 100 1 ENA 00000200
128.185.20.64 Y 6654 12 120 90 1024 100 1 DIS FFFFFFFF
Receive-Policies:
Index Type Prefix Mask Match OrgAS AdjAS IGPmetric
1 INCL 0.0.0.0 0.0.0.0 Range 0 0 0
Send-Policies:
Index Type Prefix Mask Match Tag AdjAS
1 INCL 0.0.0.0 0.0.0.0 Range 0 0
Originate-Policies:
Index Type Prefix Mask Match Tag
1 INCL 128.185.0.0 255.255.0.0 Exact 0
2 EXCL 0.0.0.0 0.0.0.0 Range 0
No aggregation records in configuration.
No no-receive-AS records in configuration.
list bgp
BGP Protocol: Enabled AS: 1
TCP-Segment Size: 1024 BGP load-sharing: Disabled
Configured Neighbors: AS
Neighbor Init Conn Hold TCPSEG Local Pre- MED MED
Address Ena AS Timer Timer Timer Size Pref pends St Value
128.185.3.2 Y 3 12 120 90 1024 100 1 DIS FFFFFFFF
list no-receive
AS-PATH with following ASs will be discarded:
AS 178
AS 165
list originate-policy
Originate-Policies:
Index Type Prefix Mask Match Tag
1 EXCL 194.10.16.0 255.255.240.0 Range 0
2 INCL 0.0.0.0 0.0.0.0 Range 0
list receive-policy
Receive-Policies:
Index Type Prefix Mask Match OrgAS AdjAS IGPmetric
1 EXCL 0.0.0.0 0.0.0.0 Range 178 165
2 INCL 0.0.0.0 0.0.0.0 Range 0 0 0
list send-policy
Send-Policies:
Index Type Prefix Mask Match Tag AdjAS
1 EXCL 194.10.16.0 255.255.240.0 Range 0 165
2 INCL 0.0.0.0 0.0.0.0 Range 0 0
move aggregate
Enter index of aggregate to move [1]? 1
Move record AFTER record number [0]? 2
move originate-policy
Enter index of originate-policy to move [1]? 3
Move record AFTER record number [0]? 5
move receive-policy
Enter index of receive-policy to move [1]? 2
Move record AFTER record number [0]? 3
move send-policy
Enter index of send-policy to move [1]? 1
Move record AFTER record number [0]? 3
neighbors
IP-Address State DAY-HH:MM:SS BGP-ID AS Upd#
128.185.252.168 Established 000-00:48:52 128.185.142.168 168 16
192.0.190.178 Established 000-02:01:49 142.4.140.178 178 16
192.0.251.167 Established 000-02:01:45 194.10.16.167 167 16
Enter neighbor followed by an IP address to display detailed data on a particular BGP neighbor.
Example:
neighbor 192.0.251.167
Active Conn: Sprt:1026 Dprt:179 State: Established KeepAlive/Hold Time: 4/12
Passve Conn: None
TCP connection errors: 0 TCP state transitions: 0
BGP Messages: Sent Received Sent Received
Open: 1 1 Update: 11 11
Notification: 0 0 KeepAlive: 1828 1830
Total Messages: 1840 1842
Msg Header Errs: Sent Received Sent Received
Conn sync err: 0 0 Bad msg length: 0 0
Bad msg type: 0 0
Open Msg Errs: Sent Received Sent Received
Unsupp versions: 0 0 Unsupp auth code: 0 0
Bad peer AS ident:0 0 Auth failure: 0 0
Bad BGP ident: 0 0 Bad hold time: 0 0
Update Msg Errs: Sent Received Sent Received
Bad attr list: 0 0 AS routing loop: 0 0
Bad wlkn attr: 0 0 Bad NEXT_HOP atr: 0 0
Mssng wlkn attr: 0 0 Optional atr err: 0 0
Attr flags err: 0 0 Bad netwrk field: 0 0
Attr length err: 0 0 Bad AS_PATH attr: 0 0
Bad ORIGIN attr: 0 0
Total Errors: Sent Received Sent Received
Msg Header Errs: 0 0 Hold Timer Exprd: 0 0
Open Msg Errs: 0 0 FSM Errs: 0 0
Update Msg Errs: 0 0 Cease: 0 0
paths
PathId NextHop AAG AGRAS RefCnt ORG AS-Path
0 10.2.0.3 No 0 2 IGP
4 192.2.0.2 No 0 2 IGP seq[2]
5 192.2.0.2 No 2 1 IGP seq[2]
6 192.2.0.2 No 0 1 IGP seq[2-1]
7 10.2.0.168 No 0 4 IGP
8 192.3.0.1 No 0 2 IGP seq[1]
9 192.2.0.2 No 2 1 IGP seq[2]
10 10.2.0.3 No 0 1 IGP
Sizes [M]
Displays the number of entries stored in the various databases.
Syntax: sizes
sizes
# Paths: 48531
# Path descriptors: 5579
Update sequence#: 636643
# Routing tbl entries (allocated): 50430
# Current tbl entries (not imported): 0
# Current tbl entries (imported to IGP): 48529