网络地址转换协议(NAT)及其应用实例
图2. 网络拓扑及地址 为了便于说明,我们首先明确四类地址的范围来定义企业内部、外部: 内部本地地址:企业内部的私有地址 内部全局地址:私有地址转换成为的公有地址 外部全局地址:internet上的公有地址 外部本地地址:internet上的公有地址转换成为的企业内部私有地址 (1) 配置IP地址 配置路由器R1的地址,f0/0的地址为192.168.1.200,255.255.255.0,f0/1的地址为 12.1.1.1 255.255.255.0。配置命令如下: R1>en R1#conf t Enter configuration commands, one perline. End with CNTL/Z. R1(config)#int f0/0 R1(config-if)#ip add 192.168.1.200 255.255.255.0 R1(config-if)#no sh R1(config-if)# R1(config-if)#int f0/1 R1(config-if)#ip add 12.1.1.1 255.255.255.0 R1(config-if)#no sh 配置路由器R2的地址,f0/0的地址为12.1.1.2 255.255.255.0,f0/1的地址为2.2.2.200 255.255.255.0。 R2>en R2#conf t Enter configuration commands, one perline. End with CNTL/Z. R2(config)#int f0/0 R2(config-if)#ip add 12.1.1.2 255.255.255.0 R2(config-if)#no sh R2(config-if)# R2(config-if)#int f0/1 R2(config-if)#ip add 2.2.2.200 255.255.255.0 R2(config-if)#no sh 配置结果如图3所示, 图3. IP配置结果 配置路由器R1,配置内容是接口f0/0连接的是企业内部私有地址,f0/1连接的是internet上的公有地址。配置命令如下: R1>en R1#conf t Enter configuration commands, one perline. End with CNTL/Z. R1(config)#int f0/0 R1(config-if)#ip nat inside R1(config-if)#exit R1(config)#int f0/1 R1(config-if)#ip nat outside R1(config-if)#exit (2) 创建NAT转换表 a. 静态NAT R1(config)#ip nat inside source static ? A.B.C.D Inside local IP address tcp Transmission ControlProtocol udp User Datagram Protocol R1(config)#ip nat inside source static192.168.1.1 ? A.B.C.D Inside global IP address R1(config)#ip nat inside source static192.168.1.1 12.1.1.11 R1(config)#ip nat inside source static192.168.1.2 12.1.1.12 R1(config)#end R1# %SYS-5-CONFIG_I: Configured from console byconsole
R1#show ip nat tr R1#show ip nat translations Pro Inside global Insidelocal Outside local Outside global --- 12.1.1.11 192.168.1.1 --- --- --- 12.1.1.12 192.168.1.2 静态NAT特点:一对一的对应关系,可以由外界主动访问内部做地址转换 b. 动态NAT 第一步:删除已建立的静态NAT R1#conf t Enter configuration commands, one perline. End with CNTL/Z. R1(config)#no ip nat inside source static192.168.1.2 12.1.1.12 R1(config)#no ip nat inside source static192.168.1.1 12.1.1.11 R1(config)#end R1# %SYS-5-CONFIG_I: Configured from console byconsole R1#show ip nat translations 第二步:匹配需要转换的数据包; R1(config)#access-list 1 permit 192.168.1.00.0.0.255 第三步:定义转换成为的地址池; R1(config)#ip nat pool BB 12.1.1.1112.1.1.12 netmask 255.255.255.0 第四步:关联数据包和地址池; R1(config)#ip nat inside source list 1 poolBB R1#show ip nat translations (编辑:应用网_阳江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |