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

 

 

 

概要

NAT は、組織の IP ネットワークを外部から見たときに、実際に使用されているものとは異なる IP アドレス空間が使用されているように見せる機能です。
このドキュメントでは route-map を使用した Static NAT の設定例を示します。route-map を使用することで宛先ごとに異なる送信元アドレスに変換することが可能になります。
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 10.0.0.1 255.255.255.0
 ip nat outside
!
interface Ethernet0/2
 ip address 20.0.0.1 255.255.255.0
 ip nat outside
!
access-list 101 permit ip 192.168.1.0 0.0.0.255 10.0.0.0 0.0.0.255
access-list 102 permit ip 192.168.1.0 0.0.0.255 20.0.0.0 0.0.0.255
!
route-map SITE1 permit 10
 match ip address 101
 set ip next-hop 10.0.0.100
!
route-map SITE2 permit 10
 match ip address 102
 set ip next-hop 20.0.0.100
!
ip nat inside source static 192.168.1.100 10.0.0.99 route-map SITE1
ip nat inside source static 192.168.1.100 20.0.0.99 route-map SITE2
!


 

設定の説明

ip nat inside

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

 

ip nat outside

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

 

access-list 101 permit ip 192.168.1.0 0.0.0.255 10.0.0.0 0.0.0.255

source が 192.168.1.0/24 で dest が 10.0.0.0/24 の通信を access-list 101 として定義します。

 

access-list 102 permit ip 192.168.1.0 0.0.0.255 20.0.0.0 0.0.0.255

source が 192.168.1.0/24 で dest が 20.0.0.0/24 の通信を access-list 102 として定義します。

 

!
route-map SITE1 permit 10
 match ip address 101
 set ip next-hop 10.0.0.100
!

access-list 101 に合致する通信(Host から SITE1 への通信)の nexthop を 10.0.0.100 に set します。

 

!
route-map SITE2 permit 10
 match ip address 102
 set ip next-hop 20.0.0.100
!

access-list 102 に合致する通信(Host から SITE1 への通信)の nexthop を 20.0.0.100 に set します。

 

!
ip nat inside source static 192.168.1.100 10.0.0.99 route-map SITE1
ip nat inside source static 192.168.1.100 20.0.0.99 route-map SITE2
!

NAT 変換する inside local address と inside global address を定義し、route-map を関連付けます。
inside 側から outside 側へ通過する際に、パケットが route-map に合致した場合、パケットの source address が <inside local address> から <inside global address> に変換されます。また、outside 側から inside 側へ通過する際に、パケットの destination address が <inside global address> から <inside local address> に変換されます。outside 側から inside 側へ通過する際には route-map の確認は行われません。


 

動作確認

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

 

NAT 変換前の show ip nat translations

Router#show ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
--- 10.0.0.99          192.168.1.100      ---                ---
--- 20.0.0.99          192.168.1.100      ---                ---
Router#

上記のように simple translation entry のみが作成されています。
*inside or outside に対応した local/global address entry のみが作成されているものを simple translation entry と呼びます。今回は ip nat inside source static の設定を行っているため、Inside global/Inside local のみの simple translation entry が作成されます。
simple translation entry がある場合、outside 側から発生した通信についても 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

      10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        10.0.0.0/24 is directly connected, Ethernet0/1
L        10.0.0.1/32 is directly connected, Ethernet0/1
L        10.0.0.99/32 is directly connected, Ethernet0/1
      20.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        20.0.0.0/24 is directly connected, Ethernet0/2
L        20.0.0.1/32 is directly connected, Ethernet0/2
L        20.0.0.99/32 is directly connected, Ethernet0/2
      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(10.0.0.99 と 20.0.0.99) が local route としてルーティングテーブルに載ります。

 

show ip aliases

Router#show ip aliases
Address Type             IP Address      Port
Interface                10.0.0.1
Dynamic                  10.0.0.99
Interface                20.0.0.1
Dynamic                  20.0.0.99
Interface                192.168.1.1
Router#

inside global address(10.0.0.99 と 20.0.0.99) の ip alias が作成されます。
inside global address(10.0.0.99 と 20.0.0.99) の ip alias が作成されると、inside global address(10.0.0.99 と 20.0.0.99) と ip nat outside が設定されている interface の IP address が同じサブネットの場合に inside global address(10.0.0.99 と 20.0.0.99)の ARP request に Router が応答します。

 

 

NAT 変換中の debug ip nat の出力

Host -> SITE1
*Apr 23 03:09:37.148: NAT*: s=192.168.1.100->10.0.0.99, d=10.0.0.100 [125]
*Apr 23 03:09:37.153: NAT*: s=10.0.0.100, d=10.0.0.99->192.168.1.100 [125]
*Apr 23 03:09:37.153: NAT*: s=192.168.1.100->10.0.0.99, d=10.0.0.100 [126]
*Apr 23 03:09:37.153: NAT*: s=10.0.0.100, d=10.0.0.99->192.168.1.100 [126]
*Apr 23 03:09:37.154: NAT*: s=192.168.1.100->10.0.0.99, d=10.0.0.100 [127]
*Apr 23 03:09:37.154: NAT*: s=10.0.0.100, d=10.0.0.99->192.168.1.100 [127]
*Apr 23 03:09:37.154: NAT*: s=192.168.1.100->10.0.0.99, d=10.0.0.100 [128]
*Apr 23 03:09:37.154: NAT*: s=10.0.0.100, d=10.0.0.99->192.168.1.100 [128]
*Apr 23 03:09:37.154: NAT*: s=192.168.1.100->10.0.0.99, d=10.0.0.100 [129]
*Apr 23 03:09:37.154: NAT*: s=10.0.0.100, d=10.0.0.99->192.168.1.100 [129]
Host -> SITE2
*Apr 23 03:09:41.404: NAT*: s=192.168.1.100->20.0.0.99, d=20.0.0.100 [130]
*Apr 23 03:09:41.405: NAT*: s=20.0.0.100, d=20.0.0.99->192.168.1.100 [130]
*Apr 23 03:09:41.405: NAT*: s=192.168.1.100->20.0.0.99, d=20.0.0.100 [131]
*Apr 23 03:09:41.405: NAT*: s=20.0.0.100, d=20.0.0.99->192.168.1.100 [131]
*Apr 23 03:09:41.406: NAT*: s=192.168.1.100->20.0.0.99, d=20.0.0.100 [132]
*Apr 23 03:09:41.406: NAT*: s=20.0.0.100, d=20.0.0.99->192.168.1.100 [132]
*Apr 23 03:09:41.406: NAT*: s=192.168.1.100->20.0.0.99, d=20.0.0.100 [133]
*Apr 23 03:09:41.407: NAT*: s=20.0.0.100, d=20.0.0.99->192.168.1.100 [133]
*Apr 23 03:09:41.407: NAT*: s=192.168.1.100->20.0.0.99, d=20.0.0.100 [134]
*Apr 23 03:09:41.407: NAT*: s=20.0.0.100, d=20.0.0.99->192.168.1.100 [134]

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

 

NAT 変換直後の show ip nat translations

Router#show ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
icmp 10.0.0.99:25      192.168.1.100:25   10.0.0.100:25      10.0.0.100:25
icmp 20.0.0.99:26      192.168.1.100:26   20.0.0.100:26      20.0.0.100:26
--- 10.0.0.99          192.168.1.100      ---                ---
--- 20.0.0.99          192.168.1.100      ---                ---
Router#

simple translation entry に加え、fully extended translation entry が作成されます。
*Inside global, Inside local, Outside local, Outside global の IP address と port 番号が全て記載されたものを fully extended translation entry と呼びます。
simple translation entry がある場合、outside 側から発生した通信についても NAT 変換を行うことが可能です。

 

 

 

トラブルシューティング

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

NAT Troubleshooting Commands


 

 

関連情報

 

Getting Started

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

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