ネットワークポートアドレス変換NAPT設定

 

あなたは会社のネットワーク管理者です。会社のオフィス ネットワークはインターネットに接続する必要があります。会社は ISP からの専用回線のみを申し込みます。専用回線には会社の IP アドレスが割り当てられ、すべてのホストがインターネットに接続できるように設定されています。会社は外部ネットワークにアクセスできます。

技術原理

NAT は、ネットワークを内部ネットワークと外部ネットワークの 2 つに分割し、LAN ホストが NAT を使用してネットワークにアクセスする際に、LAN 内のローカル アドレスをグローバル アドレス (インターネットの正規の IP アドレス) に変換し、データパケットを転送するNATは、NAT(ネットワークアドレス変換)とNAPT(ネットワークポートアドレス変換のIPアドレスがグローバルアドレスに相当)の2種類に分かれます

NAPT: 異なるポートを使用して、複数の内部 IP アドレスを指定された外部 IP アドレスに多対 1 でマッピングします。
NAPT はポート多重化を使用します。内部ネットワーク内のすべてのホストは、インターネットにアクセスするために合法的な外部 IP アドレスを共有できるため、IP アドレス リソースを最大限に節約できます。同時に、ネットワーク内のすべてのホストを隠し、インターネットからの攻撃を効果的に回避できます。したがって、ネットワークで最も広く使用されているのはポート多重化モードです。

インターネット サービス プロバイダーである ISP (インターネット サービス プロバイダー) は、大多数のユーザーにインターネット アクセス サービス、情報サービス、および付加価値サービスを総合的に提供する通信事業者です。ISP は国の管轄当局によって承認された正式な運営企業であり、国の法的保護を受けています。

実験手順

新しいパケット トレーサ トポロジ マップを作成する

(1) R1 は会社のエクスポート ルータであり、V.35 ケーブル シリアル ポートを介して ISP ルータに接続されており、DCE 端末が R1 に接続されており、そのクロック周波数は 64000 に設定されています。 PC、サーバー、およびルーターのインターフェイス IP アドレス
;
(3) PC が相互に ping できるように、各ルーターで静的ルーティング プロトコルを構成します;
(4) R1 で NAPT を構成します。
(5) R1 で内部および外部ネットワーク インターフェイスを定義します。
(6) ホスト間の相互運用性を検証します。

研究所の備品

PC 2 台;Server-PT 1 台;Switch_2950-24 1 台 Router-PT 2 台;直通线;交叉线;DCE串口线

PC1

192.168.1.2
255.255.255.0
192.168.1.1

PC2

192.168.1.3
255.255.255.0
192.168.1.1

Server

200.1.2.2
255.255.255.0
200.1.2.1

R1

en
conf t
host R1
int fa 0/0
ip address 192.168.1.1 255.255.255.0
no shutdown
int s 2/0
ip address 200.1.1.1 255.255.255.0
no shutdown
clock rate 64000

R2

en
conf t
host R2
int s 2/0
ip address 200.1.1.2 255.255.255.0
no shutdown
int fa 0/0
ip address 200.1.2.1 255.255.255.0
no shutdown

R1

exit
ip route 200.1.2.0 255.255.255.0 200.1.1.2

R2

exit
ip route 192.168.1.0 255.255.255.0 200.1.1.1
end
show ip route

PC1

CMD
ping 200.1.2.2 (success)

Web 浏览器
http://200.1.2.2 (success)

R1

int fa 0/0
ip nat inside
int s 2/0
ip nat outside
exit
access-list 1 permit 192.168.1.0 0.0.0.255
ip nat pool jaking 200.1.1.3 200.1.1.3 netmask 255.255.255.0 #设置名称为jaking的地址池,起始和终止IP都是200.1.1.3
ip nat inside source list 1 pool jaking overload (无 overload 表示多对多,有 overload 表示多对一)
end
show ip nat translations(无结果)

PC1

Web 浏览器
http://200.1.2.2 (success)

R1

show ip nat translations(有 1 个结果)

PC2

Web 浏览器
http://200.1.2.2 (success)

R1

show ip nat translations(有 2 个结果)

実践演習

R1

Continue with configuration dialog? [yes/no]: n


Press RETURN to get started!



Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#host R1
R1(config)#int fa 0/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no shut

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R1(config-if)#int s 2/0
R1(config-if)#ip add 200.1.1.1 255.255.255.0
R1(config-if)#no shut

