DynagenでCCIEを目指す
20100530 BGP 基本設定
最終更新:
it_certification
-
view
目的
- BGPの基本的な設定を確認します。
構成
- 設定概要
- BGPによってルーティングします。
- 構成図

- netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] f0/0 = R2 f0/0 [[ROUTER R2]]
- 初期設定 R1
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 10.1.0.1 255.255.255.0 secondary ip address 10.1.1.1 255.255.255.0 secondary ip address 10.1.2.1 255.255.255.0 secondary ip address 10.1.3.1 255.255.255.0 secondary ip address 1.1.1.1 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.1.1 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 R2
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 10.2.0.1 255.255.255.0 secondary ip address 10.2.1.1 255.255.255.0 secondary ip address 10.2.2.1 255.255.255.0 secondary ip address 10.2.3.1 255.255.255.0 secondary ip address 2.2.2.2 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.1.2 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
検証1 BGPによるneighbor確立
- 設定の投入
R1, R2の間で、BGP neighborを確立させます。また、互いのloopback addressをnetworkコマンドによって通知します。
R1(config)#router bgp 1 R1(config-router)#neighbor 192.168.1.2 remote-as 2 R1(config-router)#network 1.1.1.1 mask 255.255.255.255 R2(config)#router bgp 2 R2(config-router)#neighbor 192.168.1.1 remote-as 1 R2(config-router)#network 2.2.2.2 mask 255.255.255.255
- 設定確認
設定確認を行います。show ip protocolでは、AS番号やneighborの一覧を確認できます。
R1#show ip protocols Routing Protocol is "bgp 1" <- R1のAS番号 Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set IGP synchronization is disabled Automatic route summarization is disabled Neighbor(s): <- neighborの一覧 Address FiltIn FiltOut DistIn DistOut Weight RouteMap 192.168.1.2 Maximum path: 1 Routing Information Sources: Gateway Distance Last Update 192.168.1.2 20 00:03:08 Distance: external 20 internal 200 local 200 R1#
show ip bgpコマンドでは、BGPテーブルが確認できます。
R1#show ip bgp BGP table version is 3, local router ID is 1.1.1.1 <- ルータID Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 0.0.0.0 0 32768 i <- ">"の記載があるのが最短ルート *> 2.2.2.2/32 192.168.1.2 0 0 2 i <- ">"の記載があるのが最短ルート R1#
show ip bgp summaryはBGPテーブルの概要が確認できます。また、「State/PfxRcd」に着目するとneighborが確立できたかどうかを確認できます。neighborが確立された状態ではBGPルートの数が表示され、未確立の状態ではIdle, Active等の状態が表示されます。
R1#show ip bgp summary BGP router identifier 1.1.1.1, local AS number 1 BGP table version is 3, main routing table version 3 2 network entries using 202 bytes of memory 2 path entries using 96 bytes of memory 2 BGP path attribute entries using 120 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP using 442 total bytes of memory BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.1.2 4 2 17 17 3 0 0 00:12:02 1 R1#
ルーティングテーブルには「B」の表記でルートが記載されます。
R1#show ip route bgp 2.0.0.0/32 is subnetted, 1 subnets B 2.2.2.2 [20/0] via 192.168.1.2, 00:12:50 R1#
検証2 再配送による通知
- 再配送の設定
R1のsecondary addressをR2に通知します。通知方法はconnectedを再配送します。
R1(config)#router bgp 1 R1(config-router)#redistribute connected
- BGPデータベースの確認
再配送されたルートがR2に通知された事を確認します。また、再配送によって通知されたルートのOriginが「? - imcomplete」になっている事も読み取れます。
R2#show ip route bgp 1.0.0.0/32 is subnetted, 1 subnets B 1.1.1.1 [20/0] via 192.168.1.1, 00:08:11 10.0.0.0/24 is subnetted, 8 subnets B 10.1.3.0 [20/0] via 192.168.1.1, 00:01:46 B 10.1.2.0 [20/0] via 192.168.1.1, 00:01:46 B 10.1.1.0 [20/0] via 192.168.1.1, 00:01:46 B 10.1.0.0 [20/0] via 192.168.1.1, 00:01:46 R2# R2# R2# R2#show ip bgp BGP table version is 11, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.1.1 0 0 1 i *> 2.2.2.2/32 0.0.0.0 0 32768 i *> 10.1.0.0/24 192.168.1.1 0 0 1 ? *> 10.1.1.0/24 192.168.1.1 0 0 1 ? *> 10.1.2.0/24 192.168.1.1 0 0 1 ? *> 10.1.3.0/24 192.168.1.1 0 0 1 ? r> 192.168.1.0 192.168.1.1 0 0 1 ? R2#
検証3 Originの変更
- Originの変更
「究めるBGP」によると、検証2のように「? - imcomplete」として他ISPにルートを通知するのは望ましい状態ではありません(実践経験がないのであまりよく分かりませんが…)。そこで、route-mapを使用して、Originを「i(IGP)」に変更します。
R1(config)#route-map SET_ORIGIN_IGP permit 10 R1(config-route-map)#set origin igp R1(config-route-map)#exit R1(config)# R1(config)# R1(config)#router bgp 1 R1(config-router)#redistribute connected route-map SET_ORIGIN_IGP
- Originの確認
originが「i(IGP)」に変わった事が確認できます。
R2#show ip bgp BGP table version is 16, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.1.1 0 0 1 i *> 2.2.2.2/32 0.0.0.0 0 32768 i *> 10.1.0.0/24 192.168.1.1 0 0 1 i *> 10.1.1.0/24 192.168.1.1 0 0 1 i *> 10.1.2.0/24 192.168.1.1 0 0 1 i *> 10.1.3.0/24 192.168.1.1 0 0 1 i r> 192.168.1.0 192.168.1.1 0 0 1 i
補足 パケットの確認
- debug ip bgp
debug ip bgpでbgp neighbor確立の様子を確認する事ができます。
R2#debug ip bgp BGP debugging is on R2# *Mar 1 00:54:02.295: BGP: Applying map to find origin for 2.2.2.2/32 *Mar 1 00:55:02.331: BGP: Applying map to find origin for 2.2.2.2/32 *Mar 1 00:55:26.707: BGP: 192.168.1.1 connection timed out 180236ms (last update) 180000ms (hold time) *Mar 1 00:55:26.707: BGP: 192.168.1.1 went from Established to Closing *Mar 1 00:55:26.711: %BGP-5-ADJCHANGE: neighbor 192.168.1.1 Down BGP Notification sent *Mar 1 00:55:26.711: %BGP-3-NOTIFICATION: sent to neighbor 192.168.1.1 4/0 (hold time expired) 0 bytes *Mar 1 00:55:26.711: BGP: 192.168.1.1 send message type 3, length (incl. header) 21 *Mar 1 00:55:27.711: BGP: 192.168.1.1 local error close after sending NOTIFICATION *Mar 1 00:55:28.711: BGPNSF state: 192.168.1.1 went from nsf_not_active to nsf_not_active *Mar 1 00:55:28.715: BGP: 192.168.1.1 went from Closing to Idle *Mar 1 00:55:28.715: BGP: 192.168.1.1 closing *Mar 1 00:55:48.719: BGP: 192.168.1.1 went from Idle to Active *Mar 1 00:55:48.719: BGP: 192.168.1.1 open active, delay 23541ms *Mar 1 00:56:02.359: BGP: Applying map to find origin for 2.2.2.2/32 *Mar 1 00:56:10.539: BGP: 192.168.1.1 passive open *Mar 1 00:56:10.539: BGP: 192.168.1.1 went from Active to Idle *Mar 1 00:56:10.539: BGP: 192.168.1.1 went from Idle to Connect *Mar 1 00:56:10.587: BGP: 192.168.1.1 rcv message type 1, length (excl. header) 26 *Mar 1 00:56:10.591: BGP: 192.168.1.1 rcv OPEN, version 4 *Mar 1 00:56:10.591: BGP: 192.168.1.1 went from Connect to OpenSent *Mar 1 00:56:10.595: BGP: 192.168.1.1 sending OPEN, version 4, my as: 2 *Mar 1 00:56:10.595: BGP: 192.168.1.1 rcv OPEN w/ OPTION parameter len: 16 *Mar 1 00:56:10.595: BGP: 192.168.1.1 rcvd OPEN w/ optional parameter type 2 (Capability) len 6 *Mar 1 00:56:10.599: BGP: 192.168.1.1 OPEN has CAPABILITY code: 1, length 4 *Mar 1 00:56:10.599: BGP: 192.168.1.1 OPEN has MP_EXT CAP for afi/safi: 1/1 *Mar 1 00:56:10.603: BGP: 192.168.1.1 rcvd OPEN w/ optional parameter type 2 (Capability) len 2 *Mar 1 00:56:10.603: BGP: 192.168.1.1 OPEN has CAPABILITY code: 128, length 0 *Mar 1 00:56:10.607: BGP: 192.168.1.1 OPEN has ROUTE-REFRESH capability(old) for all address-families *Mar 1 00:56:10.607: BGP: 192.168.1.1 rcvd OPEN w/ optional parameter type 2 (Capability) len 2 *Mar 1 00:56:10.611: BGP: 192.168.1.1 OPEN has CAPABILITY code: 2, length 0 *Mar 1 00:56:10.611: BGP: 192.168.1.1 OPEN has ROUTE-REFRESH capability(new) for all address-families *Mar 1 00:56:10.615: BGP: 192.168.1.1 went from OpenSent to OpenConfirm *Mar 1 00:56:10.615: BGP: 192.168.1.1 send message type 1, length (incl. header) 45 *Mar 1 00:56:10.643: BGP: 192.168.1.1 went from OpenConfirm to Established *Mar 1 00:56:10.647: %BGP-5-ADJCHANGE: neighbor 192.168.1.1 Up *Mar 1 00:57:02.411: BGP: Applying map to find origin for 2.2.2.2/32 *Mar 1 00:58:02.463: BGP: Applying map to find origin for 2.2.2.2/32
- debug ip bgp updates
debug ip bgp updatesで通知されたルートを確認する事ができます。
R2#debug ip bgp updates BGP updates debugging is on R2# *Mar 1 00:33:59.703: BGP(0): 192.168.1.1 rcvd UPDATE w/ attr: nexthop 192.168.1.1, origin ?, metric 0, path 1 *Mar 1 00:33:59.703: BGP(0): 192.168.1.1 rcvd 10.1.0.0/24 *Mar 1 00:33:59.707: BGP(0): 192.168.1.1 rcvd 10.1.1.0/24 *Mar 1 00:33:59.711: BGP(0): 192.168.1.1 rcvd 10.1.2.0/24 *Mar 1 00:33:59.715: BGP(0): 192.168.1.1 rcvd 10.1.3.0/24 *Mar 1 00:33:59.715: BGP(0): 192.168.1.1 rcvd 192.168.1.0/24 *Mar 1 00:33:59.715: BGP(0): Revise route installing 1 of 1 route for 10.1.0.0/24 -> 192.168.1.1 to main IP table *Mar 1 00:33:59.719: BGP(0): Revise route installing 1 of 1 route for 10.1.1.0/24 -> 192.168.1.1 to main IP table *Mar 1 00:33:59.723: BGP(0): Revise route installing 1 of 1 route for 10.1.2.0/24 -> 192.168.1.1 to main IP table *Mar 1 00:33:59.731: BGP(0): Revise route installing 1 of 1 route for 10.1.3.0/24 -> 192.168.1.1 to main IP table *Mar 1 00:33:59.735: BGP(0): Revise route installing 1 of 1 route for 192.168.1.0/24 -> 192.168.1.1 to main IP table *Mar 1 00:33:59.739: BGP(0): 192.168.1.1 computing updates, afi 0, neighbor version 5, table version 11, starting at 0.0.0.0 *Mar 1 00:33:59.739: BGP(0): 192.168.1.1 update run completed, afi 0, ran for 0ms, neighbor version 5, start version 11, throttled to 11 *Mar 1 00:33:59.839: BGP(0): Revise route installing 1 of 1 route for 192.168.1.0/24 -> 192.168.1.1 to main IP table
- パケットキャプチャによる確認
BGPの様子をパケットキャプチャします。TCP 179を使用して経路を交換したりneighborを確立したりしているのが分かります。IGPと違ってTCPを使用する仕様になっているのは、信頼性が求められるからです。

添付ファイル