
Experimental principle
BGP is based on TCP, which is a well-known situation, and TCP is a host-to-host connection, that is, a point-to-point connection based on host to host. To complete this step, naturally there must be mutual routing between the two TCP points to establish a TCP connection.
BGP is based on TCP port 179. Note that it is a port number, not a protocol number. What should be emphasized here is that the protocol number is a three-layer concept. The protocol number can only be found in the IP header, such as OSPF. This is one of the reasons why BGP is sometimes called a high-level application. However, the purpose of BGP is still to deliver a large number of routes.
BGP does not automatically discover and establish neighbors like IGP, so you need to manually specify neighbors during configuration. At the same time, the TCP connection needs to specify a source to establish a connection with the peer. This concept is the concept of update-source in BGP. This concept is very important. When a device wants to establish It is very critical to establish multiple BGP neighbors. For example, usually: when establishing iBGP, a loopback interface is used (the reason is that the loopback interface is more stable), and when the device establishes eBGP with another device, it is usually established through a direct connection without specifying the update source. The default is the outbound interface (the interface connected to the eBGP neighbor).
Regarding eBGP multi-hop, it should be pointed out that the default TTL in the IPv4 header in iBGP is 255, while eBGP is 1. If the eBGP neighbor relationship is established through the loopback interface, then the TTL is 2. You need to specify that eBGP multi-hop is greater than or equal to 2.
BGP will not actively establish BGP neighbor relationships through default routes. This is an anti-loop mechanism. This means that if the loopback interface is used as the update source between two peers, and only the default route on the two devices reaches the loopback interface of the opposite end, then there will be a lack of TCP connection and BGP neighbor cannot be established. As long as one end has a detailed route, such as a static route pointing to the loopback interface of the opposite end, it will be sufficient.
BGP, like ospf, also needs a RID to identify the relationship. There must be an ipv4 address as the RID (BGP will not be enabled if there is no address). The selection order of RID is: manually specified; the largest loopback interface (the same as OSPF, it is not necessary to announce the interface, especially BGP, which advertises routes, not activated interfaces); the largest physical interface
Experiment purpose
Master the use of direct routing to establish eBGP neighbor relationships
Master the use of loopback interfaces to establish eBGP neighbor relationships
Experimental environment
Referring to 4.1 Topology, the direct address and loopback interface address have been configured in the preconfiguration. As shown in Figure 4-1

