Configuring BGP
Before beginning to configure BGP, gather the network requirements you need, which should include the following:
- Whether you need to run IBGP for internal connectivity
- External connectivity to the ISP
- Configuration parameters such as neighbor IP addresses and their AS number, and which networks you will advertise via BGP
Table 6-1 lists the basic BGP configuration commands and their functions.
Table 6-1. Basic BGP Configuration Commands
Command |
Description |
router bgp AS-number |
Starts the BGP routing process on the router. |
neighbor ip-address remote-as AS-number |
Sets up peering between BGP routers. IP address must match the source of routing updates. |
neighbor peer - group-name peer-group |
Creates a peer group to which you can then assign neighbors. |
neighbor ip-address peer-group peer-group-name |
Assigns a neighbor to a peer group. |
neighbor ip-address next-hop-self |
Configures a router to advertise its connected interface as the next hop for all routes to this neighbor. |
neighbor ip-address update-source interface-type number |
Configures a router to use the IP address of a specific interface as the source for its advertisements to this neighbor. |
no synchronization |
Turns off BGP synchronization. |
network prefix [ mask subnet-mask ] |
Initiates the advertisement of a network in BGP. |
BGP Network Command
In most IGPs, the network command starts the routing process on an interface. In BGP, the command tells the router to originate an advertisement for that network. The network does not have to be connected to the router; it just has to be in the routing table. In theory, it can even be a network in a different autonomous system (not usually recommended).
When advertising a network, BGP assumes you are using the default classful subnet mask. If you want to advertise a subnet, you must use the optional keyword mask and specify the subnet mask to use. Note that this is a subnet mask, not the inverse mask used by OSPF and EIGRP network statements. The routing table must contain an exact match (prefix and subnet mask) to the network listed in the network statement before BGP advertises the route.
BGP Peering
BGP assumes that external neighbors are directly connected and that they are peering with the IP address of the directly connected interface of their neighbor. If not, you must tell BGP to look more than one hop away for its neighbor, with the neighbor ip-address ebgp-multihop number-of-hops command. You might use this command if you are peering with loopback interface IP addresses, for instance. BGP assumes that internal neighbors might not be directly connected, so this command is not needed with IBGP. If you do peer with loopback IP addresses, you must change the source of the BGP packets to match the loopback address with the neighbor ip-address update-source interface command.
To take down the peering session with a neighbor but keep the neighbor configuration, use the neighbor ip-address shutdown command.
BGP Peering States
The command show ip bgp neighbors shows a list of peers and the status of their peering session. This status can include the following states:
- Idle: No peering; router is looking for neighbor. Idle (admin) means that the neighbor relationship has been administratively shut down.
- Connect: TCP handshake completed.
- OpenSent, or Active: An open message was sent to try to establish the peering.
- OpenConfirm: Router has received a reply to the open message.
- Established: Routers have a BGP peering session. This is the desired state.
You can troubleshoot session establishment with debug commands. Use debug ip bgp events or debug ip bgp ipv4 unicast (in IOS versions 12.4 and up) to see where the process fails. Some common failure causes include AS number misconfiguration, neighbor IP address misconfiguration, a neighbor with no neighbor statement for your router, and a neighbor with no route to the source address of your router's BGP messages.