NAT--网络地址转换

目录

一、NAT

1、作用

2、NAT转换内网地址的范围

3、NAT为什么常用

4、NAT的优点

二、NAT的使用方法

1、静态NAT(一个内网地址对一个公网地址)

2、动态NAT--PAT(多个内网地址对多个公网地址)

3、Easyip(多个公网地址对一个接口)

4、静态PAT(一对一,但是外网口IP和内网服务器服务的映射是否成功)

三、总结


 

一、NAT

NAT--网络地址装换

1、作用

将内部(私有)地址转换成外部(公有)地址

2、NAT转换内网地址的范围

10.0.0.0--10.255.255.255

172.16.0.0--192.31.255.255

192.168.0.0--192.168.255.255

3、NAT为什么常用

常用是因为它有针对性,即下面的四个方向作为主要常用方向:

1.没有足够的公网IP连接到Internet

2.当更换ISP需要重新编址

3.合并使用重叠地址空间的内部网络

4.使用单个IP地址支持基本的负载分担

4、NAT的优点

1.节省了公网IP地址

2.能够处理编址方案重叠的问题

3.网络发生变化时不需要重新编址

4.隐藏了真正的IP地址

二、NAT的使用方法

1、静态NAT(一个内网地址对一个公网地址)


 

PC1:192.168.1.10 255.255.255.0  192.168.1.1    PC1的IP地址、子网掩码和网关

PC2:192.168.1.20 255.255.255.0  192.168.1.1    PC2的IP地址、子网掩码和网关 

 R1配置:

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname R1                    更改名字为R1

[R1]user-interface console 0          

[R1-ui-console0]idle-timeout 0 0     永不超时

[R1]int g0/0/0                                     进入接口g0/0/0 

[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24      设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/0]undo shutdown                  开启接口

[R1-GigabitEthernet0/0/0]int g0/0/1                           进入接口g0/0/1

[R1-GigabitEthernet0/0/1]ip add 202.10.100.1 24     设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/1]undo shutdown                 开启接口

[R1]int g0/0/1                                                             进入接口g0/0/1

[R1-GigabitEthernet0/0/1]nat static global 15.0.0.10 inside 192.168.1.10 netmask  255.255.255.255         

                                       

 

ISP配置

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname ISP                    更改名字为ISP

[ISP]user-interface console 0          

[ISP-ui-console0]idle-timeout 0 0     永不超时

[ISP]int g0/0/0                                     进入接口g0/0/0 

[ISP-GigabitEthernet0/0/0]ip add 202.10.200.2  24      设置接口IP地址与子网掩码长度

[ISP-GigabitEthernet0/0/0]undo shutdown                  开启接口

[ISP]ip route-static 15.0.0.10 32 202.10.100.1    ISP回指一条路由指向公司出口网关IP

测试通信

PC1>ping 202.10.100.2

 

 

PC2>ping 202.10.100.2 

 

此时PC1能访问ISP ,PC2不能访问

2、动态NAT--PAT(多个内网地址对多个公网地址)

 

 

PC1:192.168.1.10 255.255.255.0  192.168.1.1    PC1的IP地址、子网掩码和网关

PC2:192.168.1.20 255.255.255.0  192.168.1.1    PC2的IP地址、子网掩码和网关 

 R1配置:

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname R1                    更改名字为R1

[R1]user-interface console 0          

[R1-ui-console0]idle-timeout 0 0     永不超时

[R1]int g0/0/0                                     进入接口g0/0/0 

[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24      设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/0]undo shutdown                  开启接口

[R1-GigabitEthernet0/0/0]int g0/0/1                           进入接口g0/0/1

[R1-GigabitEthernet0/0/1]ip add 202.10.100.1 24     设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/1]undo shutdown                 开启接口

[R1]ip route-static 0.0.0.0 0 202.10.100.2

 [R1]nat address-group 1 15.0.0.10 15.0.0.11

[R1]acl 2000

