当前位置:文档之家› 网络地址转换NAT配置

网络地址转换NAT配置

Packet Tracer 5.2实验(十四) 网络一、实验目标•理解NAT网络地址转换的原理及功能;•掌握静态NAT的配置,实现局域网访问互联网;二、实验背景公司欲发布WWW服务,现要求将内网Web服务器IP地址映射为全局IP地址,实现外部网络可访问公司内部Web服务器。

三、技术原理•网络地址转换NAT(NetworkAddress Translation),被广泛应用于各种类型Internet接入方式和各种类型的网络中。

原因很简单,NAT不仅完美解决了IP地址不足的问题,而且还能够有效地避免来自网络外部的攻击,隐藏并保护网络内部的计算机。

•默认情况下,内部IP地址是无法被路由到外网的,内部主机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:实现内部地址与外部地址一对一的映射。

现实中,一般都用于服务器;•动态NAT:定义一个地址池,自动映射,也是一对一的。

现实中,用得比较少;•NAPT:使用不同的端口来映射多个内网IP地址到一个指定的外网IP地址,多对一。

四、实验步骤实验拓扑1、R1为公司出口路由器,其与外部路由之间通过V.35电缆串口连接,DCE端连接在R2上,配置其时钟频率为64000;2、配置PC机、服务器及路由器接口IP地址;3、在各路由器上配置静态路由协议,让PC间能相互ping通;4、在R1上配置静态NAT;5、在R1上定义内外部网络接口;6、验证主机之间的互通性。

R1:Router>enRouter#conf tEnter configuration commands,one per line. End with CNTL/Z.Router(config)#hostname R1R1(config)#int fa0/0R1(config-if)#ip add192.168.1.1 255.255.255.0R1(config-if)#no shut%LINK-5-CHANGED: InterfaceFastEthernet0/0, changed stateto up%LINEPROTO-5-UPDOWN: Lineprotocol on InterfaceFastEthernet0/0, changed stateto upR1(config-if)#exitR1(config)#int s2/0R1(config-if)#ip add 222.0.1.1255.255.255.0R1(config-if)#no shut%LINK-5-CHANGED: InterfaceSerial2/0, changed state to downR1(config-if)#%LINK-5-CHANGED: InterfaceSerial2/0, changed state to up%LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial2/0,changed state to upR1(config-if)#R1(config-if)#R1(config-if)#exitR1(config)#ip route 222.0.2.0255.255.255.0 222.0.1.2 //配置到222.0.2.0网段的静态路由R1(config)#endR1#%SYS-5-CONFIG_I: Configuredfrom console by consoleR1#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - 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 routeGateway of last resort is not setC 192.168.1.0/24 is directly connected, FastEthernet0/0C 222.0.1.0/24 is directly connected, Serial2/0S 222.0.2.0/24 [1/0] via 222.0.1.2R1#R1#R1#conf tEnter configuration commands, one per line. End with CNTL/Z. R1(config)#int fa0/0R1(config-if)#?arp Set arp type (arpa, probe, snap) or timeout bandwidth Set bandwidth informational parametercdp CDP interface subcommandscryptoEncryption/Decryption commands custom-queue-list Assign acustom queue list to an interface delay Specify interface throughput delaydescription Interface specific descriptionduplex Configure duplex operation.exit Exit from interface configuration modefair-queue Enable Fair Queuing on an Interfacehold-queue Set hold queue depthip Interface Internet Protocol config commandsmac-address Manuallyset interface MAC addressmtu Set the interface Maximum Transmission Unit (MTU)no Negate a command or set its defaultspriority-group Assign a priority group to an interface service-policy Configure QoS Service Policyshutdown Shutdown the selected interfacespeed Configure speed operation.tx-ring-limit Configure PA level transmit ring limitzone-member Apply zone nameR1(config-if)#ip ?access-group Specify access control for packetsaddress Set the IP address of an interfacehello-intervalConfigures IP-EIGRP hello intervalhelper-address Specify adestination address for UDP broadcastsinspect Apply inspect nameips Create IPS rulemtu Set IP Maximum Transmission Unitnat NATinterface commandsospf OSPFinterface commandssplit-horizon Perform split horizonsummary-address Perform address summarizationvirtual-reassembly Virtual ReassemblyR1(config-if)#ip nat ?inside Inside interface for address translationoutside Outside interface for address translationR1(config-if)#ip nat inside ? <cr>R1(config-if)#ip nat insideR1(config-if)#exitR1(config)#int s2/0R1(config-if)#ip nat outside ? <cr>R1(config-if)#ip nat outside R1(config-if)#exitR1(config)#R1#R1#R1#conf tEnter configuration commands, one per line. End with CNTL/Z. R1(config)#ip ?access-list Namedaccess-listdefault-network Flags networks as candidates for default routesdhcp Configure DHCP server and relay parameters domain IP DNSResolverdomain-lookup Enable IP Domain Name System hostname translationdomain-name Define the default domain nameforward-protocol Controls forwarding of physical and directed IP broadcastshost Add an entryto the ip hostname tablename-server Specify address of name server to usenat NATconfiguration commandsroute Establishstatic routestcp Global TCP parametersR1(config)#ip nat ?inside Inside address translationoutside Outside address translationpool Define pool of addressesR1(config)#ip nat inside ?source Source address translationR1(config)#ip nat inside source ? list Specify access list describing local addressesstatic Specify staticlocal->global mappingR1(config)#ip nat inside source static ?A.B.C.D Inside local IP addresstcp Transmission Control Protocoludp User DatagramProtocolR1(config)#ip nat inside sourcestatic 192.168.1.2 ?A.B.C.D Inside global IPaddressR1(config)#ip nat inside sourcestatic 192.168.1.2 222.0.1.3 ?<cr>R1(config)#ip nat inside sourcestatic 192.168.1.2 222.0.1.3 //配置内网到外网的静态NAT映射R1(config)#endR1#%SYS-5-CONFIG_I: Configuredfrom console by consoleR1#show ip nat ?statistics Translationstatisticstranslations TranslationentriesR1#show ip nat translationsPro Inside global Insidelocal Outside localOutside global--- 222.0.1.3192.168.1.2 ------R1#R1#show ip nat translationsPro Inside global Insidelocal Outside localOutside global--- 222.0.1.3192.168.1.2 ------tcp 222.0.1.3:80192.168.1.2:80222.0.2.2:1025222.0.2.2:1025R1#R1#show running-configBuilding configuration...Current configuration : 753 bytes!version 12.2no service timestamps log datetime msecno service timestamps debug datetime msecno service password-encryption !hostname R1!...!interface FastEthernet0/0ip address 192.168.1.1255.255.255.0ip nat insideduplex autospeed auto!interface FastEthernet1/0no ip addressduplex autospeed autoshutdown!interface Serial2/0ip address 222.0.1.1255.255.255.0ip nat outside!interface Serial3/0no ip addressshutdown!interface FastEthernet4/0no ip addressshutdown!interface FastEthernet5/0no ip addressshutdownip nat inside source static 192.168.1.2 222.0.1.3ip classlessip route 222.0.2.0 255.255.255.0 222.0.1.2!...!line con 0line vty 0 4login!!!endR1#R2:Router>Router>enRouter#conf tEnter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R2R2(config)#int fa0/0R2(config-if)#ip add 222.0.2.1 255.255.255.0R2(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 upR2(config-if)#exitR2(config)#int s2/0R2(config-if)#ip add 222.0.1.2 255.255.255.0R2(config-if)#no shut%LINK-5-CHANGED: Interface Serial2/0, changed state to up R2(config-if)#clock rate 64000 R2(config-if)#%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to upR2(config-if)#R2(config-if)#R2(config-if)#exitR2(config)#ip route 192.168.1.0 255.255.255.0 222.0.1.1R2(config)#endR2#%SYS-5-CONFIG_I: Configured from console by consoleR2#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - 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 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 connected, Serial2/0C 222.0.2.0/24 is directly connected, FastEthernet0/0R2#PC1:Packet Tracer PC Command Line 1.0 PC>ipconfigIP Address......................: 222.0.2.2Subnet Mask.....................:255.255.255.0Default Gateway.................:222.0.2.1PC>ping 192.168.1.2Pinging 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: 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-seconds:Minimum = 15ms, Maximum = 19ms, Average = 17msPC>PC1-WEB:。

相关主题