加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 综合聚焦 > 酷站推荐 > 酷站 > 正文

网络地址转换协议(NAT)及其应用实例

发布时间:2019-12-31 18:28:30 所属栏目:酷站 来源:站长网
导读:副标题#e# 当在专用网内部的一些主机本来已经分配到了本地IP地址(即仅在本专用网内使用的专用地址),但现在又想和因特网上的主机通信(并不需要加密)时,可使用NAT(Network Address Translation,网络地址转换)方法。 这种方法需要在专用网连接到因特网的路

网络地址转换协议(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所示,

网络地址转换协议(NAT)及其应用实例

图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 

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读