Figure 4-1 eBGP basic configuration
Experimental steps
Use direct connection to establish eBGP neighbor relationships
Step 1. First test the direct communication to ensure that eBGP neighbors can be established
[R5]ping 10.1.15.1 PING 10.1.15.1: 56 data bytes, press CTRL_C to break Reply from 10.1.15.1: bytes=56 Sequence=1 ttl=255 time=60 ms Reply from 10.1.15.1: bytes=56 Sequence=2 ttl=255 time=30 ms |
Step 2. Establish eBGP neighbor
R1 [R1]bgp 100 //Start bgp, AS number is 100 [R1-bgp]router-id 1.1.1.1 //Configure the router ID of R1's bgp to 1.1.1.1. The ID is in an IPv4 address format. It can be an address that does not exist on the device, but it must be a unique RID. [R1-bgp]peer 10.1.15.5 as-number 200 //Establish an eBGP neighbor relationship with the peer 10.1.15.5, the peer AS number is 200 [R1-bgp]network 1.1.1.1 32 //Advertise the business interface of R1. Please note that BGP advertises routes, so the mask must be accurate, otherwise the route will not be generated. R5 [R5]bgp 200 [R5-bgp]router-id 5.5.5.5 [R5-bgp]peer 10.1.15.1 as-number 100 [R5-bgp]network 5.5.5.5 32 |
Step 3. View BGP neighbor relationships and obtained routes
Check BGP neighbor relationships
[R1-bgp]display bgp peer BGP local router ID: 1.1.1.1 //BGP RID Local AS number: 100 //The AS number of this device is 100 Total number of peers : 1 Peers in established state : 1 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 10.1.15.5 4 200 5 5 0 00:02:18 Established 1 //The 1 here represents a bgp route received from the peer, and established represents the neighbor establishment successfully |
View the bgp database, that is, bgp routing
[R1-bgp]dis bgp routing-table BGP Local router ID is 1.1.1.1 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 0.0.0.0 0 0 I //1.1.1.1/32 is the route generated by this device, which can be seen from 0.0.0.0 *> 5.5.5.5/32 10.1.15.5 0 0 200i //The route obtained from the peer As200, you can see that the AS-path is 200 |
Step 4. View the routing table and test data communication
<R1>dis ip routing-table protocol bgp Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : BGP Destinations : 1 Routes : 1 BGP routing table status : <Active> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 5.5.5.5/32 EBGP 255 0 D 10.1.15.5 GigabitEthernet0/0/0 //The route of 5.5.5.5 was obtained through ebgp. Please observe that the priority is 255 Data communication: [R1]ping -a 1.1.1.1 5.5.5.5 //Carry the business interface of the local end and the business interface of the opposite end to test the communication. As shown below, the data is successfully communicated. PING 5.5.5.5: 56 data bytes, press CTRL_C to break Reply from 5.5.5.5: bytes=56 Sequence=1 ttl=255 time=30 ms Reply from 5.5.5.5: bytes=56 Sequence=2 ttl=255 time=30 ms |
Establish eBGP neighbor over loopback interface
Step 1. First, the loopback interfaces at both ends communicate through static routing as the update source.
[R5]ip route-static 11.1.1.1 32 10.1.15.1 [R1]ip route-static 55.1.1.1 32 10.1.15.5 //R1 and R5 point to each other's loopback interfaces, and the next hop is their physical interface address. |
Step 2. Test routing communication
[R5]ping -a 55.1.1.1 11.1.1.1 PING 11.1.1.1: 56 data bytes, press CTRL_C to break Reply from 11.1.1.1: bytes=56 Sequence=1 ttl=255 time=110 ms Reply from 11.1.1.1: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 11.1.1.1: bytes=56 Sequence=3 ttl=255 time=30 ms Reply from 11.1.1.1: bytes=56 Sequence=4 ttl=255 time=20 ms Reply from 11.1.1.1: bytes=56 Sequence=5 ttl=255 time=10 ms --- 11.1.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 10/38/110 ms //The loopback interfaces at both ends communicate successfully, so that they can be used as BGP update sources to establish neighbors. |
Step 3. Establish EBGP neighbor
R1 [R1]bgp 100 //Start bgp, AS number is 100 [R1-bgp]router-id 1.1.1.1 //Configure the router ID of R1's bgp to 1.1.1.1. The ID is in an IPv4 address format. It can be an address that does not exist on the device, but it must be a unique RID. [R1-bgp]peer 55.1.1.1 as-number 200 //Establish an eBGP neighbor relationship with the peer 55.1.1.1 lo0, the peer AS number is 200 [R1-bgp]peer 55.1.1.1 connect-interface lo0 [R1-bgp]peer 55.1.1.1 ebgp-max-hop 2 //Since the TTL value defaults to 1, if the loopback interface is used to establish the ebgp neighbor relationship, then the data packet will not only be transmitted through 1 hop between peers, but the TTL value will be -1 before it is transmitted. If it is 0, it will be discarded. Therefore, multiple hops must be set. [R1-bgp]network 1.1.1.1 32 //Advertise the business interface of R1. Please note that BGP advertises routes, so the mask must be accurate, otherwise the route will not be generated. R5 [R5]bgp 200 //Start bgp, AS number is 100 [R5-bgp]router-id 5.5.5.5 //route-id is specified as 5.5.5.5 [R5-bgp]peer 11.1.1.1 as-number 100 [R5-bgp]network 5.5.5.5 32 [R5-bgp]peer 11.1.1.1 ebgp-max-hop 2 |
View the bgp database, that is, bgp routing
[R1]display bgp routing-table BGP Local router ID is 1.1.1.1 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 2 //Received 2 BGP routes Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 0.0.0.0 0 0 i // A route of 1.1.1.1 is generated from this section, which can be seen from 0.0.0.0 5.5.5.5/32 55.1.1.1 0 0 200i // 5.5.5.5 is the route learned from AS200. It can be seen from AS-path 200i that the next hop is 55.1.1.1 |
Step 4. View the routing table and test data communication
[R1]display ip routing-table protocol bgp Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : BGP Destinations : 1 Routes : 1 BGP routing table status : <Active> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 5.5.5.5/32 EBGP 255 0 RD 55.1.1.1 GigabitEthernet 0/0/0 //The route 5.5.5.5 was obtained through ebgp. Please observe that the priority is 255. BGP routing table status : <Inactive> Destinations : 0 Routes : 0 |
Data communication:

