キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 
cancel
5373
閲覧回数
0
いいね!
0
コメント
Ryota Takao
Cisco Employee
Cisco Employee

 

 

 

概要

NAT は、組織の IP ネットワークを外部から見たときに、実際に使用されているものとは異なる IP アドレス空間が使用されているように見せる機能です。
このドキュメントでは route-map を使用した Dynamic NAT の設定例を示します。Dynamic NAT では N 対 N の Translation を定義します。
NAT の詳しい概要についてはこのドキュメントの最後にある「関連情報」の Link を参照してください。
なお、このドキュメントの内容は 15.6(3)M1 を使用して動作確認を行っています。

  

  

ネットワーク構成

Router の IOS version : 15.6(3)M1

 

  

設定例

 

Router 

!
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip nat inside
!
interface Ethernet0/1
 ip address 172.16.1.1 255.255.255.0
 ip nat outside
!
ip nat pool POOL 172.16.1.90 172.16.1.99 netmask 255.255.255.0
ip nat inside source route-map RM pool POOL reversible
!
route-map RM permit 10
 match ip address 100
!
access-list 100 permit ip 192.168.1.0 0.0.0.255 172.16.1.0 0.0.0.255
!


 

設定の説明

ip nat inside

インターフェースが inside network であることを指定します。

 

ip nat outside

インターフェースが outside network であることを指定します。

 

ip nat pool POOL 172.16.1.90 172.16.1.99 netmask 255.255.255.0

NAT変換する inside global address の範囲を定義します。

 

ip nat pool POOL 172.16.1.90 172.16.1.99 netmask 255.255.255.0

NAT変換後の inside global address の範囲を定義します。この例では、172.16.1.90 ~ 172.16.1.99 の範囲の IP アドレスに変換するように定義しています。

 

!
route-map RM permit 10
match ip address 100
!
access-list 100 permit ip 192.168.1.0 0.0.0.255 172.16.1.0 0.0.0.255
!

source が 192.168.1.0/24 で dest が 172.16.1.0/24 の通信を access-list 100 として定義し、access-list 100 に合致する通信を route-map RM として作成します。
*route-map 配下に standard access-list も設定可能ですが、「ip nat inside source route-map <name> ...」で route-map を関連付ける場合は standard access-list はサポートされておりません。

 

 

ip nat inside source route-map RM pool POOL reversible

route-map と pool を関連づけ、route-map に合致する通信の source アドレスを pool のアドレスに変換します。

reversible option がある場合は、inside 側から outside 側への通信が発生した際に fully extended translation entry だけでなく simple translation entry も作成されます。
*inside or outside に対応した local/global address entry のみが作成されているものを simple translation entry と呼びます。
*Inside global, Inside local, Outside local, Outside global の IP address と port 番号が全て記載されたものを fully extended translation entry と呼びます。

simple translation entry が作成されると、simple translation entry が削除されるまでは、outside 側から発生した通信においても NAT 変換が行われます。なお、この simple translation entry は default では該当の通信がなくなってから 3600秒(1時間) 経過すると削除されます。default 値を変更したい場合は以下のコマンドで変更を行ってください。

ip nat translation routemap-entry-timeout <0-536870秒>



reversible option がない場合は、simple translation entry が作成されないため、inside 側から通信が開始された場合のみ NAT 変換が行われます。
reversible option がない場合でも、inside 側からの ping の相手からの戻りのパケット、inside 側から開始された TCP 通信の相手からの戻りのパケットのように inside 側から開始された通信であれば変換は行われます。


 

動作確認

各種コマンドで NAT 変換が正常に行われているか確認します。

 

NAT 変換前の show ip nat translations

Router#show ip nat translations
Router#

上記のように translation entry には何も表示されません。Static NAT とは異なり、初期状態では simple translation entry もありません。

 

show ip route

Router#show ip route
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, p - overrides from PfR

Gateway of last resort is not set

      172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.16.1.0/24 is directly connected, Ethernet0/1
L        172.16.1.1/32 is directly connected, Ethernet0/1
      192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.1.0/24 is directly connected, Ethernet0/0
L        192.168.1.1/32 is directly connected, Ethernet0/0
Router#

NAT のエントリがないため、inside global address はルーティングテーブルには載りません。

 

NAT 変換前の show ip aliases

Router#show ip aliases
Address Type             IP Address      Port
Interface                172.16.1.1
Interface                192.168.1.1
Router#

NAT のエントリがないため、inside global address の ip alias は作成されません。

 

 

NAT 変換時の debug ip nat の出力

*Apr 23 09:23:16.336: NAT*: s=192.168.1.100->172.16.1.90, d=172.16.1.100 [50]
*Apr 23 09:23:16.337: NAT*: s=172.16.1.100, d=172.16.1.90->192.168.1.100 [50]
*Apr 23 09:23:16.342: NAT*: s=192.168.1.100->172.16.1.90, d=172.16.1.100 [51]
*Apr 23 09:23:16.342: NAT*: s=172.16.1.100, d=172.16.1.90->192.168.1.100 [51]
*Apr 23 09:23:16.343: NAT*: s=192.168.1.100->172.16.1.90, d=172.16.1.100 [52]
*Apr 23 09:23:16.343: NAT*: s=172.16.1.100, d=172.16.1.90->192.168.1.100 [52]
*Apr 23 09:23:16.343: NAT*: s=192.168.1.100->172.16.1.90, d=172.16.1.100 [53]
*Apr 23 09:23:16.343: NAT*: s=172.16.1.100, d=172.16.1.90->192.168.1.100 [53]
*Apr 23 09:23:16.344: NAT*: s=192.168.1.100->172.16.1.90, d=172.16.1.100 [54]
*Apr 23 09:23:16.344: NAT*: s=172.16.1.100, d=172.16.1.90->192.168.1.100 [54]

NAT 変換の様子を確認するため Router にて debug ip nat を有効にした状態で Host 1(192.168.1.100)から Host 2(172.16.1.100) へ ping を行い、NAT 変換が行われていることを確認します。
*debug を使用する場合は CPU の使用率が高騰する恐れがあるのでご注意ください。
ping を行うと上記のように inside から outside へ通過する際に、source が 192.168.1.100 から 172.16.1.90 に変換されます。また、戻りのパケットが、outside から inside に通過する際に destnation が 172.16.1.90 から 192.168.1.100 に変換されます。

 

NAT 変換直後の show ip nat translations

Router#show ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
icmp 172.16.1.90:10    192.168.1.100:10   172.16.1.100:10    172.16.1.100:10
--- 172.16.1.90        192.168.1.100      ---                ---
Router#

simple translation entry(下側のエントリ) と、fully extended translation entry(上側のエントリ) が作成されます。
simple translation entry がある場合、outside 側から発生した通信についても NAT 変換を行うことが可能です。

 

 

NAT 変換直後の show ip route

Router#show ip route

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, p - overrides from PfR

Gateway of last resort is not set

      172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C        172.16.1.0/24 is directly connected, Ethernet0/1
L        172.16.1.1/32 is directly connected, Ethernet0/1
L        172.16.1.90/32 is directly connected, Ethernet0/1
      192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.1.0/24 is directly connected, Ethernet0/0
L        192.168.1.1/32 is directly connected, Ethernet0/0
Router#

上記のように inside global address(172.16.1.90) が local route としてルーティングテーブルに載ります。
*該当の fully extended translation entry と simple translation entry が削除されると消えます。

 

NAT 変換直後の show ip aliases

Router#show ip aliases
Address Type             IP Address      Port
Interface                172.16.1.1
Dynamic                  172.16.1.90
Interface                192.168.1.1
Router#

inside global address(172.16.1.90) の ip alias が作成されます。
*該当の fully extended translation entry と simple translation entry が削除されると消えます。
inside global address(172.16.1.90) の ip alias が作成されると、inside global address(172.16.1.90) と ip nat outside が設定されている interface の IP address(172.16.1.1) が同じサブネットの場合に inside global address(172.16.1.90) の ARP request に Router が応答します。

 

 

トラブルシューティング

以下のLink を参照してください。

NAT Troubleshooting Commands


 

 

関連情報

 

Getting Started

検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう

シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします