实验要求:
1.合理IP地址
2.AS 1 2 3 内部使用OSPF 协议 , AS 1 AS 2内部建立全互联的IBGP邻居 ,AS之间建立全部的EBGP邻居
3.PC 1 3 5 属于电信的路由,通信时必须使用电信AS 1 ;PC 2 4 6 属于联通的路由,通信时必须使用联通的 AS 2
4.若 R1-R9之间链路断开,电信的路由依然通过电信 AS 1 通信
一:拓扑:
二:配置ip
..........
三:AS 1 2 3配置OSPF
以R1为例:
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 15.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 13.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
R7通过OSPF学习的路由如下
R8通过OSPF学习的路由如下
R10通过OSPF学习的路由如下
四、AS1,AS2内部建立全互联的IBGP邻居
配置如下:
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 3.3.3.3 as-number 1
[R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp]peer 3.3.3.3 next-hop-local
[R1-bgp]peer 5.5.5.5 as-number 1
[R1-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[R1-bgp]peer 5.5.5.5 next-hop-local
[R1-bgp]peer 7.7.7.7 as-number 1
[R1-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[R1-bgp]peer 7.7.7.7 next-hop-local
R1上BGP邻居表如图
R2上BGP邻居表如图
五、R9,R10建立IBGP邻居
[R9]bgp 3
[R9-bgp]router-id 9.9.9.9
[R9-bgp]peer 10.10.10.10 as-number 3
[R9-bgp]peer 10.10.10.10 connect-interface LoopBack 0
[R9-bgp]peer 10.10.10.10 next-hop-local
[R10]bgp 3
[R10-bgp]router-id 10.10.10.10
[R10-bgp]peer 9.9.9.9 as-number 3
[R10-bgp]peer 9.9.9.9 connect-interface LoopBack 0
[R10-bgp]peer 9.9.9.9 next-hop-local
六、AS之间建立全部的EBGP邻居
[R1-bgp]peer 12.1.1.2 as-number 2
[R2-bgp]peer 12.1.1.1 as-number 1
七、路由宣告
在R9上宣告192.168.1.0/24 --- 192.168.2.0/24
在R10上宣告192.168.3.0/24 --- 192.168.4.0/24
在R11上宣告192.168.5.0/24 --- 192.168.6.0/24
八、PC 1 3 5通信时必须使用电信的AS1 --- AS1中不能通过 2 4 6
R1 --- 让其不接收来自R9和AS2中R2的2.0、4.0、6.0网段
[R1]ip ip-prefix 1 permit 192.168.2.0 24
[R1]ip ip-prefix 2 permit 192.168.4.0 24
[R1]ip ip-prefix 3 permit 192.168.6.0 24
[R1]route-policy a deny node 10
[R1-route-policy]if-match ip-prefix 1
[R1]route-policy a deny node 20
[R1-route-policy]if-match ip-prefix 2
[R1]route-policy a deny node 25
[R1-route-policy]if-match ip-prefix 3
[R1]route-policy a permit node 30
[R1-bgp]peer 19.1.1.9 route-policy a import
[R1-bgp]peer 12.1.1.2 route-policy a import
R3 --- 让其不接收来自AS2中R4的2.0、4.0、6.0网段
R5 --- 让其不接收来自R11和AS2中R6的2.0、4.0、6.0网段
R7 --- 让其不接收来自R8的2.0、4.0、6.0网段
九、PC 2 4 6通信时必须使用联通的AS2 --- 不能直接拒绝1 3 5
R4 --- 除了限制AS1中R3传过来的 1.0-3.0-5.0 网段,还要修改从R10传过来的1.0和3.0 网段的as-path值,使其在R4这是备份的作用,拒绝从R10传过来的5.0网段
[R4]ip ip-prefix 1 permit 192.168.1.0 24
[R4]ip ip-prefix 2 permit 192.168.3.0 24
[R4]ip ip-prefix 3 permit 192.168.5.0 24
[R4]route-policy a deny node 10
[R4-route-policy]if-match ip-prefix 1
[R4]route-policy a deny node 20
[R4-route-policy]if-match ip-prefix 2
[R4]route-policy a deny node 25
[R4-route-policy]if-match ip-prefix 3
[R4]route-policy a permit node 30
修改1.0 和3.0到R4的as-path,使其成为备份
[R4]route-policy b permit node 10
[R4-route-policy]if-match ip-prefix 1
[R4-route-policy]apply as-path 3 additive
[R4]route-policy b permit node 20
[R4-route-policy]if-match ip-prefix 2
[R4-route-policy]apply as-path 3 additive
[R4]route-policy b deny node 30 --- 拒绝5.0网段
[R4-route-policy]if-match ip-prefix 3
[R4]route-policy b permit node 40
[R4]bgp 2
[R4-bgp]peer 34.1.1.3 route-policy a import
[R4-bgp]peer 40.1.1.10 route-policy b import
R2 --- 拒绝从R1传过来的1.0 、3.0、5.0网段
[R2]ip ip-prefix 1 permit 192.168.1.0 24
[R2]ip ip-prefix 2 permit 192.168.3.0 24
[R2]ip ip-prefix 3 permit 192.168.5.0 24
[R2]route-policy a deny node 10
[R2-route-policy]if-match ip-prefix 1
[R2]route-policy a deny node 20
[R2-route-policy]if-match ip-prefix 2
[R2]route-policy a deny node 25
[R2-route-policy]if-match ip-prefix 3
[R2]route-policy a permit node 30
[R2]bgp 2
[R2-bgp]peer 12.1.1.1 route-policy a import
R6 --- 拒绝从R5传过来的1.0 、3.0网段
R8 --- 拒绝从R7、R11传过来的1.0 、3.0、5.0网段,还要拒绝从R4传过来的1.0、3.0
十、测试
正常情况下
R1-R9链路断开时
实验结束