NAT 基本設定

ルータでip nat insideと設定したネットワークが内部ネットワーク、ip nat outsideと設定したネットワークが外部ネットワークになります。NATで表現されるアドレスも次の4つの種類があります。

・内部ローカルアドレス :内部ネットワークのホストアドレス
・内部グローバルアドレス:ネットワーク上で一意の内部ホストのグローバルアドレス
・外部ローカルアドレス :内部ネットワークから見た外部ホストのアドレス
・外部グローバルアドレス:外部ネットワークのホストアドレス

ネットワークが重複する場合のNAT等の際には、外部グローバルアドレスを橋渡しとして使います。
送信元が内部ローカルアドレス、送信先は一時的に割り当てた外部ローカルアドレスとしてパケットが送付されNATはこれを内部グローバルアドレス、外部グローバルアドレスへ各々変換します。

例:
内部ローカル  内部グローバル 外部グローバル 外部ローカル
192.168.1.90 66.66.66.66 192.168.1.150 172.16.1.150

NAT変換前 Source:192.168.1.90  Dist:172.16.1.150
NAT変換後 Source:66.66.66.660  Dist:192.168.1.150

■Static NAT

NAT_01_01

[RouterA]

interface Ethernet0/0
 ip address 192.168.1.2 255.255.255.0
 ip nat outside
 ip virtual-reassembly
 half-duplex
!
interface Ethernet0/1
 ip address 10.1.1.2 255.255.255.0
 ip nat inside
 ip virtual-reassembly
 half-duplex
!
ip nat inside source static 10.1.1.1 192.168.1.1
!
ip route 192.168.2.0 255.255.255.0 192.168.1.3

[RouterB]

interface Ethernet0/0
 ip address 192.168.1.3 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.2.2 255.255.255.0
 half-duplex
!

RouterAのNATテーブルを確認

RouterA#show ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
--- 192.168.1.1        10.1.1.1           ---                ---

WindowsXPから192.168.2.2へPingを飛ばしその様子をDebugで確認。

RouterA#debug ip nat
IP NAT debugging is on
RouterA#
*Mar  1 00:49:30.275: NAT*: s=10.1.1.1->192.168.1.1, d=192.168.2.2 [148]
*Mar  1 00:49:30.335: NAT*: s=192.168.2.2, d=192.168.1.1->10.1.1.1 [148]
*Mar  1 00:49:31.207: NAT*: s=10.1.1.1->192.168.1.1, d=192.168.2.2 [149]

RouteBでも確認

IP packet debugging is on
RouterB#
*Mar  1 00:47:08.707: IP: tableid=0, s=192.168.1.1 (Ethernet0/0), d=192.168.2.2 (Ethernet0/1), routed via RIB
*Mar  1 00:47:08.707: IP: s=192.168.1.1 (Ethernet0/0), d=192.168.2.2, len 60, rcvd 4
*Mar  1 00:47:08.711: IP: tableid=0, s=192.168.2.2 (local), d=192.168.1.1 (Ethernet0/0), routed via FIB
*Mar  1 00:47:08.711: IP: s=192.168.2.2 (local), d=192.168.1.1 (Ethernet0/0), len 60, sending
*Mar  1 00:47:09.567: IP: tableid=0, s=192.168.1.1 (Ethernet0/0), d=192.168.2.2 (Ethernet0/1), routed via RIB
*Mar  1 00:47:09.567: IP: s=192.168.1.1 (Ethernet0/0), d=192.168.2.2, len 60, rcvd 4

■PAT

NAT_01_02
[RouterA]

interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip nat outside
 ip virtual-reassembly
 half-duplex
!
interface Ethernet0/1
 ip address 10.1.1.4 255.255.255.0
 ip nat inside
 ip virtual-reassembly
 half-duplex

!
ip nat pool testpool 192.168.1.1 192.168.1.1 netmask 255.255.255.0 
:アドレス変換用のアドレスをtestpoolという名前でプール(startとendが一緒)
ip nat inside source list 1 pool testpool overload
:内部ネットワークの送信元アドレスがACLのNo1(10.1.1.1-2)だったら、testpool(192.168.1.1)に変換
!
access-list 1 permit 10.1.1.2 :変換するアドレスをNo1で定義
access-list 1 permit 10.1.1.1 :変換するアドレスをno1で定義
!
ip route 192.168.2.0 255.255.255.0 192.168.1.2

[RouterB]

interface Ethernet0/0
 ip address 192.168.1.2 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.2.2 255.255.255.0
 half-duplex
!

RouterAでNATテーブルを確認

RouterA#sh ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
icmp 192.168.1.1:512   10.1.1.1:512       192.168.2.2:512    192.168.2.2:512
icmp 192.168.1.1:513   10.1.1.2:512       192.168.2.2:512    192.168.2.2:513

もしくはPoolを設定せずインターエースに紐付ける方法もありこちらの方が一般的な模様。

RouterA(config)#ip nat inside source list 1 interface ethernet 0/0 overload

■DynamicNAT

[RouterA]

interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip nat outside
 no ip virtual-reassembly
 half-duplex
!
interface Ethernet0/1
 ip address 10.1.1.4 255.255.255.0
 ip nat inside
 no ip virtual-reassembly
 half-duplex

!
ip nat pool testpool 192.168.1.3 192.168.1.4 netmask 255.255.255.0
ip nat inside source list 1 pool testpool
!
access-list 1 permit 10.1.1.2
access-list 1 permit 10.1.1.1
!
ip route 192.168.2.0 255.255.255.0 192.168.1.2

show ip nat translationsの後にverboseオプションを付けるとエントリの有効期限、残り時間等を確認できます。

RouterA#show ip nat translations verbose
Pro Inside global Inside local Outside local Outside global
--- 192.168.1.3 10.1.1.1 --- ---
 create 00:03:13, use 00:03:13 timeout:86400000, left 23:56:46, Map-Id(In): 4,
 flags:
none, use_count: 0, entry-id: 7, lc_entries: 0
--- 192.168.1.4 10.1.1.2 --- ---
 create 00:03:10, use 00:03:10 timeout:86400000, left 23:56:49, Map-Id(In): 4,
 flags:
none, use_count: 0, entry-id: 9, lc_entries: 0
スポンサーリンク






シェアする

  • このエントリーをはてなブックマークに追加

フォローする