BGP專案

明月人倚樓發表於2020-10-16

專案目的:

實現全網互通,並按要求的路線進行資料傳輸。

專案拓撲圖:

配置檔案:

R1:
#
sysname r1
#
interface GigabitEthernet0/0/0
 ip address 12.1.1.1 255.255.255.0
interface LoopBack0
 ip address 1.1.1.1 255.255.255.255
#
bgp 100
 peer 2.2.2.2 as-number 100
 peer 2.2.2.2 connect-interface LoopBack0
 #
network 1.1.1.1 255.255.255.255
  network 12.1.1.0 255.255.255.0
  peer 2.2.2.2 enable
#
ospf 1 router-id 1.1.1.1
 area 0.0.0.0
  network 1.1.1.1 0.0.0.0
  network 12.1.1.0 0.0.0.255

 

R2:
#
sysname r2
#
interface GigabitEthernet0/0/0
 ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 28.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/2
 ip address 23.1.1.2 255.255.255.0
#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.255
#
bgp 100
 router-id 2.2.2.2
 peer 1.1.1.1 as-number 100
 peer 1.1.1.1 connect-interface LoopBack0
 peer 3.3.3.3 as-number 200
 peer 3.3.3.3 ebgp-max-hop 255
 peer 3.3.3.3 connect-interface LoopBack0
 peer 8.8.8.8 as-number 300
 peer 8.8.8.8 ebgp-max-hop 255
 peer 8.8.8.8 connect-interface LoopBack0
 #
network 1.1.1.1 255.255.255.255
  network 2.2.2.2 255.255.255.255
  network 3.3.3.3 255.255.255.255
  network 8.8.8.8 255.255.255.255
  network 12.1.1.0 255.255.255.0
  network 23.1.1.0 255.255.255.0
  network 28.1.1.0 255.255.255.0
  peer 1.1.1.1 enable
  peer 1.1.1.1 next-hop-local
  peer 3.3.3.3 enable
  peer 8.8.8.8 enable
  peer 8.8.8.8 route-policy as export
#
ospf 1 router-id 2.2.2.2
 area 0.0.0.0
  network 2.2.2.2 0.0.0.0
  network 12.1.1.0 0.0.0.255
#
route-policy as permit node 10
 apply as-path 555 666 777 additive
#
ip route-static 3.3.3.3 255.255.255.255 23.1.1.3
ip route-static 8.8.8.8 255.255.255.255 28.1.1.8

 

R3:
#
sysname r3
#
interface GigabitEthernet0/0/0
 ip address 35.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 36.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/2
 ip address 23.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/3
 ip address 34.1.1.3 255.255.255.0
#
interface LoopBack0
 ip address 3.3.3.3 255.255.255.255
#
bgp 200
 router-id 3.3.3.3
 peer 2.2.2.2 as-number 100
 peer 2.2.2.2 ebgp-max-hop 255
 peer 2.2.2.2 connect-interface LoopBack0
 peer 4.4.4.4 as-number 200
 peer 4.4.4.4 connect-interface LoopBack0
 peer 5.5.5.5 as-number 400
 peer 5.5.5.5 ebgp-max-hop 255
 peer 5.5.5.5 connect-interface LoopBack0
 peer 6.6.6.6 as-number 300
 peer 6.6.6.6 ebgp-max-hop 255
 peer 6.6.6.6 connect-interface LoopBack0
 #
  network 2.2.2.2 255.255.255.255
  network 3.3.3.3 255.255.255.255
  network 4.4.4.4 255.255.255.255
  network 5.5.5.5 255.255.255.255
  network 6.6.6.6 255.255.255.255
  network 34.1.1.0 255.255.255.0
  network 35.1.1.0 255.255.255.0
  network 36.1.1.0 255.255.255.0
  peer 2.2.2.2 enable
  peer 2.2.2.2 route-policy as export
  peer 4.4.4.4 enable
  peer 4.4.4.4 next-hop-local
  peer 5.5.5.5 enable
  peer 6.6.6.6 enable
  peer 6.6.6.6 route-policy as export
#
ospf 1 router-id 3.3.3.3
 area 0.0.0.0
  network 34.1.1.0 0.0.0.255
  network 3.3.3.3 0.0.0.0
#
route-policy as permit node 10
 if-match acl 2000
 apply as-path 444 555 666 additive
#
route-policy as permit node 20
#
ip route-static 2.2.2.2 255.255.255.255 23.1.1.2
ip route-static 5.5.5.5 255.255.255.255 35.1.1.5
ip route-static 6.6.6.6 255.255.255.255 36.1.1.6

 

R4:
#
sysname r4
#
interface GigabitEthernet0/0/0
 ip address 45.1.1.4 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 34.1.1.4 255.255.255.0
#
interface LoopBack0
 ip address 4.4.4.4 255.255.255.255
#
bgp 200
 router-id 4.4.4.4
 peer 3.3.3.3 as-number 200
 peer 3.3.3.3 connect-interface LoopBack0
 peer 5.5.5.5 as-number 400
 peer 5.5.5.5 ebgp-max-hop 255
 peer 5.5.5.5 connect-interface LoopBack0
 #
  network 3.3.3.3 255.255.255.255
  network 4.4.4.4 255.255.255.255
  network 5.5.5.5 255.255.255.255
  network 34.1.1.0 255.255.255.0
  network 45.1.1.0 255.255.255.0
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local
  peer 5.5.5.5 enable
#
ospf 1 router-id 4.4.4.4
 area 0.0.0.0
  network 4.4.4.4 0.0.0.0
  network 34.1.1.0 0.0.0.255
#
ip route-static 5.5.5.5 255.255.255.255 45.1.1.5

 

R5:
#
sysname r5
#
interface GigabitEthernet0/0/0
 ip address 56.1.1.5 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 35.1.1.5 255.255.255.0
#
interface GigabitEthernet0/0/2
 ip address 45.1.1.5 255.255.255.0
#
interface LoopBack0
 ip address 5.5.5.5 255.255.255.255
#
bgp 400
 router-id 5.5.5.5
 peer 3.3.3.3 as-number 200
 peer 3.3.3.3 ebgp-max-hop 255
 peer 3.3.3.3 connect-interface LoopBack0
 peer 4.4.4.4 as-number 200
 peer 4.4.4.4 ebgp-max-hop 255
 peer 4.4.4.4 connect-interface LoopBack0
 peer 6.6.6.6 as-number 300
 peer 6.6.6.6 ebgp-max-hop 255
 peer 6.6.6.6 connect-interface LoopBack0
 #
  network 3.3.3.3 255.255.255.255
  network 4.4.4.4 255.255.255.255
  network 5.5.5.5 255.255.255.255
  network 6.6.6.6 255.255.255.255
  network 35.1.1.0 255.255.255.0
  network 45.1.1.0 255.255.255.0
  network 56.1.1.0 255.255.255.0
  peer 3.3.3.3 enable
  peer 4.4.4.4 enable
  peer 6.6.6.6 enable
#
ip route-static 3.3.3.3 255.255.255.255 35.1.1.3
ip route-static 6.6.6.6 255.255.255.255 56.1.1.6


R6:
#
sysname r6
#
interface GigabitEthernet0/0/0
 ip address 67.1.1.6 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 56.1.1.6 255.255.255.0
#
interface GigabitEthernet0/0/2
 ip address 36.1.1.6 255.255.255.0
#
interface LoopBack0
 ip address 6.6.6.6 255.255.255.255
#
bgp 300
 router-id 6.6.6.6
 peer 3.3.3.3 as-number 200
 peer 3.3.3.3 ebgp-max-hop 255
 peer 3.3.3.3 connect-interface LoopBack0
 peer 5.5.5.5 as-number 400
 peer 5.5.5.5 ebgp-max-hop 255
 peer 5.5.5.5 connect-interface LoopBack0
 peer 7.7.7.7 as-number 300
 peer 7.7.7.7 connect-interface LoopBack0
 peer 8.8.8.8 as-number 300
 peer 8.8.8.8 connect-interface LoopBack0
 #
  network 3.3.3.3 255.255.255.255
  network 5.5.5.5 255.255.255.255
  network 6.6.6.6 255.255.255.255
  network 7.7.7.7 255.255.255.255
  network 8.8.8.8 255.255.255.255
  network 36.1.1.0 255.255.255.0
  network 56.1.1.0 255.255.255.0
  network 67.1.1.0 255.255.255.0
  peer 3.3.3.3 enable
  peer 5.5.5.5 enable
  peer 7.7.7.7 enable
  peer 7.7.7.7 next-hop-local
  peer 8.8.8.8 enable
  peer 8.8.8.8 next-hop-local
#
ospf 1 router-id 3.3.3.3
 area 0.0.0.0
  network 6.6.6.6 0.0.0.0
  network 67.1.1.0 0.0.0.255
#
ip route-static 3.3.3.3 255.255.255.255 36.1.1.3
ip route-static 5.5.5.5 255.255.255.255 56.1.1.5

 

R7
#
sysname r7
#
interface GigabitEthernet0/0/0
 ip address 78.1.1.7 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 67.1.1.7 255.255.255.0
#
interface LoopBack0
 ip address 7.7.7.7 255.255.255.255
#
bgp 300
 router-id 7.7.7.7
 peer 6.6.6.6 as-number 300
 peer 6.6.6.6 connect-interface LoopBack0
 peer 8.8.8.8 as-number 300
 peer 8.8.8.8 connect-interface LoopBack0
 #
  network 6.6.6.6 255.255.255.255
  network 7.7.7.7 255.255.255.255
  network 8.8.8.8 255.255.255.255
  network 67.1.1.0 255.255.255.0
  network 78.0.0.0
  network 78.1.1.0 255.255.255.0
  peer 6.6.6.6 enable
  peer 8.8.8.8 enable
#
ospf 1 router-id 7.7.7.7
 area 0.0.0.0
  network 7.7.7.7 0.0.0.0
  network 67.1.1.0 0.0.0.255
  network 78.1.1.0 0.0.0.255


R8
#
sysname r8
#
interface GigabitEthernet0/0/0
 ip address 28.1.1.8 255.255.255.0
#
interface GigabitEthernet0/0/1
 ip address 78.1.1.8 255.255.255.0
#
interface LoopBack0
 ip address 8.8.8.8 255.255.255.255
#
bgp 300
 router-id 8.8.8.8
 peer 2.2.2.2 as-number 100
 peer 2.2.2.2 ebgp-max-hop 255
 peer 2.2.2.2 connect-interface LoopBack0
 peer 6.6.6.6 as-number 300
 peer 6.6.6.6 connect-interface LoopBack0
 peer 7.7.7.7 as-number 300
 peer 7.7.7.7 connect-interface LoopBack0
 #
  network 2.2.2.2 255.255.255.255
  network 6.6.6.6 255.255.255.255
  network 7.7.7.7 255.255.255.255
  network 8.8.8.8 255.255.255.255
  network 28.1.1.0 255.255.255.0
  network 78.1.1.0 255.255.255.0
  peer 2.2.2.2 enable
  peer 6.6.6.6 enable
  peer 6.6.6.6 next-hop-local
  peer 7.7.7.7 enable
  peer 7.7.7.7 next-hop-local
#
ospf 1 router-id 8.8.8.8
 area 0.0.0.0
  network 78.1.1.0 0.0.0.255
  network 8.8.8.8 0.0.0.0
#
ip route-static 2.2.2.2 255.255.255.255 28.1.1.2

相關文章