BGP学习过程-1

一、R1R2分属于AS1AS2

 

r1#show run

Building configuration...

 

Current configuration : 1252 bytes

!

version 12.2

service timestamps debug uptime

service timestamps log uptime

no service password-encryption

!

hostname r1

!

!

ip subnet-zero

ip cef

!

!

no ip domain-lookup

!

call rsvp-sync

!        

!        

interface Loopback0

 ip address 1.1.1.1 255.255.255.0

!        

interface FastEthernet0/0

 no ip address

 shutdown

 duplex half

!        

interface Serial1/0

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial1/1

 ip address 192.168.12.1 255.255.255.0

 serial restart-delay 0

!        

interface Serial1/2

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial1/3

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/0

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/1

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/2

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/3

 no ip address

 shutdown

 serial restart-delay 0

!        

router bgp 1

 bgp log-neighbor-changes

 network 1.1.1.0 mask 255.255.255.0

 network 192.168.12.0

 neighbor 192.168.12.2 remote-as 2

!        

ip classless

no ip http server

!        

!        

dial-peer cor custom

!        

!        

gatekeeper

 shutdown

!        

!        

line con 0

 exec-timeout 0 0

 password cisco

 logging synchronous

line aux 0

line vty 0 4

 password cisco

 login   

!        

end       

 ------------------------

r2#show run

00:10:43: %SYS-5-CONFIG_I: Configured from console by console

r2#show run

Building configuration...

 

Current configuration : 1252 bytes

!

version 12.2

service timestamps debug uptime

service timestamps log uptime

no service password-encryption

!

hostname r2

!

!

ip subnet-zero

ip cef

!

!

no ip domain-lookup

!

call rsvp-sync

!        

!        

interface Loopback0

 ip address 2.2.2.2 255.255.255.0

!        

interface FastEthernet0/0

 no ip address

 shutdown

 duplex half

!        

interface Serial1/0

 ip address 192.168.12.2 255.255.255.0

 serial restart-delay 0

!        

interface Serial1/1

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial1/2

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial1/3

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/0

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/1

 no ip address

 shutdown

 serial restart-delay 0

!         

interface Serial2/2

 no ip address

 shutdown

 serial restart-delay 0

!        

interface Serial2/3

 no ip address

 shutdown

 serial restart-delay 0

!        

router bgp 2

 bgp log-neighbor-changes

 network 2.2.2.0 mask 255.255.255.0

 network 192.168.12.0

 neighbor 192.168.12.1 remote-as 1

!        

ip classless

no ip http server

!        

!        

dial-peer cor custom

!        

!        

gatekeeper

 shutdown

!        

!        

line con 0

 exec-timeout 0 0

 password cisco

 logging synchronous

line aux 0

line vty 0 4

 password cisco

 login   

!        

end      

 

 

 

 

 

 

有关状态详解:

r1#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

C    192.168.12.0/24 is directly connected, Serial1/1

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

     2.0.0.0/24 is subnetted, 1 subnets

B       2.2.2.0 [20/0] via 192.168.12.2, 00:10:16

 

 

r1#ping 2.2.2.2 source 1.1.1.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/27/56 ms

 

 

r1#show ip bgp

BGP table version is 4, local router ID is 1.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.0/24       0.0.0.0                  0         32768 i

*> 2.2.2.0/24       192.168.12.2             0             0 2 i

*  192.168.12.0     192.168.12.2             0             0 2 i

*>                  0.0.0.0                  0         32768 i

 

 

r1#show ip bgp neighbors

BGP neighbor is 192.168.12.2,  remote AS 2, external link

  BGP version 4, remote router ID 2.2.2.2

  BGP state = Established, up for 00:13:34

  Last read 00:00:34, hold time is 180, keepalive interval is 60 seconds

  Neighbor capabilities:

    Route refresh: advertised and received(old & new)

    Address family IPv4 Unicast: advertised and received

  Message statistics:

    InQ depth is 0

    OutQ depth is 0

                         Sent       Rcvd

    Opens:                  1          1

    Notifications:          0          0

    Updates:                1          1

    Keepalives:            16         16

    Route Refresh:          0          0

    Total:                 18         18

  Default minimum time between advertisement runs is 30 seconds

 

 For address family: IPv4 Unicast

  BGP table version 4, neighbor version 4

  Index 1, Offset 0, Mask 0x2

                                 Sent       Rcvd

  Prefix activity:               ----       ----

    Prefixes Current:               2          2 (Consumes 72 bytes)

    Prefixes Total:                 2          2

    Implicit Withdraw:              0          0

    Explicit Withdraw:              0          0

    Used as bestpath:             n/a          1

    Used as multipath:            n/a          0

         

                                   Outbound    Inbound

  Local Policy Denied Prefixes:    --------    -------

    Bestpath from this peer:              1        n/a

    Total:                                1          0

  Number of NLRIs in the update sent: max 2, min 0

         

  Connections established 1; dropped 0

  Last reset never

Connection state is ESTAB, I/O status: 1, unread input bytes: 0

Local host: 192.168.12.1, Local port: 11000

