BGP的简单配置:

拓扑如下

配置:

R1:interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
 ip address 1.1.2.2 255.255.255.0
!
interface Serial1/0
 ip address 12.1.1.1 255.255.255.0
 serial restart-delay 0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.0 mask 255.255.255.0
 network 1.1.2.0 mask 255.255.255.0
 neighbor 12.1.1.2 remote-as 200
 no auto-summary

R2:interface Serial1/0
 ip address 12.1.1.2 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 23.1.1.1 255.255.255.0
 serial restart-delay 0
!
interface Serial1/2
 ip address 24.1.1.1 255.255.255.0
 serial restart-delay 0
!
router ospf 1
 log-adjacency-changes
 network 23.1.1.1 0.0.0.0 area 0
 network 24.1.1.1 0.0.0.0 area 0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 12.1.1.1 remote-as 100
 neighbor 23.1.1.2 remote-as 200
 neighbor 23.1.1.2 next-hop-self
 neighbor 35.1.1.2 remote-as 200
 neighbor 35.1.1.2 next-hop-self
 no auto-summary
!

R3:interface Serial1/0
 ip address 23.1.1.2 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 35.1.1.1 255.255.255.0
 serial restart-delay 0
!
router ospf 1
 log-adjacency-changes
 network 23.1.1.2 0.0.0.0 area 0
 network 35.1.1.1 0.0.0.0 area 0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 23.1.1.1 remote-as 200
 neighbor 35.1.1.2 remote-as 200
 no auto-summary

R4:(不配置BGP)

interface Serial1/0
 ip address 24.1.1.2 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 45.1.1.1 255.255.255.0
 serial restart-delay 0
!
router ospf 1
 log-adjacency-changes
 network 24.1.1.2 0.0.0.0 area 0
 network 45.1.1.1 0.0.0.0 area 0
!

R5:

!
interface Serial1/0
 ip address 35.1.1.2 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 56.1.1.1 255.255.255.0
 serial restart-delay 0
!
interface Serial1/2
 ip address 45.1.1.2 255.255.255.0
 serial restart-delay 0
!
router ospf 1
 log-adjacency-changes
 network 35.1.1.2 0.0.0.0 area 0
 network 45.1.1.2 0.0.0.0 area 0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 23.1.1.1 remote-as 200
 neighbor 23.1.1.1 next-hop-self
 neighbor 35.1.1.1 remote-as 200
 neighbor 35.1.1.1 next-hop-self
 neighbor 56.1.1.2 remote-as 300
 no auto-summary

R6:interface Loopback0
 ip address 6.6.6.6 255.255.255.0
!
interface Serial1/0
 ip address 56.1.1.2 255.255.255.0
 serial restart-delay 0
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 network 6.6.6.0 mask 255.255.255.0
 neighbor 56.1.1.1 remote-as 200
 no auto-summary
!
ip route 0.0.0.0 0.0.0.0 Serial1/0
说明:1、当R2和R5建立邻居之后,R5并不能学到1.1.1.0和1.1.2.0网段,这是由于下一跳12.1.1.1是不可达的。要实现这点必须在R2配置neighbor 35.1.1.2 next-hop-self告知把R2自身作为下一跳这样R5就可以学到R1上的环回口路由条目。但是此时一定要关闭同步。

2、按着上面的配置,但是R5和R3ping不通1.1.1.1是由于数据包有去有回,所以在R1上面配置默认路由送S1/0出

3、从IBGP学到的路由不能传给IBGP邻居,因此要实现全互联才可以。就像上面实验,如果R2和R5不形成邻居即使R2和R3,R3和R5形成了邻居,R5也是无法学到R1上环回口的网段的。

4、如果R3和R5没有形成邻居,R2和R5形成了邻居,纵然R5学到了R1环回口的路由条目也是不可以ping通的。这是说明了即使有路由条目也不一定能通信的

5、BGP的network 不一定是直连网段,但是必须是明细的路由条目,子网掩码也必须和路由表的一致。