2017-01-27 11:55 AM 2019-03-22 07:10 AM 更新
初版:2017年1月27日
第2版:2017年3月15日 Route-mapのAND/ORについて更新しました
第3版:2017年4月24日 Dynamic NAT における簡易変換エントリについて修正しました
概要
本ドキュメントでは NAT における reversible オプションの動作について記述します。 reversible オプションはデフォルトでは無効です。有効にする場合は以下のように設定を行います。
ip nat inside source route-map name pool name reversible
ip nat inside source static ip_address_A ip _address_B route-map name reversible
reversible オプションは Dynamic NAT と Static NAT では動作が異なり、トラフィックの方向によっても動作が変わります。以下検証を交えつつ、それぞれの動作を確認していきます。
目次
1.トポロジ
2.動作
2-1.Static NAT (non-reversible)
2-2.Static NAT (reversible)
2-3.Dynamic NAT について
2-4.Dynamic NAT (non-reversible)
2-5.Dynamic NAT (reversible)
3.まとめ
4.参照
1.トポロジ
[[{"attributes":{},"fields":{}}]]
2.動作
2-1.Static NAT (non-reversible)
Static NAT において reversible オプションが設定されていない場合、Route-map によるマッチングはinside->outside 方向のトラフィックのみに実行され、outside->inside 方向のトラフィックは無条件に変換されます。
R2の設定
ip nat inside source static 1.1.1.1 11.11.11.11 route-map rm1 route-map rm1 permit 10 match ip address 111 ! access-list 111 permit ip host 1.1.1.1 host 100.100.100.100
以下 inside->outside 方向のトラフィックに対する NAT の挙動
R1#ping 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 100.100.100.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms R2# <NAT を実行せず>
R1#ping 100.100.100.100 source 1.1.1.1 Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms R2# *Dec 7 08:22:00.841: NAT*: s=1.1.1.1->11.11.11.11, d=100.100.100.100 [55] *Dec 7 08:22:00.841: NAT*: s=100.100.100.100, d=11.11.11.11->1.1.1.1 [55]
-----snip-----
inside->outside 方向のトラフィックに対して Route-map によるマッチングを行い、マッチしたトラフィックに対して NAT を適用しています。
一方 outside->inside 方向のトラフィックに対しては、以下のように Route-map を参照せず、無条件に変換を実行しています。
R3#ping 11.11.11.11 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms R2# *Dec 8 04:56:02.817: NAT*: s=150.1.4.3, d=11.11.11.11->1.1.1.1 [172] *Dec 8 04:56:02.818: NAT*: s=1.1.1.1->11.11.11.11, d=150.1.4.3 [172]
-----snip----
R3#ping 11.11.11.11 source 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: Packet sent with a source address of 100.100.100.100 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms R2# *Dec 8 04:57:31.548: NAT*: s=100.100.100.100, d=11.11.11.11->1.1.1.1 [177] *Dec 8 04:57:31.548: NAT*: s=1.1.1.1->11.11.11.11, d=100.100.100.100 [177]
-----snip----
補足ですが、以下のように Route-map に複数のアクセスリストを定義した場合、OR 条件でマッチングを行います。
route-map rm1 permit 10 match ip address 111 222
上記の設定ではアクセスリスト111または222のどちらかにマッチした場合に NAT を実行します。
ただし、Reversibleオプションを有効にした場合の outside -> inside 方向に対しては AND 条件でマッチングを行います。
2-2.Static NAT (reversible)
Static NAT において reversible オプションを有効にした場合、 inside->outside 方向だけでなく outside->inside 方向のトラフィックに対しても Route-map によるマッチングを適用します。
R2の設定
ip nat inside source static 1.1.1.1 11.11.11.11 route-map rm1 reversible route-map rm1 permit 10 match ip address 111 ! access-list 111 permit ip host 1.1.1.1 host 100.100.100.100
以下、outside->inside 方向のトラフィックに対する動作
R3#ping 11.11.11.11 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: !.!.! Success rate is 60 percent (3/5), round-trip min/avg/max = 1/1/1 ms R2# *Dec 8 05:03:29.362: NAT(acl): name 111 failed *Dec 8 05:03:29.362: NAT(acl): name 111 failed *Dec 8 05:03:29.362: NAT(acl): name 111 failed
-----snip-----
トラフィックが Route-map にマッチせず、かつ 11.11.11.11 宛の経路が R2 のルーティングテーブルにないため通信に失敗しています。 R1 に Lo2 (11.11.11.11) を作成し、 R2 で 11.11.11.11 への static route を設定すると、以下で示すように通信は成功しますが NAT は実行されません。
R3#ping 11.11.11.11 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
R2# *Dec 8 05:28:58.237: NAT(acl): name 111 failed *Dec 8 05:28:58.237: NAT(acl): name 111 failed
-----snip-----
次は Route-map にマッチするトラフィックに対する挙動を示します。
R3#ping 11.11.11.11 source 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: Packet sent with a source address of 100.100.100.100 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms R2# *Dec 8 05:30:23.608: NAT*: s=100.100.100.100, d=11.11.11.11->1.1.1.1 [222] *Dec 8 05:30:23.608: NAT*: s=1.1.1.1->11.11.11.11, d=100.100.100.100 [222] *Dec 8 05:30:23.608: NAT*: s=100.100.100.100, d=11.11.11.11->1.1.1.1 [223] *Dec 8 05:30:23.608: NAT*: s=1.1.1.1->11.11.11.11, d=100.100.100.100 [223] -----snip-----
Route-map にマッチしたので、 NAT 変換が実行されています。
以上が Static NAT における reversible オプションの違いとなります。
2-3.Dynamic NAT について
Static NAT と異なり、 Dynamic NAT は外部から開始されるセッションに対して NAT 変換を行うことができません。
Static NAT では設定を投入すると直ちに簡易変換エントリ (Simple translation entry) が NAT テーブルに作成されます。
R2#sh ip nat translations Pro Inside global Inside local Outside local Outside global --- 11.11.11.11 1.1.1.1 --- ---
このエントリを参照することで外部からのトラフィックに対しても NAT 変換を実行できます。
対してDynamic NAT は、NAT を実行する直前まで変換先のアドレスが一意に定まらないため、NAT の設定時には簡易変換エントリを作成しません。そのため、Dynamic NAT においては NAT の設定を行った時点では外部からのトラフィックに対して NAT を実行できません。
Static NAT と Dynamic NAT のどちらとも変換を実行する際に完全拡張変換エントリ (Fully extended translation entry) を作成します。
R2#sh ip nat translations Pro Inside global Inside local Outside local Outside global icmp 11.11.11.11:38 1.1.1.1:38 100.100.100.100:38 100.100.100.100:38 --- 11.11.11.11 1.1.1.1 --- ---
この完全拡張変換エントリは一定時間経過後に破棄されますが、簡易変換エントリは破棄されません。
Route-mapを用いたDynamic NAT において reversible オプションを有効にすると、変換実行時に完全拡張変換エントリと共に簡易変換エントリも作成するようになります。(Access-list を用いた Dynamic NAT では reversible オプションの有無に関わらずNAT実行時に簡易変換エントリと完全拡張エントリを作成します。)
以下でこの違いを検証します。
2-4 Dynamic NAT (non-reversible)
R2の設定
ip nat pool pool1 11.11.11.11 11.11.11.15 prefix-length 24 ip nat inside source route-map rm1 pool pool1 ! route-map rm1 permit 10 match ip address 111 ! access-list 111 permit ip host 1.1.1.1 host 100.100.100.100
R3#ping 11.11.11.11 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: U.U.U Success rate is 0 percent (0/5) R2#
R3#ping 11.11.11.11 source 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: Packet sent with a source address of 100.100.100.100 U.U.U Success rate is 0 percent (0/5) R2#sh ip nat translations R2#
このように、 Dynamic NAT では outside->inside 方向のトラフィックに対して NAT 変換を行うことができません。
また、 NAT テーブルにエントリが存在しないことが sh ip nat translations の結果からわかります。
reversible オプションが無効の場合、 NAT テーブルに完全拡張エントリのみが存在していても外部からのトラフィックに対して変換を行いません。
R2#sh ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 11.11.11.11:49 1.1.1.1:49 100.100.100.100:49 100.100.100.100:49 R3#ping 11.11.11.11 source 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: Packet sent with a source address of 100.100.100.100 U.U.U Success rate is 0 percent (0/5)
R2#
2-5.Dynamic NAT(reversible)
R2の設定
ip nat pool pool1 11.11.11.11 11.11.11.15 prefix-length 24 ip nat inside source route-map rm1 pool pool1 ! route-map rm21 permit 10 match ip address 111 ! access-list 111 permit ip host 1.1.1.1 host 100.100.100.100
reversible オプションを有効にしても外部から開始するトラフィックに対しては NAT を実行しません。
R3#ping 11.11.11.11 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: U.U.U Success rate is 0 percent (0/5) R2#
R3#ping 11.11.11.11 source 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: Packet sent with a source address of 100.100.100.100 U.U.U Success rate is 0 percent (0/5)
Dynamic NAT において reversible オプションを有効にすると、変換時に完全拡張変換エントリに加え、簡易変換エントリも作成します。 inside->outside 方向のトラフィックに対して NAT を実行させ、その後 outside->inside 方向の通信を行うと以下の通りになります。
R2#sh ip nat translations Pro Inside global Inside local Outside local Outside global icmp 11.11.11.11:38 1.1.1.1:38 100.100.100.100:38 100.100.100.100:38 --- 11.11.11.11 1.1.1.1 --- --- R3#ping 11.11.11.11 source 100.100.100.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds: Packet sent with a source address of 100.100.100.100 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/7/24 ms
R2# *Dec 8 06:00:02.539: NAT*: s=100.100.100.100, d=11.11.11.11->1.1.1.1 [326] *Dec 8 06:00:02.540: NAT*: s=1.1.1.1->11.11.11.11, d=100.100.100.100 [326] -----snip----
outside->inside 方向のトラフィックに対して NAT を実行しています。
なお、完全拡張変換エントリが破棄されても簡易変換エントリは残っていることが以下のログからわかります。
R2# *Dec 8 06:01:03.218: NAT: expiring 11.11.11.11 (1.1.1.1) icmp 66 (66) R2#sh ip nat translations Pro Inside global Inside local Outside local Outside global --- 11.11.11.11 1.1.1.1 --- ---
以上が Dynamic NAT における reversible オプションの有無による動作の違いとなります。
3.まとめ
以上の結果をまとめます。
Static NAT において reversible オプションが無効の場合、 Route-map によるマッチングは inside->outside 方向のトラフィックのみに適用されますが、 reversible オプションを有効にすると inside->outside 方向とoutside->inside 方向の両方のトラフィックに適用されるようになります。
Route-map を用いた Dynamic NAT において reversible オプションが無効の場合、 NAT 実行時に完全拡張変換エントリのみが作成され、 reversible オプションを有効にすると NAT 変換時に完全拡張変換エントリとともに簡易変換エントリも同時に作成されます。これにより、 outside->inside 方向のトラフィックにも NAT を実行できるようになります。
4.参照
検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう
シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします
下記より関連するコンテンツにアクセスできます