实验需求:全网互通
拓扑:
步骤1:配置接口ip
R1(config)#interface f0/0
R1(config-if)#IP address 12.12.12.1 255.255.255.0
R1(config-if)#no shutdown
R2(config)#interface f0/0
R2(config-if)#IP address 12.12.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface f0/1
R2(config-if)#ip add 23.23.23.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#interface f0/1
R3(config-if)#IP address 23.23.23.3 255.255.255.0
R3(config-if)#no shutdown
步骤2:bgp配置
R1(config)#router bgp 1
R1(config-router)#neighbor 12.12.12.2 remote-as 1 //指定建立对等体关系的网络所在as,以确定建立的是ibgp关系还是ebgp
R1(config-router)#neighbor 23.23.23.3 remote-as 1
R1(config-router)#netghbor 12.12.12.0 mask 255.255.255.0 //宣告直连网络,也可不加掩码
R2(config)#router bgp 1
R2(config-router)#neighbor 12.12.12.1 remote-as 1
R2(config-router)#neighbor 23.23.23.3 remote-as 1
R2(config-router)#network 12.12.12.0 mask 255.255.255.0
R2(config-router)#network 23.23.23.0 mask 255.255.255.0
R3(config)#router bgp 1
R3(config-router)#neighbor 23.23.23.2 remote-as 1
R3(config-router)#neighbor 12.12.12.1 remote-as 1
R3(config-router)#network 23.23.23.0 mask 255.255.255.0
此时全网互通
R3(config-router)#do ping 12.12.12.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.12.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/32/48 ms
查看路由表
R3#show ip route
Gateway of last resort is not set
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
B 12.12.12.0 [200/0] via 23.23.23.2, 00:00:04 //该路由代码表示该路由条目是由bgp学习的
查看bgp邻接关系建立情况
R3#show ip bgp summary
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.12.12.1 4 1 10 10 26 0 0 00:05:53 1
23.23.23.2 4 1 11 11 26 0 0 00:06:58 2
也可以查看完整版信息
R3#show ip bgp neighbor
BGP neighbor is 12.12.12.1, remote AS 1, internal link
BGP version 4, remote router ID 12.12.12.1
BGP state = Established, up for 00:08:36
Last read 00:00:36, last write 00:00:36, 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: 11 11
Route Refresh: 0 0
Total: 13 13
Default minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
BGP table version 38, neighbor version 38/0
Output queue size : 0
Index 1, Offset 0, Mask 0x2
1 update-group member
Sent Rcvd
Prefix activity: ---- ----
Prefixes Current: 1 1 (Consumes 52 bytes)
Prefixes Total: 1 1
Implicit Withdraw: 1 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: 18 n/a
Bestpath from iBGP peer: 18 n/a
Total: 36 0
Number of NLRIs in the update sent: max 1, min 1
Connections established 1; dropped 0
Last reset never
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 255
Local host: 23.23.23.3, Local port: 179
Foreign host: 12.12.12.1, Foreign port: 53461
Enqueued packets for retransmit: 0, input: 0 mis-ordered: 0 (0 bytes)
Event Timers (current time is 0x2CBA0C):
Timer Starts Wakeups Next
Retrans 21 10 0x0
TimeWait 0 0 0x0
AckHold 12 1 0x0
SendWnd 0 0 0x0
KeepAlive 0 0 0x0
GiveUp 0 0 0x0
PmtuAger 0 0 0x0
DeadWait 0 0 0x0
iss: 3247729217 snduna: 3247729527 sndnxt: 3247729527 sndwnd: 16075
irs: 303948023 rcvnxt: 303948333 rcvwnd: 16075 delrcvwnd: 309
SRTT: 182 ms, RTTO: 1073 ms, RTV: 891 ms, KRTT: 4292 ms
minRTT: 20 ms, maxRTT: 300 ms, ACK hold: 200 ms
Flags: passive open, nagle, gen tcbs
IP Precedence value : 6
Datagrams (max data segment is 536 bytes):
Rcvd: 30 (out of order: 0), with data: 12, total data bytes: 309
Sent: 21 (retransmit: 10, fastretransmit: 0, partialack: 0, Second Congestion: 0), with data: 11, total data bytes: 309