《实验二十三PT.doc》由会员分享,可在线阅读,更多相关《实验二十三PT.doc(9页珍藏版)》请在三一文库上搜索。
1、PT 网络地址转换 NAT 配置实验一 :一、实验目标理解 NAT 网络地址转换的原理及功能;掌握静态 NAT 的配置,实现局域网访问互联网;二、实验背景公司欲发布 WWW 服务,现要求将内网 Web 服务器 IP 地址映射为全局 IP 地址,实现外部网络可访问 公司内部 Web 服务器。三、技术原理网络地址转换 NAT( Network Address Translation ),被广泛应用于各种类型 Internet 接入方式和各种 类型的网络中。原因很简单,NAT不仅完美解决了 IP地址不足的问题,而且还能够有效地避免来自网络外部的攻击,隐藏并保护网络内部的计算机。默认情况下,内部 IP
2、 地址是无法被路由到外网的,内部主机 10.1.1.1 要与外部 internet 通信, IP 包到达NAT路由器时,IP包头的源地址10.1.1.1被替换成一个合法的外网 IP,并在NAT转换表中 保存这条记录。当外部主机发送一个应答到内网时,NAT路由器收到后,查看当前 NAT转换表,用 10.1.1.1 替换掉这个外网地址。NAT将网络划分为内部网络和外部网络两部分,局域网主机利用NAT访问网络时,是将局域网内部的本地地址转换为全局地址(互联网合法的IP地址)后转发数据包。NAT分为两种类型:NAT(网络地址转换)和NAPT(网络端口地址转换 IP地址对应一个全局地址)。 静态NAT:
3、实现内部地址与外部地址一对一的映射。现实中,一般都用于服务器; 动态NAT:定义一个地址池,自动映射,也是一对一的。现实中,用得比较少;NAPT:使用不同的端口来映射多个内网 IP地址到一个指定的外网 IP地址,多对一。四、实验步骤实验拓扑NAT:222. 0. 1.3外网主机壯b服务器1、 R1为公司出口路由器,其与外部路由之间通过V.35电缆串口连接,DCE端连接在R2上,配置其时 钟频率为64000 ;2、 配置PC机、服务器及路由器接口IP地址;3、 在各路由器上配置静态路由协议,让PC间能相互ping通;4、在R1上配置静态 NAT;5、在R1上定义内外部网络接口;6、验证主机之间的
4、互通性。R1:Routere nRouter#c onftEn ter con figurati on comma nds, one per line.End with CNTL/Z.Router(config)#hostname R1/ 修改路由器名字R1(co nfig)#i nt fa0/0R1(config-if)#ip add 192.168.1.1 255.255.255.0/ 配置 fa0/0 端口 IPR1(co nfig-if)# no shutdow n/ 重新启动%LINK-5-CHANGED: In terface FastEthernet00, chan ged st
5、ate to up%LINEPROTO-5-UPDOWN: Line protocol on In terface FastEthernet0/0, cha nged state to upR1(co nfig-if)#exitR1(co nfig)#i nt s0/0/0R1(config-if)#ip add 222.0.1.1 255.255.255.0/ 配置 S0/0 端口 IPR1(c on fig-if)# no shutdow n%LINK-5-CHANGED: In terface Serial00, chan ged state to dow n%LINEPROTO-5-U
6、PDOWN: Line protocol on In terface Serial00, cha nged state to up/配置到222.0.2.0网段的静态路由R1(co nfig-if)#exitR1(co nfig)#ip route 222.0.2.0 255.255.255.0 222.0.1.2R1(co nfig)#e ndR1#%SYS-5-C0NFIG_l: Co nfigured from con sole by con soleR1#show ip routeCodes: C - connected, S - static, I - IGRPR - RIPM -
7、mobile, B - BGPD - EIGRPEX - EIGRP external, O - OSPF, IA - OSPF in ter areaN1 - 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 * - can didate default, U
8、- per-user static route, o - ODRP - periodic dow nl oaded static routeGateway of last resort is not setC 192.168.1.0/24 is directly connected, FastEthernetO/ 0C222.0.1.0/24 is directly conn ected, Serial0/ 0S 222.0.2.0/24 1/0 via 222.0.1.2需要R2也配置了 ip才能显示红色部分R1#co nf tEn ter con figurati on comma nds
9、, one per line.End with CNTL/Z.R1(co nfig)#i nt fa0/0R1(c on fig-if)#ip n at i nsideR1(co nfig-if)#exitR1(co nfig)#i nt s0/0/0R1(c on fig-if)#ip nat outsideR1(co nfig-if)#exitR1(co nfig)#R1#R1#co nf tEn ter con figurati on comma nds, one per line.End with CNTL/Z.R1(co nfig)#ip nat in side source sta
10、tic 192.168.1.2 222.0.1.3/ 配置内网到外网的静态NAT 映射R1(co nfig)#e ndR1#%SYS-5-CONFIG_I: Co nfigured from con sole by con soleR1#show ip nat tran slati onsProIn side globalIn side localOutside localOutside global-222.0.1.3192.168.1.2-R1#show runnin g-c onfigBuildi ng con figurati on.Current con figurati on :
11、753 bytes!version 12.2no service timestamps log datetime msecno service timestamps debug datetime msec no service password-e ncrypti on!host name R1 in terface FastEther netO/ 0ip address 192.168.1.1 255.255.255.0ip nat in side duplex auto speed auto!in terface FastEthernet1 /0no ip addressduplex au
12、to speed auto shutdow n!in terface Serial0/ 0ip address 222.0.1.1 255.255.255.0ip nat outside!in terface Serial3/0no ip address shutdow n!in terface FastEthernet4/0no ip addressshutdow n!in terface FastEther net5/0no ip addressshutdow n!ip n at i nside source static 192.168.1.2 222.0.1.3 ip classles
13、sip route 222.020 255.255.255.0 222.0.1.2 line con 0line vty 0 4logi nendR1#R2:RouterRoutere nRouter#c onf tEn ter con figurati on comma nds, one per line.End with CNTL/Z.Router(c on fig)#host name R2R2(co nfig)#i nt fa0/0R2(co nfig-if)#ip add 222.0.2.1 255.255.255.0R2(co nfig-if)# no shut%LINK-5-CH
14、ANGED: In terface FastEthernet00, chan ged state to up%LINEPROTO-5-UPDOWN: Line protocol on In terface FastEthernet0/0, cha nged state to upR2(co nfig-if)#exitR2(co nfig)#i nt s0/0/0R2(config-if)#ip add 222.0.1.2 255.255.255.0R2(co nfig-if)# no shut%LINK-5-CHANGED: In terface Serial00, cha nged stat
15、e to upR2(config-if)#clock rate 64000R2(co nfig-if)#%LINEPROTO-5-UPDOWN: Line protocol on In terface Serial00, cha nged state to upR2(co nfig-if)#R2(co nfig-if)#R2(co nfig-if)#exitR2(config)#ip route 192.168.1.0 255.255.255.0 222.0.1.1R2(co nfig)#e ndR2#%SYS-5-C0NFIG_l: Co nfigured from con sole by
16、con soleR2#show ip routeCodes: C - connected, S - static, I - IGRPR - RIPM - mobile, B - BGPD - EIGRPEX - EIGRP external, O - OSPF, IA - OSPF in ter areaN1 - 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
17、level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - can didate default, U - per-user static route, o - ODRP - periodic dow nl oaded static routeGateway of last resort is not setS 192.168.1.0/24 1/0 via 222.0.1.1C 222.0.1.0/24 is directly conn ected, Serial。/ 0C 222.0.2.0/24 is directly connected,
18、 FastEthernetO/ 0R2#五、验证PC1:Packet Tracer PC Comma nd Li ne 1.0PCipc onfigIP Address: 222.0.2.2Sub net Mask: 255.255.255.0Default Gateway: 222.0.2.1PCpi ng 192.168.1.2Pi nging 192.168.1.2 with 32 bytes of data:Request timed out.Reply from 192.168.1.2: bytes=32 time=19ms TTL=126Reply from 192.168.1.2
19、: bytes=32 time=17ms TTL=126Reply from 192.168.1.2: bytes=32 time=15ms TTL=126Ping statistics for 192.168.1.2:Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),Approximate round trip times in milli-sec on ds:Mi nimum = 15ms, Maximum = 19ms, Average = 17ms PCPC1-WEBPhysical Config Desktop实验在完成实验一的基础上,改造拓扑,完成如下拓扑,首先要关闭路由器 R1R2上的sO/O/O 口删除相关配置faO/1222.0.2.1/2斗faO/OfaO/1222.0.1.152, L68.1.1/24FA0/0FAO/1295J-24SwifchOFAO/2PC2 19L 163.LZ/24GATEWAY 192469,1,1I feo/o222.0.2.1222.0.2./24Server*PTPORTPC:主机思考1)此时同样是从PC主机访问内网服务器,URL应该怎么写?2)实验一和实验二的不同点 ?