%LINK-5-CHANGED: Interface Serial2/0, changed state to down
R1(config-if)#clock rate 64000
R1(config-if)#

R2 

Continue with configuration dialog? [yes/no]: n


Press RETURN to get started!



Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#host R2
R2(config)#int s 2/0
R2(config-if)#ip add 200.1.1.2 255.255.255.0
R2(config-if)#no shut

%LINK-5-CHANGED: Interface Serial2/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up

R2(config-if)#int fa 0/0
R2(config-if)#ip add 200.1.2.1 255.255.255.0
R2(config-if)#no shut

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R2(config-if)#

R1

R1(config-if)#exit
R1(config)#ip route 200.1.2.0 255.255.255.0 200.1.1.2

R2

R2(config-if)#exit
R2(config)#ip route 192.168.1.0 255.255.255.0 200.1.1.1
R2(config)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console

R2#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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

Gateway of last resort is not set

S    192.168.1.0/24 [1/0] via 200.1.1.1
C    200.1.1.0/24 is directly connected, Serial2/0
C    200.1.2.0/24 is directly connected, FastEthernet0/0

PC1

CMD
ping 200.1.2.2 (success)

PC>ipconfig

IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1

PC>ping 200.1.2.2

Pinging 200.1.2.2 with 32 bytes of data:

Request timed out.
Reply from 200.1.2.2: bytes=32 time=24ms TTL=126
Reply from 200.1.2.2: bytes=32 time=25ms TTL=126
Reply from 200.1.2.2: bytes=32 time=20ms TTL=126

Ping statistics for 200.1.2.2:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 20ms, Maximum = 25ms, Average = 23ms

PC>ping 200.1.2.2

Pinging 200.1.2.2 with 32 bytes of data:

Reply from 200.1.2.2: bytes=32 time=25ms TTL=126
Reply from 200.1.2.2: bytes=32 time=20ms TTL=126
Reply from 200.1.2.2: bytes=32 time=23ms TTL=126
Reply from 200.1.2.2: bytes=32 time=25ms TTL=126

Ping statistics for 200.1.2.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 20ms, Maximum = 25ms, Average = 23ms

Web ブラウザ
http://200.1.2.2  (成功)

PC2

CMD
ping 200.1.2.2 (success)

PC>ipconfig

IP Address......................: 192.168.1.3
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1

PC>ping 200.1.2.2

Pinging 200.1.2.2 with 32 bytes of data:

Reply from 200.1.2.2: bytes=32 time=31ms TTL=126
Reply from 200.1.2.2: bytes=32 time=17ms TTL=126
Reply from 200.1.2.2: bytes=32 time=19ms TTL=126
Reply from 200.1.2.2: bytes=32 time=23ms TTL=126

Ping statistics for 200.1.2.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 17ms, Maximum = 31ms, Average = 22ms

Web ブラウザ
http://200.1.2.2 (成功)

R1

R1(config)#int fa 0/0
R1(config-if)#ip nat inside
R1(config-if)#int s 2/0
R1(config-if)#ip nat outside
R1(config-if)#exit
R1(config)#access-list 1 permit 192.168.1.0 0.0.0.255
R1(config)#ip nat pool jaking 200.1.1.3 200.1.1.3 netmask 255.255.255.0
R1(config)#ip nat inside source list 1 pool jaking overload
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console

R1#show ip nat translations
R1#


PC1

Web 浏览器
http://200.1.2.2 (success)

R1
show ip nat translations(有 1 个结果)

R1#show ip nat translations
Pro  Inside global     Inside local       Outside local      Outside global
tcp 200.1.1.3:1026     192.168.1.2:1026   200.1.2.2:80       200.1.2.2:80


PC2

Web 浏览器
http://200.1.2.2 (success)

R1
show ip nat translations(有 2 个结果)

R1#show ip nat translations
Pro  Inside global     Inside local       Outside local      Outside global
tcp 200.1.1.3:1026     192.168.1.2:1026   200.1.2.2:80       200.1.2.2:80
tcp 200.1.1.3:1024     192.168.1.3:1026   200.1.2.2:80       200.1.2.2:80

要約する

ここまでで、Cisco シミュレータを使用したネットワーク ポート アドレス変換 NAPT の設定が完了しました。

おすすめ

転載: blog.csdn.net/ok060/article/details/131269860