BGP の練習

2023/01/14に公開

本エントリについて

Dynagen、Dynamips を使って、BGP を練習します。
Dynagen、Dynamips の利用環境はすでに整っているものとします。

    [[ROUTER r1]]
        model = 3725
        console = 2001
        f0/0 = NIO_tap:tap0
        s1/2 = r2 s1/2
        s1/3 = r3 s1/2
    [[ROUTER r2]]
        model = 3725
        console = 2002
        f0/0 = NIO_udp:30000:127.0.0.1:20000
        s1/0 = r4 s1/1
    [[ROUTER r3]]
        model = 3725
        console = 2003
        f0/0 = NIO_udp:30001:127.0.0.1:20001
        s1/0 = r2 s1/1
    [[ROUTER r4]]
        model = 3725
        console = 2004
        f0/0 = NIO_udp:30002:127.0.0.1:20002
        s1/0 = r3 s1/1

事前設定

事前設定として、各ルータで以下のように設定します。
手順については割愛します。

r1#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.2.0.254      YES NVRAM  up                    up
FastEthernet0/1            unassigned      YES NVRAM  administratively down down
Serial1/0                  unassigned      YES NVRAM  administratively down down
Serial1/1                  unassigned      YES NVRAM  administratively down down
Serial1/2                  172.16.0.253    YES NVRAM  up                    up
Serial1/3                  172.16.0.249    YES NVRAM  up                    up
Loopback0                  1.1.1.1         YES NVRAM  up                    up

r1#show cdp neigh
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
r2               Ser 1/2            145         R S I     3725      Ser 1/2
r3               Ser 1/3            173         R S I     3725      Ser 1/2

r1#show ip proto
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 1.1.1.1
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    1.1.1.1 0.0.0.0 area 0
    10.2.0.0 0.0.0.255 area 0
 Reference bandwidth unit is 100 mbps
  Passive Interface(s):
    FastEthernet0/0
  Routing Information Sources:
    Gateway         Distance      Last Update
  Distance: (default is 110)
r2#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.2.1.254      YES NVRAM  up                    up
FastEthernet0/1            unassigned      YES NVRAM  administratively down down
Serial1/0                  172.16.1.253    YES NVRAM  up                    up
Serial1/1                  172.16.3.254    YES NVRAM  up                    up
Serial1/2                  172.16.0.254    YES NVRAM  up                    up
Serial1/3                  unassigned      YES NVRAM  administratively down down
Loopback0                  2.2.2.2         YES NVRAM  up                    up

r2#show cdp neigh
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
r3               Ser 1/1            134         R S I     3725      Ser 1/0
r1               Ser 1/2            120         R S I     3725      Ser 1/2
r4               Ser 1/0            162         R S I     3725      Ser 1/1

r2#show ip proto
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 2.2.2.2
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    2.2.2.2 0.0.0.0 area 0
    10.2.1.0 0.0.0.255 area 0
    172.16.1.0 0.0.0.255 area 0
    172.16.3.0 0.0.0.255 area 0
 Reference bandwidth unit is 100 mbps
  Passive Interface(s):
    FastEthernet0/0
  Routing Information Sources:
    Gateway         Distance      Last Update
    4.4.4.4              110      00:00:46
    3.3.3.3              110      00:01:30
  Distance: (default is 110)

r3#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.2.2.254      YES NVRAM  up                    up
FastEthernet0/1            unassigned      YES NVRAM  administratively down down
Serial1/0                  172.16.3.253    YES NVRAM  up                    up
Serial1/1                  172.16.2.254    YES NVRAM  up                    up
Serial1/2                  172.16.0.250    YES NVRAM  up                    up
Serial1/3                  unassigned      YES NVRAM  administratively down down
Loopback0                  3.3.3.3         YES NVRAM  up                    up

r3#show cdp neigh
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
r2               Ser 1/0            151         R S I     3725      Ser 1/1
r1               Ser 1/2            154         R S I     3725      Ser 1/3
r4               Ser 1/1            166         R S I     3725      Ser 1/0

r3#show ip proto
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 3.3.3.3
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    3.3.3.3 0.0.0.0 area 0
    10.2.2.0 0.0.0.255 area 0
    172.16.2.0 0.0.0.255 area 0
    172.16.3.0 0.0.0.255 area 0
 Reference bandwidth unit is 100 mbps
  Passive Interface(s):
    FastEthernet0/0
  Routing Information Sources:
    Gateway         Distance      Last Update
    4.4.4.4              110      00:02:13
    2.2.2.2              110      00:02:50
  Distance: (default is 110)

r4#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.2.3.254      YES NVRAM  up                    up
FastEthernet0/1            unassigned      YES NVRAM  administratively down down
Serial1/0                  172.16.2.253    YES NVRAM  up                    up
Serial1/1                  172.16.1.254    YES NVRAM  up                    up
Serial1/2                  unassigned      YES NVRAM  administratively down down
Serial1/3                  unassigned      YES NVRAM  administratively down down
Loopback0                  4.4.4.4         YES NVRAM  up                    up

r4#show cdp neigh
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
r2               Ser 1/1            128         R S I     3725      Ser 1/0
r3               Ser 1/0            126         R S I     3725      Ser 1/1

r4#show ip proto
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 4.4.4.4
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    4.4.4.4 0.0.0.0 area 0
    10.2.3.0 0.0.0.255 area 0
    172.16.1.0 0.0.0.255 area 0
    172.16.2.0 0.0.0.255 area 0
 Reference bandwidth unit is 100 mbps
  Passive Interface(s):
    FastEthernet0/0
  Routing Information Sources:
    Gateway         Distance      Last Update
    2.2.2.2              110      00:02:47
    3.3.3.3              110      00:02:57
  Distance: (default is 110)

BGP の有効化

eBGP は異なるAS間、iBGP は同じAS内の接続です。

eBGP

r1 で BGPを有効化します。
BGPでは明示的にピアルータを指定します。

r1(config)#router bgp 65001
r1(config-router)#neigh 172.16.0.254 remote-as 65002
r1(config-router)#network 10.2.0.0 mask 255.255.255.0

状態を確認します。

r1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 65001
BGP table version is 1, main routing table version 1
1 network entries using 120 bytes of memory
1 path entries using 52 bytes of memory
2/0 BGP path/bestpath attribute entries using 248 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 420 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.254    4 65002       0       0        0    0    0 never    Idle

r1#show ip bgp
BGP table version is 1, local router ID is 1.1.1.1
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
*  10.2.0.0/24      0.0.0.0                  0         32768 i

r2 で BGPを有効化します。

r2(config)#router bgp 65002
r2(config-router)#neighbor 172.16.0.253 remote-as 65001
r2(config-router)#network 10.2.1.0 mask 255.255.255.0

状態を確認します。

r2#show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 65002
BGP table version is 1, main routing table version 1
1 network entries using 120 bytes of memory
1 path entries using 52 bytes of memory
2/0 BGP path/bestpath attribute entries using 248 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 420 total bytes of memory
BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.253    4 65001       0       0        0    0    0 never    Idle

r2#show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 65002
BGP table version is 3, main routing table version 3
2 network entries using 240 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 772 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
172.16.0.253    4 65001       4       4        3    0    0 00:00:48        1

r2#show ip bgp
BGP table version is 3, 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
*> 10.2.0.0/24      172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 00:00:34

r1でも確認します。

r1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 65001
BGP table version is 3, main routing table version 3
2 network entries using 240 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 772 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
172.16.0.254    4 65002       6       6        3    0    0 00:02:51        1

r1#show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*> 10.2.1.0/24      172.16.0.254             0             0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 2 subnets
B       10.2.1.0 [20/0] via 172.16.0.254, 00:02:36

iBGP

r2 でピア設定を追加します。MD5認証についても設定しています。

r2(config)#router bgp 65002
r2(config-router)#neighbor 172.16.3.253 remote-as 65002
r2(config-router)#neighbor 172.16.3.253 password cisco

r3 でBGPを有効化します。r2 と同様に、MD5認証についても設定しています。

r3(config)#router bgp 65002
r3(config-router)#neighbor 172.16.3.254 remote-as 65002
r3(config-router)#neighbor 172.16.3.254 password cisco
r3(config-router)#network 10.2.2.0 mask 255.255.255.0

状態を確認します。
トポロジーテーブルの r(RIB-failure) は、他のルーティングプロトコル(ここではospf)で学習した経路を表します。

r3#show ip bgp summ
BGP router identifier 3.3.3.3, local AS number 65002
BGP table version is 4, main routing table version 4
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 1068 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.3.254    4 65002       9       8        4    0    0 00:03:42        2

r3#show ip bgp
BGP table version is 4, local router ID is 3.3.3.3
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
* i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i

r3#show ip route bgp

r2でも状態を確認します。

r2#show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 65002
BGP table version is 5, main routing table version 5
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 3 (at peak 3) using 96 bytes of memory
BGP using 1132 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.253    4 65001      13      14        5    0    0 00:09:43        1
172.16.3.253    4 65002       9      10        5    0    0 00:04:55        1

r2#show ip bgp
BGP table version is 5, 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
*> 10.2.0.0/24      172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i
r>i10.2.2.0/24      172.16.3.253             0    100      0 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 00:09:23

r1 で状態を確認します。

r1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 65001
BGP table version is 4, main routing table version 4
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 1068 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.254    4 65002      15      14        4    0    0 00:10:31        2

r1#show ip bgp
BGP table version is 4, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*> 10.2.1.0/24      172.16.0.254             0             0 65002 i
*> 10.2.2.0/24      172.16.0.254                           0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 3 subnets
B       10.2.1.0 [20/0] via 172.16.0.254, 00:10:11
B       10.2.2.0 [20/0] via 172.16.0.254, 00:05:47

loopback インタフェースの利用

ピアルータのloopbackインタフェースのアドレスを、ピアルータのアドレスとして指定します。
送信元アドレスとして、自身のloopbackインタフェースのアドレスを利用します。

r3(config)#router bgp 65002
r3(config-router)#neighbor 4.4.4.4 remote-as 65002
r3(config-router)#neighbor 4.4.4.4 update-source loopback 0

r4 でも同様に設定します。

r4(config)#router bgp 65002
r4(config-router)#neighbor 3.3.3.3 remote-as 65002
r4(config-router)#neighbor 3.3.3.3 update-source loopback 0
r4(config-router)#network 10.2.3.0 mask 255.255.255.0

r4 で状態を確認します。

r4#show ip bgp summ
BGP router identifier 4.4.4.4, local AS number 65002
BGP table version is 4, main routing table version 4
2 network entries using 240 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 748 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
3.3.3.3         4 65002       5       5        4    0    0 00:00:57        1

r4#show ip bgp
BGP table version is 4, local router ID is 4.4.4.4
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
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp

r3 で状態を確認します。

r3#show ip bgp summ
BGP router identifier 3.3.3.3, local AS number 65002
BGP table version is 6, main routing table version 6
4 network entries using 480 bytes of memory
4 path entries using 208 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 1240 total bytes of memory
BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4 65002       6       6        6    0    0 00:01:33        1
172.16.3.254    4 65002      16      15        6    0    0 00:10:12        2

r3#show ip bgp
BGP table version is 6, local router ID is 3.3.3.3
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
* i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp

r2 で状態を確認します。

r2#show ip bgp
BGP table version is 5, 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
*> 10.2.0.0/24      172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i
r>i10.2.2.0/24      172.16.3.253             0    100      0 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 00:15:23

r1 で状態を確認します。

r1#show ip bgp
BGP table version is 4, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*> 10.2.1.0/24      172.16.0.254             0             0 65002 i
*> 10.2.2.0/24      172.16.0.254                           0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 3 subnets
B       10.2.1.0 [20/0] via 172.16.0.254, 00:16:05
B       10.2.2.0 [20/0] via 172.16.0.254, 00:11:40

ルートリフレクタ

iBGPでは、iGBPスプリットホライズンにより、ピアから入手した経路を他のピアにアドバタイズしません。
ルートリフレクタを利用することで、アドバタイズを他のピアへ転送するようになります。
フルメッシュのピアを張らなくても、ルートリフレクタとのピア設定だけですむようになります。

r3(config)#router bgp 65002
r3(config-router)#neighbor 172.16.3.254 route-reflector-client
r3(config-router)#neighbor 4.4.4.4 route-reflector-client

状態を確認します。

r3#show ip bgp summ
BGP router identifier 3.3.3.3, local AS number 65002
BGP table version is 12, main routing table version 12
4 network entries using 480 bytes of memory
4 path entries using 208 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1240 total bytes of memory
BGP activity 4/0 prefixes, 7/3 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4 65002      16      18       12    0    0 00:01:51        1
172.16.3.254    4 65002      27      28       12    0    0 00:01:55        2

r3#show ip bgp
BGP table version is 12, local router ID is 3.3.3.3
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
* i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp

r4 で状態を確認します。

r4#show ip bgp summ
BGP router identifier 4.4.4.4, local AS number 65002
BGP table version is 9, main routing table version 9
3 network entries using 360 bytes of memory
3 path entries using 156 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP rrinfo 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
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 944 total bytes of memory
BGP activity 4/1 prefixes, 4/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
3.3.3.3         4 65002      19      17        9    0    0 00:02:43        2

r4#show ip bgp
BGP table version is 9, local router ID is 4.4.4.4
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
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp

r2 で状態を確認します。

r2#show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 65002
BGP table version is 10, main routing table version 10
4 network entries using 480 bytes of memory
4 path entries using 208 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP rrinfo entries using 24 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
Bitfield cache entries: current 3 (at peak 4) using 96 bytes of memory
BGP using 1328 total bytes of memory
BGP activity 4/0 prefixes, 5/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.253    4 65001      26      30       10    0    0 00:22:47        1
172.16.3.253    4 65002      30      29       10    0    0 00:03:19        2

r2#show ip bgp
BGP table version is 10, 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
*> 10.2.0.0/24      172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i
r>i10.2.2.0/24      172.16.3.253             0    100      0 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 00:22:28

OSPFでAS内に 172.16.0.252/30 の経路を追加します。

r2(config)#router ospf 1
r2(config-router)#network 172.16.0.252 0.0.0.3 area 0
r2(config-router)#passive-interface s1/2

r3 で状態を確認します。

r3#show ip bgp
BGP table version is 13, local router ID is 3.3.3.3
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 00:00:40

r4 で状態を確認します。

r4#show ip bgp
BGP table version is 10, local router ID is 4.4.4.4
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 00:01:03

疎通確認を実施します。

r4#ping
Protocol [ip]:
Target IP address: 10.2.0.254
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.2.3.254
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.0.254, timeout is 2 seconds:
Packet sent with a source address of 10.2.3.254
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/38/44 ms

ピアグループ

事前設定として、r2 でピア設定を追加します。

r2(config)#router bgp 65002
r2(config-router)#neighbor 4.4.4.4 remote-as 65002
r2(config-router)#neighbor 4.4.4.4 update-source loopback 0

状態を確認します。

r2#show ip bgp summ
BGP router identifier 2.2.2.2, local AS number 65002
BGP table version is 10, main routing table version 10
4 network entries using 480 bytes of memory
4 path entries using 208 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP rrinfo entries using 24 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
Bitfield cache entries: current 3 (at peak 4) using 96 bytes of memory
BGP using 1328 total bytes of memory
BGP activity 4/0 prefixes, 5/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4 65002       0       0        0    0    0 never    Active
172.16.0.253    4 65001      48      52       10    0    0 00:44:05        1
172.16.3.253    4 65002      52      50       10    0    0 00:24:37        2

r4 でピアグループを利用してピア設定を追加します。

r4(config)#router bgp 65002
r4(config-router)#neighbor ccna peer-group
r4(config-router)#neighbor ccna remote-as 65002
r4(config-router)#neighbor ccna update-source loopback 0
r4(config-router)#neighbor 2.2.2.2 peer-group ccna

状態を確認します。

r4#show ip bgp summ
BGP router identifier 4.4.4.4, local AS number 65002
BGP table version is 12, main routing table version 12
4 network entries using 480 bytes of memory
6 path entries using 312 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP rrinfo entries using 24 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
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1368 total bytes of memory
BGP activity 5/1 prefixes, 7/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.2.2.2         4 65002       6       5       12    0    0 00:00:16        2
3.3.3.3         4 65002      44      41       12    0    0 00:26:18        3

r4#show ip bgp
BGP table version is 12, local router ID is 4.4.4.4
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
* i                 172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      2.2.2.2                  0    100      0 i
r i                 172.16.3.254             0    100      0 i
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 00:00:27

r2 で状態を確認します。

r2#show ip bgp summ
BGP router identifier 2.2.2.2, local AS number 65002
BGP table version is 11, main routing table version 11
4 network entries using 480 bytes of memory
5 path entries using 260 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP rrinfo entries using 24 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
Bitfield cache entries: current 3 (at peak 4) using 96 bytes of memory
BGP using 1380 total bytes of memory
BGP activity 4/0 prefixes, 6/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4 65002       5       6       11    0    0 00:00:55        1
172.16.0.253    4 65001      50      54       11    0    0 00:46:28        1
172.16.3.253    4 65002      55      53       11    0    0 00:27:00        2

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
*> 10.2.0.0/24      172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i
r>i10.2.2.0/24      172.16.3.253             0    100      0 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i
r i                 4.4.4.4                  0    100      0 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 00:46:11

r3 で状態を確認します。

r3#show ip bgp summ
BGP router identifier 3.3.3.3, local AS number 65002
BGP table version is 13, main routing table version 13
4 network entries using 480 bytes of memory
4 path entries using 208 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1240 total bytes of memory
BGP activity 4/0 prefixes, 7/3 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4 65002      43      46       13    0    0 00:28:10        1
172.16.3.254    4 65002      54      56       13    0    0 00:28:13        2

r3#show ip bgp
BGP table version is 13, local router ID is 3.3.3.3
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 00:13:04

パスアトリビュート

練習を進める前に、eBGP 接続を追加します。

r1(config)#router bgp 65001
r1(config-router)#neighbor 172.16.0.250 remote-as 65002
r1(config-router)#network 10.2.0.0 mask 255.255.255.0

状態を確認します。

r1#show ip bgp summ
BGP router identifier 1.1.1.1, local AS number 65001
BGP table version is 7, main routing table version 7
4 network entries using 480 bytes of memory
4 path entries using 208 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 1240 total bytes of memory
BGP activity 5/1 prefixes, 5/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.250    4 65002       0       0        0    0    0 never    Active
172.16.0.254    4 65002      73      69        7    0    0 01:05:18        3
r3(config)#router bgp 65002
r3(config-router)#neighbor 172.16.0.249 remote-as 65001
r3#show ip bgp summ
BGP router identifier 3.3.3.3, local AS number 65002
BGP table version is 14, main routing table version 14
4 network entries using 480 bytes of memory
5 path entries using 260 bytes of memory
5/3 BGP path/bestpath attribute entries using 620 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
Bitfield cache entries: current 2 (at peak 2) using 64 bytes of memory
BGP using 1448 total bytes of memory
BGP activity 4/0 prefixes, 8/3 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4 65002      64      68       14    0    0 00:49:33        1
172.16.0.249    4 65001       7       6       14    0    0 00:00:06        1
172.16.3.254    4 65002      75      78       14    0    0 00:49:37        2

r3#show ip bgp
BGP table version is 14, local router ID is 3.3.3.3
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
*> 10.2.0.0/24      172.16.0.249             0             0 65001 i
* i                 172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.249, 00:00:57

r1 で状態を確認します。

r1#show ip bgp summ
BGP router identifier 1.1.1.1, local AS number 65001
BGP table version is 7, main routing table version 7
4 network entries using 480 bytes of memory
7 path entries using 364 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 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
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 1396 total bytes of memory
BGP activity 5/1 prefixes, 8/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.250    4 65002       7       8        7    0    0 00:01:14        3
172.16.0.254    4 65002      78      74        7    0    0 01:10:12        3

r1#show ip bgp
BGP table version is 7, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*  10.2.1.0/24      172.16.0.250                           0 65002 i
*>                  172.16.0.254             0             0 65002 i
*  10.2.2.0/24      172.16.0.250             0             0 65002 i
*>                  172.16.0.254                           0 65002 i
*  10.2.3.0/24      172.16.0.250                           0 65002 i
*>                  172.16.0.254                           0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.1.0 [20/0] via 172.16.0.254, 01:09:54
B       10.2.2.0 [20/0] via 172.16.0.254, 00:50:56
B       10.2.3.0 [20/0] via 172.16.0.254, 00:50:26
r4#show ip bgp summ
BGP router identifier 4.4.4.4, local AS number 65002
BGP table version is 12, main routing table version 12
4 network entries using 480 bytes of memory
6 path entries using 312 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP rrinfo entries using 24 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
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1368 total bytes of memory
BGP activity 5/1 prefixes, 7/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.2.2.2         4 65002      31      30       12    0    0 00:25:13        2
3.3.3.3         4 65002      70      66       12    0    0 00:51:15        3

r4#show ip bgp
BGP table version is 12, local router ID is 4.4.4.4
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
* i                 172.16.0.249             0    100      0 65001 i
r>i10.2.1.0/24      2.2.2.2                  0    100      0 i
r i                 172.16.3.254             0    100      0 i
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 00:25:20

Weight

Weightの設定を変更してみます。

r1(config)#access-list 1 permit 10.2.3.0 0.0.0.255
r1(config)#route-map WEIGHT permit 10
r1(config-route-map)#match ip address 1
r1(config-route-map)#set weight 100
r1(config-route-map)#route-map WEIGHT permit 20

r1(config-route-map)#router bgp 65001
r1(config-router)#neighbor 172.16.0.250 route-map WEIGHT in

r1#clear ip bgp 172.16.0.250 soft in

状態を確認します。

r1#show ip bgp
BGP table version is 8, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*  10.2.1.0/24      172.16.0.250                           0 65002 i
*>                  172.16.0.254             0             0 65002 i
*  10.2.2.0/24      172.16.0.250             0             0 65002 i
*>                  172.16.0.254                           0 65002 i
*> 10.2.3.0/24      172.16.0.250                         100 65002 i
*                   172.16.0.254                           0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.1.0 [20/0] via 172.16.0.254, 06:18:59
B       10.2.2.0 [20/0] via 172.16.0.254, 06:00:01
B       10.2.3.0 [20/0] via 172.16.0.250, 00:00:32

Local Preference

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
* i10.2.0.0/24      172.16.0.249             0    100      0 65001 i
*>                  172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i
r>i10.2.2.0/24      172.16.3.253             0    100      0 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i
r i                 4.4.4.4                  0    100      0 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 06:29:37
r3#show ip bgp
BGP table version is 14, local router ID is 3.3.3.3
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
*> 10.2.0.0/24      172.16.0.249             0             0 65001 i
* i                 172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.249, 05:21:32
r4#show ip bgp
BGP table version is 12, local router ID is 4.4.4.4
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
* i                 172.16.0.249             0    100      0 65001 i
r>i10.2.1.0/24      2.2.2.2                  0    100      0 i
r i                 172.16.3.254             0    100      0 i
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 05:44:01

Local Reference の値を変更してみます。

r3(config)#access-list 1 permit 10.2.0.0 0.0.0.255
r3(config)#route-map LOCALPREF permit 10
r3(config-route-map)#match ip address 1
r3(config-route-map)#set local-preference 300
r3(config-route-map)#route-map LP permit 20

r3(config-route-map)#router bgp 65002
r3(config-router)#neighbor 172.16.0.249 route-map LOCALPREF in

r3#clear ip bgp 172.16.0.249 soft in

状態を確認します。

r3#show ip bgp
BGP table version is 16, local router ID is 3.3.3.3
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
*> 10.2.0.0/24      172.16.0.249             0    300      0 65001 i
* i                 172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.249, 00:05:14
r2#show ip bgp
BGP table version is 13, 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
* i10.2.0.0/24      172.16.0.249             0    300      0 65001 i
*>                  172.16.0.253             0             0 65001 i
*> 10.2.1.0/24      0.0.0.0                  0         32768 i
r>i10.2.2.0/24      172.16.3.253             0    100      0 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i
r i                 4.4.4.4                  0    100      0 i

r2#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [20/0] via 172.16.0.253, 06:41:16
r4#show ip bgp
BGP table version is 14, local router ID is 4.4.4.4
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
*>i10.2.0.0/24      172.16.0.253             0    100      0 65001 i
* i                 172.16.0.249             0    300      0 65001 i
r>i10.2.1.0/24      2.2.2.2                  0    100      0 i
r i                 172.16.3.254             0    100      0 i
r>i10.2.2.0/24      3.3.3.3                  0    100      0 i
*> 10.2.3.0/24      0.0.0.0                  0         32768 i

r4#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 05:56:50

MED

MED の値を変更してみます。

r2(config)#access-list 11 permit 10.2.1.0 0.0.0.255
r2(config)#access-list 12 permit 10.2.2.0 0.0.0.255
r2(config)#route-map MED permit 10
r2(config-route-map)#match ip address 11
r2(config-route-map)#set metric 10
r2(config-route-map)#route-map MED permit 20
r2(config-route-map)#match ip address 21
r2(config-route-map)#set metric 20
r2(config-route-map)#route-map MED permit 30

r2(config)#router bgp 65002
r2(config-router)#neighbor 172.16.0.253 route-map MED out

r2#clear ip bgp 172.16.0.253 soft out

不要な設定を削除した後、状態を確認します。

r1(config)#router bgp 65001
r1(config-router)#no neighbor 172.16.0.250 route-map WEIGHT in

r1#clear ip bgp 172.16.0.250 soft in

r1#show ip bgp
BGP table version is 11, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*> 10.2.1.0/24      172.16.0.250                           0 65002 i
*                   172.16.0.254            10             0 65002 i
*> 10.2.2.0/24      172.16.0.250             0             0 65002 i
*                   172.16.0.254            20             0 65002 i
*> 10.2.3.0/24      172.16.0.250                           0 65002 i
*                   172.16.0.254            20             0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.1.0 [20/0] via 172.16.0.250, 00:03:18
B       10.2.2.0 [20/0] via 172.16.0.250, 00:03:18
B       10.2.3.0 [20/0] via 172.16.0.250, 00:42:11

r3 で設定変更してみます。

r3(config)#access-list 11 permit 10.2.1.0 0.0.0.255
r3(config)#access-list 12 permit 10.2.2.0 0.0.0.255
r3(config)#route-map MED permit 10
r3(config-route-map)#match ip address 11
r3(config-route-map)#set metric 20
r3(config-route-map)#route-map MED permit 20
r3(config-route-map)#match ip address 21
r3(config-route-map)#set metric 10
r3(config-route-map)#route-map MED permit 30

r3(config-route-map)#router bgp 65002
r3(config-router)#neighbor 172.16.0.249 route-map MED out

r3#clear ip bgp 172.16.0.249 soft out

r1 で状態を確認します。

r1#show ip bgp
BGP table version is 14, local router ID is 1.1.1.1
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
*> 10.2.0.0/24      0.0.0.0                  0         32768 i
*  10.2.1.0/24      172.16.0.250            20             0 65002 i
*>                  172.16.0.254            10             0 65002 i
*> 10.2.2.0/24      172.16.0.250            10             0 65002 i
*                   172.16.0.254            20             0 65002 i
*> 10.2.3.0/24      172.16.0.250            10             0 65002 i
*                   172.16.0.254            20             0 65002 i

r1#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.1.0 [20/10] via 172.16.0.254, 00:00:22
B       10.2.2.0 [20/10] via 172.16.0.250, 00:00:22
B       10.2.3.0 [20/10] via 172.16.0.250, 00:00:22

AS PATH

r1 で設定を変更してみます。

r1(config)#ip prefix-list PRFLIST permit 10.2.0.0/24
r1(config)#route-map ASPATH permit 10
r1(config-route-map)#match ip address prefix-list PRFLIST
r1(config-route-map)#set as-path prepend 65001 65001
r1(config-route-map)#route-map ASPATH permit 20

r1(config-route-map)#router bgp 65001
r1(config-router)#neighbor 172.16.0.250 route-map ASPATH out

r1#clear ip bgp 172.16.0.250 soft out

r3 で不要な設定を削除して、状態を確認してみます。

r3(config)#router bgp 65002
r3(config-router)#no neighbor 172.16.0.249 route-map LOCALPREF in

r3#clear ip bgp 172.16.0.249 soft in

r3#show ip bgp
BGP table version is 18, local router ID is 3.3.3.3
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
*  10.2.0.0/24      172.16.0.249             0             0 65001 65001 65001 i
*>i                 172.16.0.253             0    100      0 65001 i
r>i10.2.1.0/24      172.16.3.254             0    100      0 i
*> 10.2.2.0/24      0.0.0.0                  0         32768 i
r>i10.2.3.0/24      4.4.4.4                  0    100      0 i

r3#show ip route bgp
     10.0.0.0/24 is subnetted, 4 subnets
B       10.2.0.0 [200/0] via 172.16.0.253, 00:02:11

まとめ

Dynagen、Dynamips を使って、BGP を練習しました。

GitHubで編集を提案

Discussion