[R1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255

[R1]int g0/0/1                                     进入接口g0/0/01

[R1-GigabitEthernet0/0/1]nat outbound 2000 address-group 1

 ISP配置

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname ISP                    更改名字为ISP

[ISP]user-interface console 0          

[ISP-ui-console0]idle-timeout 0 0     永不超时

[ISP]int g0/0/0                                     进入接口g0/0/0 

[ISP-GigabitEthernet0/0/0]ip add 202.10.200.2  24      设置接口IP地址与子网掩码长度

[ISP-GigabitEthernet0/0/0]undo shutdown                  开启接口

[ISP]ip route-static 15.0.0.0 32 202.10.100.1    ISP回指一条路由指向公司出口网关IP

测试通信: 

PC1>ping 202.10.100.2

 PC2>ping 202.10.100.2

 

 此时PC1与PC2都能访问ISP

3、Easyip(多个公网地址对一个接口)

 

 R1配置:

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname R1                    更改名字为R1

[R1]user-interface console 0          

[R1-ui-console0]idle-timeout 0 0     永不超时

[R1]int g0/0/0                                     进入接口g0/0/0 

[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24      设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/0]undo shutdown                  开启接口

[R1-GigabitEthernet0/0/0]int g0/0/1                           进入接口g0/0/1

[R1-GigabitEthernet0/0/1]ip add 202.10.100.1 24     设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/1]undo shutdown                 开启接口

[R1]ip route-static 0.0.0.0 0 202.10.100.2

[R1]acl 2000

[R1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255

[R1]int g0/0/1                                     进入接口g0/0/01

[R1-GigabitEthernet0/0/1]nat outbound 2000

 

ISP配置:

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname ISP                    更改名字为ISP

[ISP]user-interface console 0          

[ISP-ui-console0]idle-timeout 0 0     永不超时

[ISP]int g0/0/0                                     进入接口g0/0/0 

[ISP-GigabitEthernet0/0/0]ip add 202.10.200.2  24      设置接口IP地址与子网掩码长度

[ISP-GigabitEthernet0/0/0]undo shutdown                  开启接口

 

 测试通信:

PC1>ping 202.10.100.2

 

 

PC2>ping 202.10.100.2

 

 此时PC1与PC2都能访问ISP

4、静态PAT(一对一,但是外网口IP和内网服务器服务的映射是否成功)

 

 R1配置:

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname R1                    更改名字为R1

[R1]user-interface console 0          

[R1-ui-console0]idle-timeout 0 0     永不超时

[R1]int g0/0/0                                     进入接口g0/0/0 

[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24      设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/0]undo shutdown                  开启接口

[R1-GigabitEthernet0/0/0]int g0/0/1                           进入接口g0/0/1

[R1-GigabitEthernet0/0/1]ip add 202.10.100.1 24     设置接口IP地址与子网掩码长度

[R1-GigabitEthernet0/0/1]undo shutdown                 开启接口

[R1]ip route-static 0.0.0.0 0 202.10.100.2

[R1]int g0/0/1

[R1-GigabitEthernet0/0/1]nat server protocol tcp global 15.0.0.10 21 inside 192.
168.1.10 21

 

ISP配置:

<Huawei>undo terminal monitor    关不弹窗

 [Huawei]sysname ISP                    更改名字为ISP

[ISP]user-interface console 0          

[ISP-ui-console0]idle-timeout 0 0     永不超时

[ISP]int g0/0/0                                     进入接口g0/0/0 

[ISP-GigabitEthernet0/0/0]ip add 202.10.200.2  24      设置接口IP地址与子网掩码长度

[ISP-GigabitEthernet0/0/0]undo shutdown                  开启接口

[ISP]ip route-static 15.0.0.10 32 202.10.100.1

 

 验证:

ISP上访问server

<ISP>ftp 15.0.0.10

 

三、总结

NAT四种实现方式,NAT 的优点 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值