IPv4 使いのための IPv6 入門

提供: hkatou_Lab
2024年5月14日 (火) 11:52時点におけるHkatou (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

i!!1981 年に IPv6 が最初にプロトコルとして制定されてから、40 年以上経過していますが、まだまだ苦手に思っている人が多いのではないかと思います。

このページでは IPv4 が使える人向けに、ISP の NW で IPv6 を導入・設計・運用するための情報を扱います。

扱うプロトコル

BGP

OSPFv3

ICMPv6

ドキュメント

まずは以下を読みましょう。無料版もあります。

プロフェッショナルIPv6 第2版


内容は網羅的になっていますので、最初からすべて読まなくても大丈夫です。

まずは目次からどのような機能があるのか、ざっと把握するようにして、辞書を引いて活用できるような状態を目指します。

ラボ

エンジニアであれば、検証環境で実際に動作するか、実証できるようにすることが求められます。

EVE-NG や CML , 実機を用いて検証できる環境を整えましょう。

ドキュメントを読んでも思ったようには動かせません。設定した通りに動きます。(動かせない)

IP アドレッシング

文書用 IP アドレスを元に、サブネット分割して各ホストに割り当てました。

IPv4

  • 192.0.2.0/24 (TEST-NET-1) : LAN 用プライベート IP
  • 198.51.100.0/24 (TEST-NET-2) : 内部用グローバル IP
  • 203.0.113.0/24 (TEST-NET-3) : 外部用グローバル IP

IPv6

  • 2001:db8::/32
host Interface IPv4 Network IPv4 Host BGP IPv4 広報アドレス IPv6 Network IPv6 Host BGP IPv6 広報アドレス
BGP-PE Lo0 203.0.113.88/32 .88 - 2001:db8:203:88::/128 ::88 -
Gi1 203.0.113.0/30 .1 203.0.113.0/24 2001:db8:203::/64 :1 2001:db8:203::/48
BGP-CE Gi4 .2 198.51.100.0/24 :2 2001:db8:192::/48

2001:db8:198::/48

2001:db8:254::/48

Lo0 198.51.100.254/32 .254 - 2001:db8:254::/128 :254 -
Gi1 192.0.2.0/30 .1 - 2001:db8:192::/64 :1 -
Core Gi4 .2 - :2 -
Lo0 198.51.100.253/32 .253 - 2001:db8:254::/128 :253 -
Gi1 198.51.100.0/25 .1 - 2001:db8:198::/64 :1 -
CPE Gi4 .11 - :11 -

構成図

この例では CSR1000V IOS-XE 17.03.04a を使用しています。

20240514_IPv6_Lab_Diagram

要件

BGP-PE Lo0 と CPE Gi4 が IPv4 と IPv6 で通信できること。

どのコマンドで正常性が確認できるか洗い出すこと。

サンプルコンフィグ

BGP コンフィグ

BGP 要件

IPv4 IPv6 デュアル スタックで設定します。

疎通するために最低限の設定を行います。

  • グローバル IP を BGP で対向 AS に広報します

IPv4 IPv6 コンフィギュレーション比較

IPv4 vs IPv6
host IPv4 IPv6 備考
BGP-PE ip routing

!

interface GigabitEthernet1

description BGP-CE_Gi4

ip address 203.0.113.1 255.255.255.252


!

router bgp 203

bgp router-id 203.0.113.88

bgp log-neighbor-changes

neighbor 203.0.113.2 remote-as 198

!

address-family ipv4

  network 0.0.0.0

  network 203.0.113.0

  no neighbor 2001:DB8:203::2 activate

  neighbor 203.0.113.2 activate

  neighbor 203.0.113.2 soft-reconfiguration inbound


  default-information originate

exit-address-family

!

ip route 0.0.0.0 0.0.0.0 Null0 254

ip route 203.0.113.0 255.255.255.0 Null0 254

ipv6 unicast-routing

!

interface GigabitEthernet1

description BGP-CE_Gi4

ipv6 address 2001:DB8:203::1/64

ipv6 enable

ipv6 nd ra suppress all

!

router bgp 203

bgp router-id 203.0.113.88

bgp log-neighbor-changes

neighbor 2001:DB8:203::2 remote-as 198

!

address-family ipv6


  default-information originate

  network ::/0

  network 2001:DB8:203::/48

  neighbor 2001:DB8:203::2 activate

  neighbor 2001:DB8:203::2 soft-reconfiguration inbound

exit-address-family

!

ipv6 route 2001:DB8:203::/48 Null0 254

ipv6 route ::/0 Null0 254

BGP-CE ip routing

!

interface GigabitEthernet4

description BGP-PE_Gi1

ip address 203.0.113.2 255.255.255.252


!

router bgp 198

bgp router-id 198.51.100.254

bgp log-neighbor-changes

neighbor 203.0.113.1 remote-as 203

!

address-family ipv4

  network 198.51.100.0


  no neighbor 2001:DB8:203::1 activate

  neighbor 203.0.113.1 activate

  neighbor 203.0.113.1 soft-reconfiguration inbound

exit-address-family

!

ip route 198.51.100.0 255.255.255.0 Null0 254


ipv6 unicast-routing

!

interface GigabitEthernet4

description BGP-PE_Gi1

ipv6 address 2001:DB8:203::2/64

ipv6 enable

ipv6 nd ra suppress all

!

router bgp 198

bgp router-id 198.51.100.254

bgp log-neighbor-changes

neighbor 2001:DB8:203::1 remote-as 203

!

address-family ipv6

  network 2001:DB8:192::/48

  network 2001:DB8:198::/48

  network 2001:DB8:254::/48

  neighbor 2001:DB8:203::1 activate

  neighbor 2001:DB8:203::1 soft-reconfiguration inbound

exit-address-family

!

ipv6 route 2001:DB8:192::/48 Null0 254

ipv6 route 2001:DB8:198::/48 Null0 254

ipv6 route 2001:DB8:254::/48 Null0 254

コンフィギュレーションのポイント

ipv6 nd ra suppress all

ルータ間でルーティング プロトコルを動作させる場合、ルータを広告する ICMPv6 RA (ルータ アドバタイズメント) は無効化しましょう。

  • EVPN で RFC5549 を実装したい場合は、あえて有効化する場合もあります

address-family ipv6

デュアル スタックの IPv6 で BGP ピアを確立させる場合、ここで設定します。

IPv4 BGP ピアで IPv6 ネットワークを受信・広報することも可能と思われますが、v6 ルーティングに v4 ネクストホップを使うのは特別な設定が要ると思われます。

商用でも筆者は見たことがありません。(逆はあり)

ipv6 route <内部ルート> Null0 254

BGP でルートを広報する場合、IGP でルートを持っている (=自 AS でルートを保持している) ことが必要です。

この例では Null0 インターフェース宛のルートを持つことで、常に IGP でルートを持つように設定しています。

OSPF コンフィグ

要件

OSPF で LAN のルートを送受信します。

  • OSPFv2 で IPv4
  • OSPFv3 で IPv6

IPv4 IPv6 コンフィギュレーション比較

IPv4 vs IPv6
host IPv4 IPv6 備考
BGP-CE ip routing

!

interface GigabitEthernet1

description Core_Gi4

ip address 192.0.2.1 255.255.255.252



ip ospf network point-to-point

!

router ospf 1

router-id 198.51.100.254

passive-interface default

no passive-interface GigabitEthernet1

network 192.0.2.0 0.0.0.3 area 0.0.0.0

network 198.51.100.254 0.0.0.0 area 0.0.0.0

default-information originate

ipv6 unicast-routing

!

interface GigabitEthernet1

description Core_Gi4

ipv6 address 2001:DB8:192::1/64

ipv6 enable

ipv6 nd ra suppress all

ipv6 ospf 1 area 0.0.0.0

ipv6 ospf network point-to-point

!

ipv6 router ospf 1

router-id 198.51.100.254

default-information originate

passive-interface default

no passive-interface GigabitEthernet1


Core ip routing

!

interface GigabitEthernet4

description BGP-CE_Gi1

ip address 192.0.2.2 255.255.255.252



ip ospf network point-to-point

!

router ospf 1

router-id 198.51.100.253

passive-interface default

no passive-interface GigabitEthernet4

network 192.0.2.0 0.0.0.3 area 0.0.0.0

network 198.51.100.0 0.0.0.127 area 0.0.0.0

network 198.51.100.253 0.0.0.0 area 0.0.0.0

ipv6 unicast-routing

!

interface GigabitEthernet4

description BGP-CE_Gi1

ipv6 address 2001:DB8:192::2/64

ipv6 enable

ipv6 nd ra suppress all

ipv6 ospf 1 area 0.0.0.0

ipv6 ospf network point-to-point

!

ipv6 router ospf 1

router-id 198.51.100.253

passive-interface default

no passive-interface GigabitEthernet4


コンフィギュレーションのポイント

IPv4 の OSPFv2 では、OSPF に参加させるインターフェースを router ospf 配下の network で指定し、IPv6 の OSPFv3 ではインターフェースで指定する点が異なります。

OSPFv3 で address-family ipv4 と ipv6 を設定する方法もあります。

passive-interface default

インターフェースの設定をデフォルトでパッシブとし、OSPF Hello を送信させないようにします。

IPv4 では network , IPv6 では area を指定することで、OSPF に参加させることが可能です。

このとき OSPF が動作しているホストが存在すると、OSPF ネイバーが意図せず隣接関係を確立してしまう場合があります。

このように意図しない隣接関係の確立を防ぐため、特に複数のホストを収容するブロードキャスト ネットワークのホストでは passive-interface default が推奨される設定になります。

no passive-interface <インターフェース ID>

OSPF 隣接関係を確立したいインターフェースは、no passive-interface で明示的に OSPF Hello を送受信させるようにします。

ip ospf network point-to-point / ipv6 ospf network point-to-point

/30 や /64 など、参加しているホストが 1:1 接続の場合は、ネットワークタイプをポイントツーポイントに設定します。

  • 隣接関係の確立を早めるため
  • 障害時の切り替え時間を短縮するため

default-information originate

デフォルト ルートを OSPF に広告します。

BGP や Null0 ルートなどでデフォルト ルートを持っている場合に広告されます。

持っていなくても広告したい場合、alway オプションをつけると常に広告されます。

ip address / ipv6 address

IPv4 では OSPF に IPv4 アドレスは必須ですが、IPv6 では OSPFv3 にグローバル ユニキャスト アドレスは必須ではありません。

traceroute の経路確認のため、

ipv6 enable

IPv6 リンク ローカル アドレスを生成し、インターフェースで IPv6 を有効化します。

OSPFv3 はルーティングにリンク ローカル アドレスを使用するため、このコマンドか、手動でリンク ローカル アドレスを設定することが必要です。

ゲートウェイ (Core) とホスト (CPE) コンフィグ

要件

固定 IPv4 IPv6 をデュアル スタックで設定します。

ゲートウェイ (Core)

IPv4 は DHCP でデフォルト ゲートウェイを広告します。

IPv6 は ICMPv6 でデフォルト ゲートウェイを広告します。アドレスと DNS は DHCPv6 サーバから広告します。

ホスト (CPE)

IPv4 : DHCP で IP アドレスと DNS サーバ情報を取得します。

IPv6 : DHCPv6 で IP アドレス DNS サーバ情報を取得します。

IPv6 コンフィギュレーション比較

IPv4 vs IPv6
host IPv4 IPv6 備考
Core ip routing

!

ip dhcp excluded-address 198.51.100.1 198.51.100.10

!

ip dhcp pool IPv4

network 198.51.100.0 255.255.255.128

default-router 198.51.100.1

dns-server 8.8.8.8

!

interface GigabitEthernet1

description CPE_Gi4


ip address 198.51.100.1 255.255.255.128



ipv6 unicast-routing

!


ipv6 dhcp pool IPv6

address prefix 2001:DB8:198::/64


dns-server 2001:4860:4860::8888

!

interface GigabitEthernet1

description CPE_Gi4

ipv6 address FE80::198:1 link-local

ipv6 address 2001:DB8:198::1/64

ipv6 enable

ipv6 nd prefix default no-advertise

ipv6 nd managed-config-flag

ipv6 nd other-config-flag

ipv6 dhcp server IPv6

CPE ip routing

!

interface GigabitEthernet4

description Core_Gi1

ip address dhcp



ipv6 unicast-routing

!

interface GigabitEthernet4

description Core_Gi1

ipv6 address dhcp

ipv6 address autoconfig default

ipv6 enable

ipv6 nd ra suppress all

ipv6 dhcp client request vendor

コンフィギュレーションのポイント

IPv4 と異なる最大の点は、ゲートウェイの設定は ICMPv6 で配布する点が IPv4 と最も異なる点です。

IPv6 は最初期に ICMPv6 で何でも配布しよう、と RFC で考えられていましたが、現在の ISP では DHCPv6 で配布するケースが多数です。

このため、ICMPv6 ではアドレスの配布を停止するが、ゲートウェイの広告は行う、DHCPv6 サーバを使用する、という設定が必要になります。

また、継続してゲートウェイの設定を広告・受信するため、マルチキャストの IPv6 ND RA が、定期的に送信・受信されることが重要です。

ipv6 address <リンク ローカル アドレス> link-local

固定 IPv6 を設定するホストがいる環境では、設定するのが推奨です。

これはルータをリプレースした際にリンク ローカル アドレスが変わってしまい、ホストのデフォルト ルート ネクストホップも変化してしまうためです。

また、fe80::/64 となるように設定します。

  • Windows Firewall が fe80::/64 でフィルタリングしているため

ipv6 nd prefix default no-advertise

ICMPv6 ND のアドレス広告を停止します。

ipv6 nd managed-config-flag

アドレスやプレフィックスの広告を DHCPv6 サーバに管理させます。

ipv6 nd other-config-flag

DNS サーバの広告を、DHCPv6 サーバに管理させます。

ipv6 dhcp server <Pool 名>

DHCPv6 サーバを有効にします。

BGP 確認

BGP 確認要件

広告・受信しているルートを確認できること。

IPv4 IPv6 確認コマンド比較

IPv4 vs IPv6
host IPv4 IPv6 備考
BGP-PE show ip bgp summary

BGP router identifier 203.0.113.88, local AS number 203

BGP table version is 6, main routing table version 6

3 network entries using 744 bytes of memory

3 path entries using 408 bytes of memory

2/2 BGP path/bestpath attribute entries using 576 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 1752 total bytes of memory

BGP activity 9/1 prefixes, 9/1 paths, scan interval 60 secs

3 networks peaked at 00:14:13 May 14 2024 UTC (02:29:34.128 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

203.0.113.2     4          198     172     171        6    0    0 02:32:04        1


show ip bgp neighbors 203.0.113.2 received-routes

BGP table version is 6, local router ID is 203.0.113.88

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   198.51.100.0     203.0.113.2              0             0 198 i

Total number of prefixes 1




show ip bgp neighbors 203.0.113.2 advertised-routes

BGP table version is 6, local router ID is 203.0.113.88

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   0.0.0.0          0.0.0.0                  0         32768 i

*>   203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 2

show bgp ipv6 unicast summary

BGP router identifier 203.0.113.88, local AS number 203

BGP table version is 6, main routing table version 6

5 network entries using 1360 bytes of memory

5 path entries using 800 bytes of memory

2/2 BGP path/bestpath attribute entries using 576 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 2760 total bytes of memory

BGP activity 9/1 prefixes, 9/1 paths, scan interval 60 secs

5 networks peaked at 00:24:51 May 14 2024 UTC (02:20:17.295 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

2001:DB8:203::2 4          198     164     163        6    0    0 02:22:36        3


show bgp ipv6 unicast neighbors 2001:DB8:203::2 received-routes

BGP table version is 6, local router ID is 203.0.113.88

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   2001:DB8:192::/48

                      2001:DB8:203::2          0             0 198 i

*>   2001:DB8:198::/48

                      2001:DB8:203::2          0             0 198 i

*>   2001:DB8:254::/48

                      2001:DB8:203::2          0             0 198 i

Total number of prefixes 3


show bgp ipv6 unicast neighbors 2001:DB8:203::2 advertised-routes

BGP table version is 6, local router ID is 203.0.113.88

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   ::/0             ::                       0         32768 i

*>   2001:DB8:203::/48

                      ::                       0         32768 i

Total number of prefixes 2

BGP-CE show ip bgp summary

BGP router identifier 198.51.100.254, local AS number 198

BGP table version is 4, main routing table version 4

3 network entries using 744 bytes of memory

3 path entries using 408 bytes of memory

2/2 BGP path/bestpath attribute entries using 576 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 1752 total bytes of memory

BGP activity 8/0 prefixes, 8/0 paths, scan interval 60 secs

3 networks peaked at 00:14:13 May 14 2024 UTC (02:32:52.950 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

203.0.113.1     4          203     175     176        4    0    0 02:35:23        2


show ip bgp neighbors 203.0.113.1 received-routes

BGP table version is 4, local router ID is 198.51.100.254

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   0.0.0.0          203.0.113.1              0             0 203 i

*>   203.0.113.0      203.0.113.1              0             0 203 i

Total number of prefixes 2


show ip bgp neighbors 203.0.113.1 advertised-routes

BGP table version is 4, local router ID is 198.51.100.254

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   198.51.100.0     0.0.0.0                  0         32768 i

Total number of prefixes 1



show bgp ipv6 unicast summary

BGP router identifier 198.51.100.254, local AS number 198

BGP table version is 6, main routing table version 6

5 network entries using 1360 bytes of memory

5 path entries using 800 bytes of memory

2/2 BGP path/bestpath attribute entries using 576 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 2760 total bytes of memory

BGP activity 8/0 prefixes, 8/0 paths, scan interval 60 secs

5 networks peaked at 00:25:02 May 14 2024 UTC (02:23:03.379 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

2001:DB8:203::1 4          203     166     167        6    0    0 02:25:34        2


show bgp ipv6 unicast neighbors 2001:DB8:203::1 received-routes

BGP table version is 6, local router ID is 198.51.100.254

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   ::/0             2001:DB8:203::1          0             0 203 i

*>   2001:DB8:203::/48

                      2001:DB8:203::1          0             0 203 i

Total number of prefixes 2


show bgp ipv6 unicast neighbors 2001:DB8:203::1 advertised-routes

BGP table version is 6, local router ID is 198.51.100.254

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,

              t secondary path, L long-lived-stale,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

*>   2001:DB8:192::/48

                      ::                       0         32768 i

*>   2001:DB8:198::/48

                      ::                       0         32768 i

*>   2001:DB8:254::/48

                      ::                       0         32768 i

Total number of prefixes 3

確認のポイント

State/PfxRcd

数字が出ているのが正常で、Establish ステータスを意味します。

Open や Connect は BGP が Up しておらず、異常を意味します。