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

 

 

 

概要

NAT は、組織の IP ネットワークを外部から見たときに、実際に使用されているものとは異なる IP アドレス空間が使用されているように見せる機能です。
このドキュメントでは Static NAT の設定例を示します。Static NAT では 1 対 1 の 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 inside source static 192.168.1.100 172.16.1.99
!


 

設定の説明

ip nat inside

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

 

ip nat outside

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

 

ip nat inside source static <inside local address> <inside global address>

NAT変換する inside local address と inside global address を定義します。
inside 側から outside 側へ通過する際に、パケットの source address が <inside local address> から <inside global address> に変換されます。また、outside 側から inside 側へ通過する際に、パケットの destination address が <inside global address> から <inside local address> に変換されます。

 

 

ip nat outside source static <outside global address> <outside local address>

 

NAT変換する outside global address と outside local address を定義します。
outside 側から inside 側へ通過する際に、パケットの source address が <outside global address> から <outside local address> に変換されます。また、inside 側から outside 側へ通過する際に、パケットの destination address が <outside local address> から <outside global address> に変換されます。

 

この例では以下のように設定しています。

ip nat inside source static 192.168.1.100 172.16.1.99

そのため、inside 側から outside 側へ通過する際に、パケットの source address が 192.168.1.100 から 172.16.1.99 に変換されます。また、outside 側から inside 側へ通過する際に、パケットの destination address が 172.16.1.99 から 192.168.1.100 に変換されます。


 

動作確認

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

 

NAT 変換前の show ip nat translations

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

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

      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.99/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#

「ip nat inside source static 192.168.1.100 172.16.1.99」を設定すると上記のように inside global address(172.16.1.99) が local route としてルーティングテーブルに載ります。

 

show ip aliases

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

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

 

 

debug ip nat

*Apr 20 09:46:29.920: NAT*: s=192.168.1.100->172.16.1.99, d=172.16.1.100 [30]
*Apr 20 09:46:29.975: NAT*: s=172.16.1.100, d=172.16.1.99->192.168.1.100 [30]
*Apr 20 09:46:29.975: NAT*: s=192.168.1.100->172.16.1.99, d=172.16.1.100 [31]
*Apr 20 09:46:29.976: NAT*: s=172.16.1.100, d=172.16.1.99->192.168.1.100 [31]
*Apr 20 09:46:29.976: NAT*: s=192.168.1.100->172.16.1.99, d=172.16.1.100 [32]
*Apr 20 09:46:29.976: NAT*: s=172.16.1.100, d=172.16.1.99->192.168.1.100 [32]
*Apr 20 09:46:29.977: NAT*: s=192.168.1.100->172.16.1.99, d=172.16.1.100 [33]
*Apr 20 09:46:29.977: NAT*: s=172.16.1.100, d=172.16.1.99->192.168.1.100 [33]
*Apr 20 09:46:29.977: NAT*: s=192.168.1.100->172.16.1.99, d=172.16.1.100 [34]
*Apr 20 09:46:29.978: NAT*: s=172.16.1.100, d=172.16.1.99->192.168.1.100 [34]

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.99 に変換されます。また、戻りのパケットが、outside から inside に通過する際に destnation が 172.16.1.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 172.16.1.99:6     192.168.1.100:6    172.16.1.100:6     172.16.1.100:6
--- 172.16.1.99        192.168.1.100      ---                ---
Router#

simple translation entry に加え、fully extended translation entry が作成されます。
*Inside global, Inside local, Outside local, Outside global の IP address と port 番号(この例では 6)が全て記載されたものを fully extended translation entry と呼びます。

 

 

 

トラブルシューティング

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

NAT Troubleshooting Commands


 

 

関連情報

 

Getting Started

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

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