2014年7月19日 星期六

Olive pratice lab- BGP

  • Topology:
BGP_ospf_redistribute.jpeg
Looback:
R1:1.1.1.1
R2:2.2.2.2
R3:3.3.3.3
R4:4.4.4.4

Lab:
最終目的:每個Router都必須ping的到其他router的loopback
1. R2/R4建立OSPF,並可互ping彼此的loopback
2. R1/R2/R3彼此之間,利用界接interface建立ebgp,R2/R4用loopback建立ibgp
3.設定policy,R1/R2/R3放出loopback給彼此學習
4.設定policy,export ospf route 給ebgp
5.驗證每台router都可以互ping loopback IP


過幾天再把設定整理一下放上來。

或許利用寫blog的方式,可以強迫自己練習lab,也趁機會思考並學習兜lab架構的邏輯。


Configuration:

Interface setting:
set logical-systems r1 interfaces em1 unit 12 vlan-id 12
set logical-systems r1 interfaces em1 unit 12 family inet address 192.168.12.1/30
set logical-systems r1 interfaces lo0 unit 1 family inet address 1.1.1.1/32
set logical-systems r2 interfaces em1 unit 23 vlan-id 23
set logical-systems r2 interfaces em1 unit 23 family inet address 192.168.23.1/30
set logical-systems r2 interfaces em1 unit 24 vlan-id 24
set logical-systems r2 interfaces em1 unit 24 family inet address 192.168.24.1/30
set logical-systems r2 interfaces em2 unit 12 vlan-id 12
set logical-systems r2 interfaces em2 unit 12 family inet address 192.168.12.2/30
set logical-systems r2 interfaces lo0 unit 2 family inet address 2.2.2.2/32
set logical-systems r3 interfaces em2 unit 23 vlan-id 23
set logical-systems r3 interfaces em2 unit 23 family inet address 192.168.23.2/30
set logical-systems r3 interfaces lo0 unit 3 family inet address 3.3.3.3/32
set logical-systems r4 interfaces em2 unit 24 vlan-id 24
set logical-systems r4 interfaces em2 unit 24 family inet address 192.168.24.2/30
set logical-systems r4 interfaces lo0 unit 4 family inet address 4.4.4.4/32
set interfaces em1 vlan-tagging
set interfaces em2 vlan-tagging
set interfaces em3 vlan-tagging
set interfaces em4 vlan-tagging
set interfaces em5 vlan-tagging
set interfaces em6 vlan-tagging


確認指令:
互ping interface IP是要通的,ping loopback是不會通的

OSPF setting:
set logical-systems r2 protocols ospf area 0.0.0.0 interface lo0.2
set logical-systems r2 protocols ospf area 0.0.0.0 interface em1.24

set logical-systems r4 protocols ospf area 0.0.0.0 interface lo0.4
set logical-systems r4 protocols ospf area 0.0.0.0 interface em2.24

確認指令:
show ospf neighbor logical-system all
都應在r2/r4會看到full的狀態
r2/r4能夠互ping對方的loopback,確定能夠通才能進行IBGP連接


BGP setting:
EBGP
set logical-systems r1 routing-options autonomous-system 100
set logical-systems r2 routing-options autonomous-system 200
set logical-systems r3 routing-options autonomous-system 300
set logical-systems r4 routing-options autonomous-system 200

set logical-systems r1 protocols bgp group ebgp type external
set logical-systems r1 protocols bgp group ebgp export export_bgp
set logical-systems r1 protocols bgp group ebgp neighbor 192.168.12.2 peer-as 200
set logical-systems r2 protocols bgp group ebgp type external
set logical-systems r2 protocols bgp group ebgp export export_bgp
set logical-systems r2 protocols bgp group ebgp neighbor 192.168.12.1 peer-as 100
set logical-systems r2 protocols bgp group ebgp neighbor 192.168.23.2 peer-as 300

set logical-systems r3 protocols bgp group ebgp type external
set logical-systems r3 protocols bgp group ebgp export export_bgp
set logical-systems r3 protocols bgp group ebgp neighbor 192.168.23.1 peer-as 200


IBGP
set logical-systems r2 protocols bgp group ibgp type internal
set logical-systems r2 protocols bgp group ibgp export export_ibgp
set logical-systems r2 protocols bgp group ibgp neighbor 4.4.4.4 local-address 2.2.2.2

set logical-systems r4 protocols bgp group ibgp type internal
set logical-systems r4 protocols bgp group ibgp neighbor 2.2.2.2 local-address 4.4.4.4


確認指令:
show bgp summary logical-system all
應該都是要full的狀態

為了讓r1/r2/r3/r4可以互相學到loopback,所以設定把direct跟ospf route export到EBGP

Export Policy: 
set logical-systems r1 policy-options policy-statement export_bgp term 10 from protocol direct
set logical-systems r1 policy-options policy-statement export_bgp term 10 then accept

set logical-systems r2 policy-options policy-statement export_bgp term 10 from protocol direct
set logical-systems r2 policy-options policy-statement export_bgp term 10 then accept
set logical-systems r2 policy-options policy-statement export_bgp term 20 from protocol ospf
set logical-systems r2 policy-options policy-statement export_bgp term 20 then accept

set logical-systems r3 policy-options policy-statement export_bgp term 10 from protocol direct
set logical-systems r3 policy-options policy-statement export_bgp term 10 then accept
 

確認指令就是show route logical-systems X,可看到r1/r2/r3/r4的route
但是此時ping  4.4.4.4會有不通的問題(r1跟r3才有)

此時需要把EBGP學來的route,bgp不會去變動next-hop的位址,所以需要手動加入next-hop self,此時r4學習到的route才會正常的往r2送。
set logical-systems r2 policy-options policy-statement export_ibgp term 10 from protocol bgp
set logical-systems r2 policy-options policy-statement export_ibgp term 10 then next-hop self
set logical-systems r2 policy-options policy-statement export_ibgp term 20 from protocol direct
set logical-systems r2 policy-options policy-statement export_ibgp term 20 then accept


此時每台的loopback應該都可以通了,恭喜完成bgp lab了。
完整設定
set logical-systems r1 interfaces em1 unit 12 vlan-id 12
set logical-systems r1 interfaces em1 unit 12 family inet address 192.168.12.1/30
set logical-systems r1 interfaces lo0 unit 1 family inet address 1.1.1.1/32
set logical-systems r1 protocols bgp group ebgp type external
set logical-systems r1 protocols bgp group ebgp export export_bgp
set logical-systems r1 protocols bgp group ebgp neighbor 192.168.12.2 peer-as 200
set logical-systems r1 policy-options policy-statement export_bgp term 10 from protocol direct
set logical-systems r1 policy-options policy-statement export_bgp term 10 then accept
set logical-systems r1 routing-options autonomous-system 100
set logical-systems r2 interfaces em1 unit 23 vlan-id 23
set logical-systems r2 interfaces em1 unit 23 family inet address 192.168.23.1/30
set logical-systems r2 interfaces em1 unit 24 vlan-id 24
set logical-systems r2 interfaces em1 unit 24 family inet address 192.168.24.1/30
set logical-systems r2 interfaces em2 unit 12 vlan-id 12
set logical-systems r2 interfaces em2 unit 12 family inet address 192.168.12.2/30
set logical-systems r2 interfaces lo0 unit 2 family inet address 2.2.2.2/32
set logical-systems r2 protocols bgp group ebgp type external
set logical-systems r2 protocols bgp group ebgp export export_bgp
set logical-systems r2 protocols bgp group ebgp neighbor 192.168.12.1 peer-as 100
set logical-systems r2 protocols bgp group ebgp neighbor 192.168.23.2 peer-as 300
set logical-systems r2 protocols bgp group ibgp type internal
set logical-systems r2 protocols bgp group ibgp export export_ibgp
set logical-systems r2 protocols bgp group ibgp neighbor 4.4.4.4 local-address 2.2.2.2
set logical-systems r2 protocols ospf area 0.0.0.0 interface lo0.2
set logical-systems r2 protocols ospf area 0.0.0.0 interface em1.24
set logical-systems r2 policy-options policy-statement export_bgp term 10 from protocol direct
set logical-systems r2 policy-options policy-statement export_bgp term 10 then accept
set logical-systems r2 policy-options policy-statement export_bgp term 20 from protocol ospf
set logical-systems r2 policy-options policy-statement export_bgp term 20 then accept
set logical-systems r2 policy-options policy-statement export_ibgp term 10 from protocol bgp
set logical-systems r2 policy-options policy-statement export_ibgp term 10 then next-hop self
set logical-systems r2 policy-options policy-statement export_ibgp term 20 from protocol direct
set logical-systems r2 policy-options policy-statement export_ibgp term 20 then accept
set logical-systems r2 routing-options autonomous-system 200
set logical-systems r3 interfaces em2 unit 23 vlan-id 23
set logical-systems r3 interfaces em2 unit 23 family inet address 192.168.23.2/30
set logical-systems r3 interfaces lo0 unit 3 family inet address 3.3.3.3/32
set logical-systems r3 protocols bgp group ebgp type external
set logical-systems r3 protocols bgp group ebgp export export_bgp
set logical-systems r3 protocols bgp group ebgp neighbor 192.168.23.1 peer-as 200
set logical-systems r3 policy-options policy-statement export_bgp term 10 from protocol direct
set logical-systems r3 policy-options policy-statement export_bgp term 10 then accept
set logical-systems r3 routing-options autonomous-system 300
set logical-systems r4 interfaces em2 unit 24 vlan-id 24
set logical-systems r4 interfaces em2 unit 24 family inet address 192.168.24.2/30
set logical-systems r4 interfaces lo0 unit 4 family inet address 4.4.4.4/32
set logical-systems r4 protocols bgp group ibgp type internal
set logical-systems r4 protocols bgp group ibgp neighbor 2.2.2.2 local-address 4.4.4.4
set logical-systems r4 protocols ospf area 0.0.0.0 interface lo0.4
set logical-systems r4 protocols ospf area 0.0.0.0 interface em2.24
set logical-systems r4 routing-options autonomous-system 200
set interfaces em1 vlan-tagging
set interfaces em2 vlan-tagging
set interfaces em3 vlan-tagging
set interfaces em4 vlan-tagging
set interfaces em5 vlan-tagging
set interfaces em6 vlan-tagging 

沒有留言: