NETWORK ENGINEER BLOG

Tips and Reviews for Engineers

BGP設定例

概要

BGP を使った冗長化設定例になります。
動作確認は R5 と R6 の Loopback インターフェース間の Ping 疎通により行っています。

検証環境

  • CSR1000V を VMware Workstation 上に構築
  • IOS は 15.4(1)S2を使用

f:id:FriendsNow:20170506114903p:plain

通信フロー

正常系

f:id:FriendsNow:20170506115004p:plain

故障系-1

f:id:FriendsNow:20170506120026p:plain

故障系-2

f:id:FriendsNow:20170506120234p:plain

故障系-3

f:id:FriendsNow:20170506120245p:plain

設定例

R1

hostname R1
!
interface GigabitEthernet1
 ip address 10.1.13.1 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2
 ip address 10.1.12.1 255.255.255.0
 negotiation auto
!
interface GigabitEthernet3
 ip address 172.16.15.1 255.255.255.0
 negotiation auto
!
router ospf 1
 redistribute bgp 65001 metric 100 metric-type 1 subnets
 network 172.16.15.0 0.0.0.255 area 0
!
router bgp 65001
 bgp log-neighbor-changes
 timers bgp 10 30
 neighbor 10.1.12.2 remote-as 65001
 neighbor 10.1.13.3 remote-as 65002
 !
 address-family ipv4
  bgp redistribute-internal
  network 192.168.5.0
  neighbor 10.1.12.2 activate
  neighbor 10.1.12.2 next-hop-self
  neighbor 10.1.13.3 activate
  neighbor 10.1.13.3 route-map LP in
  neighbor 10.1.13.3 route-map MED out
  neighbor 10.1.13.3 filter-list 1 out
 exit-address-family
!
ip as-path access-list 1 permit ^$
ip as-path access-list 2 permit ^65002_
!
access-list 1 permit 192.168.5.0 0.0.0.255
!
route-map LP permit 10
 match as-path 2
 set local-preference 200
!
route-map MED permit 10
 match ip address 1
 set metric 110
!

R2

hostname R2
!
interface GigabitEthernet1
 ip address 10.1.24.2 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2
 ip address 10.1.12.2 255.255.255.0
 negotiation auto
!
interface GigabitEthernet3
 ip address 172.16.25.2 255.255.255.0
 negotiation auto
!
router ospf 1
 network 172.16.25.0 0.0.0.255 area 0
!
router bgp 65001
 bgp log-neighbor-changes
 timers bgp 10 30
 neighbor 10.1.12.1 remote-as 65001
 neighbor 10.1.24.4 remote-as 65002
 !
 address-family ipv4
  network 192.168.5.0
  neighbor 10.1.12.1 activate
  neighbor 10.1.12.1 next-hop-self
  neighbor 10.1.24.4 activate
  neighbor 10.1.24.4 route-map LP in
  neighbor 10.1.24.4 route-map MED out
  neighbor 10.1.24.4 filter-list 1 out
  distance bgp 20 100 200
 exit-address-family
!
ip as-path access-list 1 permit ^$
ip as-path access-list 2 permit ^65002_
!
access-list 1 permit 192.168.5.0 0.0.0.255
!
route-map LP permit 10
 match as-path 2
 set local-preference 150
!
route-map MED permit 10
 match ip address 1
 set metric 120
!

R3

hostname R3
!
interface GigabitEthernet1
 ip address 10.1.13.3 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2
 ip address 10.1.34.3 255.255.255.0
 negotiation auto
!
interface GigabitEthernet3
 ip address 172.16.36.3 255.255.255.0
 negotiation auto
!
router ospf 1
 redistribute bgp 65002 metric 100 metric-type 1 subnets
 network 172.16.36.0 0.0.0.255 area 0
!
router bgp 65002
 bgp log-neighbor-changes
 timers bgp 10 30
 neighbor 10.1.13.1 remote-as 65001
 neighbor 10.1.34.4 remote-as 65002
 !
 address-family ipv4
  bgp redistribute-internal
  network 192.168.6.0
  neighbor 10.1.13.1 activate
  neighbor 10.1.13.1 route-map LP in
  neighbor 10.1.13.1 route-map MED out
  neighbor 10.1.13.1 filter-list 1 out
  neighbor 10.1.34.4 activate
  neighbor 10.1.34.4 next-hop-self
 exit-address-family
!
ip as-path access-list 1 permit ^$
ip as-path access-list 2 permit ^65001_
!
access-list 1 permit 192.168.6.0 0.0.0.255
!
route-map LP permit 10
 match as-path 2
 set local-preference 200
!
route-map MED permit 10
 match ip address 1
 set metric 110
!

R4

hostname R4
!
interface GigabitEthernet1
 ip address 10.1.24.4 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2
 ip address 10.1.34.4 255.255.255.0
 negotiation auto
!
interface GigabitEthernet3
 ip address 172.16.46.4 255.255.255.0
 negotiation auto
!
router ospf 1
 network 172.16.46.0 0.0.0.255 area 0
!
router bgp 65002
 bgp log-neighbor-changes
 timers bgp 10 30
 neighbor 10.1.24.2 remote-as 65001
 neighbor 10.1.34.3 remote-as 65002
 !
 address-family ipv4
  network 192.168.6.0
  neighbor 10.1.24.2 activate
  neighbor 10.1.24.2 route-map LP in
  neighbor 10.1.24.2 route-map MED out
  neighbor 10.1.24.2 filter-list 1 out
  neighbor 10.1.34.3 activate
  neighbor 10.1.34.3 next-hop-self
  distance bgp 20 100 200
 exit-address-family
!
ip as-path access-list 1 permit ^$
ip as-path access-list 2 permit ^65001_
!
access-list 1 permit 192.168.6.0 0.0.0.255
!
route-map LP permit 10
 match as-path 2
 set local-preference 150
!
route-map MED permit 10
 match ip address 1
 set metric 120
!

R5

hostname R5
!
interface Loopback1
 ip address 192.168.5.5 255.255.255.0
 ip ospf network point-to-point
!
interface GigabitEthernet1
 ip address 172.16.15.5 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2
 ip address 172.16.25.5 255.255.255.0
 negotiation auto
!
router ospf 1
 network 172.16.15.0 0.0.0.255 area 0
 network 172.16.25.0 0.0.0.255 area 0
 network 192.168.5.0 0.0.0.255 area 0
!
ip route 192.168.6.0 255.255.255.0 172.16.25.2 200
!

R6

hostname R6
!
interface Loopback1
 ip address 192.168.6.6 255.255.255.0
 ip ospf network point-to-point
!
interface GigabitEthernet1
 ip address 172.16.36.6 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2
 ip address 172.16.46.6 255.255.255.0
 negotiation auto
!
router ospf 1
 network 172.16.36.0 0.0.0.255 area 0
 network 172.16.46.0 0.0.0.255 area 0
 network 192.168.6.0 0.0.0.255 area 0
!
ip route 192.168.5.0 255.255.255.0 172.16.46.4 200168.6.0 255.255.255.0 172.16.25.2 200
!

設定のポイント

R1(R3)

  • IBGP の経路情報を OSPF へ再配送
 address-family ipv4
  bgp redistribute-internal

R2(R4)

  • IBGP の AD 値をデフォルトの200から100へ変更*1
 address-family ipv4
  distance bgp 20 100 200

共通

  • 他の AS の経路情報を配送しない。
 address-family ipv4
  neighbor 10.1.13.3 filter-list 1 out
!
ip as-path access-list 1 permit ^$

動作確認

正常系

R1(R3)は、対向へ経路情報を配信

R1#show ip bgp neighbors 10.1.13.3 advertised-routes
BGP table version is 4, local router ID is 192.168.1.221
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.5.0      172.16.15.5              2         32768 i

Total number of prefixes 1

R1(R3)は、対向から経路情報を受信

R1#show ip bgp neighbors 10.1.13.3 routes
BGP table version is 4, local router ID is 192.168.1.221
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.6.0      10.1.13.3              110    200      0 65002 i

Total number of prefixes 1

R1(R3)は、LAN 内のネットワークについて OSPF 経由の経路を使用

R1#show ip route 192.168.5.0 longer-prefixes
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

O     192.168.5.0/24 [110/2] via 172.16.15.5, 06:44:10, GigabitEthernet3

R1(R3)は、対向のネットワークについて BGP 経由の経路を使用

R1#show ip route 192.168.6.0 longer-prefixes
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

B     192.168.6.0/24 [20/110] via 10.1.13.3, 00:29:35

R2(R4)は、対向のネットワークについて R1(R3)経由の経路を使用(LocPrf により優先)

R2#show ip bgp
BGP table version is 3, local router ID is 192.168.1.222
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 192.168.5.0      10.1.12.1                2    100      0 i
 *   192.168.6.0      10.1.24.4              120    150      0 65002 i
 *>i                  10.1.12.1              110    200      0 65002 i

故障系-1

R1(R3)は、対向のネットワークについて R2(R4)経由の経路へ変更

R1#show ip bgp
BGP table version is 8, local router ID is 192.168.1.221
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.5.0      172.16.15.5              2         32768 i
 *>i 192.168.6.0      10.1.12.2              120    150      0 65002 i

R2(R4)は、対向のネットワークについて R4(R2)経由の経路へ変更

R2#show ip bgp
BGP table version is 4, local router ID is 192.168.1.222
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 192.168.5.0      10.1.12.1                2    100      0 i
 *>  192.168.6.0      10.1.24.4              120    150      0 65002 i

故障系-2

R1(R3)は、LAN 内のネットワークについて BGP 経由の経路へ変更

R1#show ip route 192.168.5.0 longer-prefixes
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

B     192.168.5.0/24 [200/2] via 10.1.12.2, 00:13:30

R2(R4)は、LAN 内のネットワークについて OSPF 経由の経路へ変更

R2#show ip route 192.168.5.0 longer-prefixes
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

O     192.168.5.0/24 [110/2] via 172.16.25.5, 00:24:05, GigabitEthernet3

故障系-3

R2(R4)は、LAN 内のネットワークについて OSPF 経由の経路へ変更

R2#show ip route 192.168.5.0 longer-prefixes
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

O     192.168.5.0/24 [110/2] via 172.16.25.5, 00:24:05, GigabitEthernet3

R2(R4)は、対向のネットワークについて R4(R2)経由の経路へ変更

R2#show ip route 192.168.6.0 longer-prefixes
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

B     192.168.6.0/24 [20/120] via 10.1.24.4, 00:06:25

R3は、対向のネットワークについて R4 経由の経路へ変更

R3#show ip bgp
BGP table version is 8, local router ID is 192.168.1.223
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 192.168.5.0      10.1.34.4              120    150      0 65001 i
 *>  192.168.6.0      172.16.36.6              2         32768 i

R5(R6)は、対向のネットワークについて R2(R4)経由の経路へ変更

R5#show ip static route
Codes: M - Manual static, A - AAA download, N - IP NAT, D - DHCP,
       G - GPRS, V - Crypto VPN, C - CASA, P - Channel interface processor,
       B - BootP, S - Service selection gateway
       DN - Default Network, T - Tracking object
       L - TL1, E - OER, I - iEdge
       D1 - Dot1x Vlan Network, K - MWAM Route
       PP - PPP default route, MR - MRIPv6, SS - SSLVPN
       H - IPe Host, ID - IPe Domain Broadcast
       U - User GPRS, TE - MPLS Traffic-eng, LI - LIIN
       IR - ICMP Redirect
Codes in []: A - active, N - non-active, B - BFD-tracked, D - Not Tracked, P - permanent

Static local RIB for default

M  192.168.6.0/24 [200/0] via 172.16.25.2 [A]

*1:OSPF(AD110)経由で学習した経路より IBGP 経由で学習した経路を優先するため。

広告を非表示にする