文档库 最新最全的文档下载
当前位置:文档库 › 网络地址转换NAT配置实验

网络地址转换NAT配置实验

网络地址转换NAT配置实验
网络地址转换NAT配置实验

. . 实验 网络地址转换NAT 配置实验

学号 _________ 学生 _____ 实验时间____________________ 课程名称:交换机/路由器配置

辅导教师:泰峰

任务一 利用动态NAPT 实现局域网访问互联网

[实验名称]

利用动态NAPT 实现局域网访问互联网。

[实验目的]

掌握网中所有主机连接到Internet 网时,通过端口号区分的复用部全局地址转换。

[背景描述]

你是某公司的网络管理员,公司只向ISP 申请了一个公网IP 地址,希望全公司的主机都能访问外网,请你实现。

[技术原理]

NAT(网络地址转换或网络地址翻译),是指将网络地址从一个地址空间转换为另一个地址空间的行为。

NAT 将网络划分为部网络(inside)和外部网络(outside)两部分。局域网主机利用NAT 访问网络时,是将局域网部的本地地址转换为全局地址(互联网合法IP 地址)后转发数据包。

NAT 分为两种类型:NA T(网络地址转换)和NAPT(网络地址端口转换)。NAT 是实现转换后一个本地IP 地址对应与一个全局地址。NAPT 是实现转换后多个IP 地址对应一个全局地址。目前网络中由于公网IP 地址紧缺,而局域网主机数较多,因此一般使用动态的NAPT 实现局域网多台主机共用一个或少数几个公网IP 访问互联网。

[实现功能]

允许部所有主机在公网地址缺乏的情况下可以访问外部网络。

[实验设备]

R1762路由器(两台)、V .35线缆(1条)、PC (两台)直连线或交叉线(2)

[实验拓扑]

[实验步骤]

步骤1. 基本配置

192.17.4.1/24 F1/0 192.17.3.1/24 192.17.4.2/24 192.17.3.2/24 S1/2 S1/2 R1 Lan-router Internet-router F1/0 192.17.1.1/24 192.17.1.2/24 R2

局域网路由器Router2 基本配置

router#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

router(config)#hostname router2

router2(config)#interface fastEthernet 1/0

router2(config-if)#ip add 192.17.4.1 255.255.255.0

router2(config-if)#no shutdown

router2(config-if)#exit

router2(config)#interface serial 1/2

router2(config-if)#ip add 192.17.3.2 255.255.255.0

router2(config-if)#no shutdown

router2(config-if)#end

router2#

测试命令:show ip interface brief。

Router2#show ip int brief !观察接口状态Interface IP-Address(Pri) OK? Status serial 1/2 192.17.3.2/24 YES UP serial 1/3 no address YES DOWN FastEthernet 1/0 192.17.4.1/24 YES UP FastEthernet 1/1 no address YES DOWN Null 0 no address YES UP

互联网路由器Router1 基本配置

router>enable

Password:

router#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

router(config)#hostname router1

router1(config)#interface fastEthernet 1/0

router1(config-if)#ip add 192.17.1.1 255.255.255.0

router1(config-if)#no shutdown

router1(config-if)#exit

router1(config)#interface serial 1/2

router1(config-if)#ip add 192.17.3.1 255.255.255.0

router1(config-if)#clock rate 64000

router1(config-if)#no shutdown

router1(config-if)#exit

router1(config)#end

router1#

测试命令:show ip interface brief 。

Router1#show ip int brief ! 观察接口状态Interface IP-Address(Pri) OK? Status

.

.

serial 1/2 192.17.3.1/24 YES UP

serial 1/3 no address YES DOWN

FastEthernet 1/0 192.17.1.1/24 YES UP

FastEthernet 1/1 no address YES DOWN

Null 0 no address YES UP

在局域网路由器R2上配置静态路由

router2(config)#ip route 0.0.0.0 0.0.0.0 serial 1/2

在互联网路由器R1上配置静态路由

Router1(config)#ip route 0.0.0.0 0.0.0.0 serial 1/2

测试命令:show ip route 。

Router1#show ip route !查看路由表信息

Router2#show ip route

步骤2. 配置动态NAPT映射。

router2(config)#interface f1/0

router2(config-if)#ip nat inside !定义F1/0为网接口

router2(config-if)#exit

router2(config)#interface s1/2

router2(config-if)#ip nat outside !定义S1/2为外网接口

router2(config-if)#exit

router2(config)#ip nat pool to_internet 192.17.3.2 192.17.3.2 netmask 255.255.255.0 !定义部全局地址池

router2(config)#access-list 10 permit 192.17.4.0 0.0.0.255 !定义允许转换的地址router2(config)#ip nat inside source list 10 pool to_internet overload

!为部本地调用转换地址池

router2(config)#end

步骤3. 验证测试。

1、在服务器192.17.1.2上配置Web服务。

2、在PC机192.17.4.2上测试访问192.17.1.2的网页。

3、在局域网路由器R2上查看NAPT的映射关系。

router2#show ip nat translations

Pro Inside global Inside local Outside local Outside global

tcp 192.17.3.2:1094 192.17.4.2:1094 192.17.1.2:80 192.17.1.2:80

tcp 192.17.3.2:1093 192.17.4.2:1093 192.17.1.2:80 192.17.1.2:80

[注意事项]

1、不要把inside和outside应用的接口弄错。

2、要加上能使数据包向外转发的路由,比如默认路由。

3、尽量不要使用广域网接口地址作为映射的全局地址,本例中特定仅有一个公网地址,实际