Foreign host: 192.168.12.2, Foreign port: 179--------BGP使用的是TCP179端口

         

Enqueued packets for retransmit: 0, input: 0  mis-ordered: 0 (0 bytes)

         

Event Timers (current time is 0xF670C):

Timer          Starts    Wakeups            Next

Retrans            19          0             0x0

TimeWait            0          0             0x0

AckHold            18         14             0x0

SendWnd             0          0             0x0

KeepAlive           0          0             0x0

GiveUp              0          0             0x0

PmtuAger            0          0             0x0

DeadWait            0          0             0x0

         

iss: 2892687547  snduna: 2892687953  sndnxt: 2892687953     sndwnd:  15979

irs: 2895553805  rcvnxt: 2895554211  rcvwnd:      15979  delrcvwnd:    405

         

SRTT: 276 ms, RTTO: 466 ms, RTV: 190 ms, KRTT: 0 ms

minRTT: 4 ms, maxRTT: 300 ms, ACK hold: 200 ms

Flags: higher precedence, nagle

         

Datagrams (max data segment is 1460 bytes):

Rcvd: 20 (out of order: 0), with data: 18, total data bytes: 405

Sent: 34 (retransmit: 0, fastretransmit: 0), with data: 18, total data bytes: 405

 

 

r1#show ip bgp summary

BGP router identifier 1.1.1.1, local AS number 1

BGP table version is 4, main routing table version 4

3 network entries using 291 bytes of memory

4 path entries using 144 bytes of memory

2 BGP path attribute entries using 120 bytes of memory

1 BGP AS-PATH entries using 24 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes of memory

BGP using 579 total bytes of memory

BGP activity 3/0 prefixes, 4/0 paths, scan interval 60 secs

 

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

192.168.12.2    4     2      20      20        4    0    0 00:15:53        2

 

 

r1#debug ip bgp

BGP debugging is on

r1#clear ip bgp *

r1#

00:20:16: BGP: 192.168.12.2 went from Established to Idle

00:20:16: %BGP-5-ADJCHANGE: neighbor 192.168.12.2 Down User reset

r1#

00:20:16: BGP: 192.168.12.2 closing

r1#

00:20:36: BGP: 192.168.12.2 went from Idle to Active

00:20:36: BGP: 192.168.12.2 open active, delay 26680ms

r1#

00:20:53: BGP: Applying map to find origin for 1.1.1.0/24

00:20:53: BGP: Applying map to find origin for 192.168.12.0/24

r1#

00:20:55: BGP: 192.168.12.2 passive open

00:20:55: BGP: 192.168.12.2 went from Active to Idle

00:20:55: BGP: 192.168.12.2 went from Idle to Connect

00:20:55: BGP: 192.168.12.2 rcv message type 1, length (excl. header) 26

00:20:55: BGP: 192.168.12.2 rcv OPEN, version 4

00:20:55: BGP: 192.168.12.2 went from Connect to OpenSent

00:20:55: BGP: 192.168.12.2 sending OPEN, version 4, my as: 1

00:20:55: BGP: 192.168.12.2 rcv OPEN w/ OPTION parameter len: 16

00:20:55: BGP: 192.168.12.2 rcvd OPEN w/ optional parameter type 2 (Capability) len 6

00:20:55: BGP: 192.168.12.2 OPEN has CAPABILITY code: 1, length 4

00:20:55: BGP: 192.168.12.2 OPEN has MP_EXT CAP for afi/safi: 1/1

00:20:55: BGP: 192.168.12.2 rcvd OPEN w/ optional parameter type 2 (Capability) len 2

00:20:55: BGP: 192.168.12.2 OPEN has CAPABILITY code: 128, length 0

00:20:55: BGP: 192.168.12.2 OPEN has ROUTE-REFRESH capability(old) for all address-families

00:20:55: BGP: 192.168.12.2 rcvd OPEN w/ optional parameter type

r1#2 (Capability) len 2

00:20:55: BGP: 192.168.12.2 OPEN has CAPABILITY code: 2, length 0

00:20:55: BGP: 192.168.12.2 OPEN has ROUTE-REFRESH capability(new) for all address-families

00:20:55: BGP: 192.168.12.2 went from OpenSent to OpenConfirm

00:20:55: BGP: 192.168.12.2 send message type 1, length (incl. header) 45

00:20:55: BGP: 192.168.12.2 went from OpenConfirm to Established

00:20:55: %BGP-5-ADJCHANGE: neighbor 192.168.12.2 Up

r1#

00:21:53: BGP: Applying map to find origin for 1.1.1.0/24

00:21:53: BGP: Applying map to find origin for 192.168.12.0/24

r1#

00:22:53: BGP: Applying map to find origin for 1.1.1.0/24

00:22:53: BGP: Applying map to find origin for 192.168.12.0/24

r1#un all

All possible debugging has been turned off

 

R2状态显示:

r2#

00:20:18: %BGP-5-ADJCHANGE: neighbor 192.168.12.1 Down Peer closed the session

r2#

00:20:54: %BGP-5-ADJCHANGE: neighbor 192.168.12.1 Up