BGP实验

实验拓扑图如下:

BGP实验

配置接口IP、环回

[R1]int GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 13.0.0.1 24
[R1-GigabitEthernet0/0/0]q
[R1]int l0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]q

[R2]int GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 24.0.0.1 24
[R2-GigabitEthernet0/0/0]q
[R2]int l0
[R2-LoopBack0]ip address 2.2.2.2 32
[R2-LoopBack0]q

[R3]int GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 13.0.0.2 24
[R3-GigabitEthernet0/0/0]int GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 35.0.0.1 24
[R3-GigabitEthernet0/0/1]q
[R3]int l0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]q

[R4]int GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip address 24.0.0.2 24
[R4-GigabitEthernet0/0/0]int GigabitEthernet 0/0/1
[R4-GigabitEthernet0/0/1]ip address 45.0.0.1 24
[R4-GigabitEthernet0/0/1]
[R4-GigabitEthernet0/0/1]q
[R4]int l0
[R4-LoopBack0]ip address 4.4.4.4 32
[R4-LoopBack0]q

[R5]int GigabitEthernet 0/0/0
[R5-GigabitEthernet0/0/0]ip address 35.0.0.2 24
[R5-GigabitEthernet0/0/0]int GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]ip address 45.0.0.2 24
[R5-GigabitEthernet0/0/1]q
[R5]int l0
[R5-LoopBack0]ip address 5.5.5.5 32
[R5-LoopBack0]q

AS300内启用OSPF

[R3]ospf  1 router-id 3.3.3.3
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 35.0.0.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]q

[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]a 0
[R4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 45.0.0.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]q

[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]a 0
[R5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 35.0.0.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 45.0.0.0 0.0.0.255

BGP建邻

EBGP邻居的建立(利用直连)

[R1]bgp 100
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 13.0.0.2 as-number 300

[R2]bgp 200
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 24.0.0.2 as-number 300

[R3]bgp 300
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 13.0.0.1 as-number 100

[R4]bgp 300
[R4-bgp]router-id 4.4.4.4 	
[R4-bgp]peer 24.0.0.1 as-number 200

IBGP邻居的建立(利用环回建立)

[R3-bgp]peer 4.4.4.4 as-number 300
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0

[R4-bgp]peer 3.3.3.3 as-number 300
[R4-bgp]peer 3.3.3.3 connect-interface LoopBack 0

查看邻居

<R1>display bgp peer 

 BGP local router ID : 1.1.1.1
 Local AS number : 100
 Total number of peers : 1		  Peers in established state : 1

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  13.0.0.2        4         300       12       13     0 00:10:16 Established  0

配置静态路由

[R1]ip route-static 3.3.3.3 32 13.0.0.2

[R2]ip route-static 4.4.4.4 32 24.0.0.2

[R3]ip route-static 1.1.1.1 32 13.0.0.1

[R4]ip route-static 2.2.2.2 32 24.0.0.1

引入路由

[r3]route-policy ddd permit node 10
[r3-route-policy]if-match interface GigabitEthernet 0/0/0	#接口匹配
[r3-route-policy]if-match interface GigabitEthernet 0/0/1
[R3-route-policy]q
[r3]bgp 300
[r3-bgp]import-route direct route-policy ddd 

[r4]route-policy ddd permit node 10
[r4-route-policy]if-match interface GigabitEthernet 0/0/0
[r4-route-policy]if-match interface GigabitEthernet 0/0/1
[R4-route-policy]q
[r4]bgp 300
[r4-bgp]import-route direct route-policy ddd 

过滤

 新加俩环回

[r1]int l1
[r1-LoopBack1]ip add 10.10.10.10 32
[r1-LoopBack1]int l2
[r1-LoopBack2]ip add 20.20.20.20 32

[r1]bgp 100
[r1-bgp]network 10.10.10.0 32
[r1-bgp]network 20.20.20.0 32

使用前缀列表来实现过滤

[r1]ip ip-prefix 10 deny 10.10.10.10 32	10.10.10.10
[r1]ip ip-prefix 10 permit 0.0.0.0 0 less-equal 32	
[r1]bgp 100
[r1-bgp]peer 13.0.0.2 ip-prefix 10 export	

上一篇:【原】iOS动态性(五)一种可复用且解耦的用户统计实现(运行时Runtime)


下一篇:什么是BGP网络线路?BGP线路到底是什么意思?