工作中不推荐。

.

.

[参考配置]

Router1#show running-config !查看路由器1的全部配置Router2#show running-config !查看路由器2的全部配置

.

.

. . 任务二 利用NAT 实现外网主机访问网服务器

[实验名称]

利用NAT 实现外网主机访问网服务器。

[实验目的]

掌握NAT 源地址转换和目的地址转换的区别,掌握如何向外网发布网的服务器。

[背景描述]

你是某公司的网络管理员,公司只向ISP 申请了一个公网IP 地址,现公司的在网,要求在互联网也可以访问公司,请你实现。192.17.4.2是公司Web 服务器的IP 地址。

[技术原理]

NAT(网络地址转换或网络地址翻译),是指将网络地址从一个地址空间转换为另一个地址空间的行为。

NAT 将网络划分为部网络(inside)和外部网络(outside)两部分。局域网主机利用NAT 访问网络时,是将局域网部的本地地址转换为全局地址(互联网合法IP 地址)后转发数据包。

NAT 分为两种类型:NA T(网络地址转换)和NAPT(网络地址端口转换)。NAT 是实现转换后一个本地IP 地址对应与一个全局地址。NAPT 是实现转换后多个IP 地址对应一个全局地址。目前网络中由于公网IP 地址紧缺,而局域网主机数较多,因此一般使用动态的NAPT 实现局域网多台主机共用一个或少数几个公网IP 访问互联网。

[实现功能]

网服务器能够转换成外网公网IP,被互联网访问。

[实验设备]

R1762路由器(两台)、V .35线缆(1条)、PC (两台)直连线或交叉线(2)

[实验拓扑]

[实验步骤]

步骤1. 基本配置

局域网路由器Router2 基本配置

router#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

router(config)#hostname router2

router2(config)#interface fastEthernet 1/0

router2(config-if)#ip add 192.17.4.1 255.255.255.0

router2(config-if)#no shutdown

router2(config-if)#exit

router2(config)#interface serial 1/2

Lan-router Internet-router F1/0 192.17.3.1/24 192.17.4.2/24 192.17.3.2/24 S1/2 S1/2 R1 F1/0 192.17.1.1/24 192.17.1.2/24 R2 192.17.4.1/24

router2(config-if)#ip add 192.17.3.2 255.255.255.0

router2(config-if)#no shutdown

router2(config-if)#end

router2#

测试命令:show ip interface brief。

Router2#show ip int brief !观察接口状态Interface IP-Address(Pri) OK? Status serial 1/2 192.17.3.2/24 YES UP serial 1/3 no address YES DOWN FastEthernet 1/0 192.17.4.1/24 YES UP FastEthernet 1/1 no address YES DOWN Null 0 no address YES UP

互联网路由器Router1 基本配置

router>enable

Password:

router#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

router(config)#hostname router1

router1(config)#interface fastEthernet 1/0

router1(config-if)#ip add 192.17.1.1 255.255.255.0

router1(config-if)#no shutdown

router1(config-if)#exit

router1(config)#interface serial 1/2

router1(config-if)#ip add 192.17.3.1 255.255.255.0

router1(config-if)#clock rate 64000

router1(config-if)#no shutdown

router1(config-if)#exit

router1(config)#end

router1#

测试命令:show ip interface brief 。

Router1#show ip int brief ! 观察接口状态Interface IP-Address(Pri) OK? Status serial 1/2 192.17.3.1/24 YES UP serial 1/3 no address YES DOWN FastEthernet 1/0 192.17.1.1/24 YES UP FastEthernet 1/1 no address YES DOWN Null 0 no address YES UP

在局域网路由器R2上配置静态路由

router2(config)#ip route 0.0.0.0 0.0.0.0 serial 1/2

在互联网路由器R1上配置静态路由

Router1(config)#ip route 0.0.0.0 0.0.0.0 serial 1/2

.

.

测试命令:show ip route 。

Router1#show ip route !查看路由表信息

Router2#show ip route

步骤2. 配置反向NAT映射。

router2(config)#interface f1/0

router2(config-if)#ip nat inside !定义F1/0为网接口

router2(config-if)#exit

router2(config)#interface s1/2

router2(config-if)#ip nat outside !定义S1/2为外网接口

router2(config-if)#exit

router2(config)#ip nat pool web_server 192.17.4.2 192.17.4.2 netmask 255.255.255.0 !定义网服务器地址池

router2(config)#access-list 3 permit host 192.17.3.2 !定义外网的公网IP地址router2(config)#ip nat inside destination list 3 pool web_server

!将外网的公网IP地址转换为Web服务器地址

router2(config)#ip nat inside source static tcp 192.17.4.2 80 192.17.3.2 80

!定义访问外网IP的80端口时转换为网的服务器IP的80端口

步骤3. 验证测试。

1、在网主机192.17.4.2上配置Web服务。

2、在外网1台PC机192.17.1.2上测试访问192.17.4.2的网页。

3、在局域网路由器R2上查看NA T的映射关系。

router2#show ip nat translations

Pro Inside global Inside local Outside local Outside global

tcp 192.17.3.2:80 192.17.4.2:80 192.17.1.2:1281 192.17.1.2:1281

[注意事项]

1、不要把inside和outside应用的接口弄错。

2、要加上能使数据包向外转发的路由,比如默认路由。

3、配置目标地址转换后,需要利用静态NAPT配置静态的端口地址转换。

[参考配置]

Router1#show running-config !查看路由器1的全部配置

Router2#show running-config !查看路由器2的全部配置

.

.

相关文档