我是靠谱客的博主 开放唇膏,这篇文章主要介绍NAT(地址转换技术)详解,现在分享给大家,希望可以做个参考。

目录

一.概述

二.优点

三.实现方式

总结


 

一.概述

中文名称,网络地址转换

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

NAT转换内网地址范围(源地址)

10.0.0.0-10.255.255.255

172.16.0.0-172.31.255.255

192.168.0.0-192.168.255.255

常用的原因(即应用方向)

有针对性,

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

2当更换ISP需要重新编址

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

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

二.优点

1.节省了公网IP地址

2.能够处理编址方案重叠的情况

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

4.隐藏了真正的IP地址

三.实现方式

出口路由器上需要配置默认路由

ip route-static 0.0.0.0 0 指向运营商接口IP

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

进入出接口

nat static globle 出口公网IP地址(此地址必须不是外网IP,是另外的租用的公网地址)inside 内部PCip地址 netmask 255.255.255.255

查看静态NAT映射情况

display nat static

公网接入路由器

[]ip route-static 出口公网IP地址(此地址必须不是外网IP,是另外的租用的公网地址)32 指向下一跳地址   //回指一条路由指向公司出口网关IP

AR1路由器设置

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<Huawei>u t m <Huawei>sys [Huawei]SY A [A]user-interface co0 [A-ui-console0]id 0 0 [A-ui-console0]q [A]int g0/0/0 [A-GigabitEthernet0/0/0]ip add 192.168.1.1 24 [A-GigabitEthernet0/0/0]undo shutdown [A-GigabitEthernet0/0/0]int g0/0/1 [A-GigabitEthernet0/0/1]ip add 202.10.100.1 24 [A-GigabitEthernet0/0/1]q [A]ip route-static 0.0.0.0 0 202.10.100.2 [A]int g0/0/1 [A-GigabitEthernet0/0/1]nat static global 14.4.3.15 inside 192.168.1.3 netmask 2 55.255.255.255 [A-GigabitEthernet0/0/1]q [A]int g0/0/1 [A-GigabitEthernet0/0/1]display this [V200R003C00] # interface GigabitEthernet0/0/1 ip address 202.10.100.1 255.255.255.0 nat static global 14.4.3.15 inside 192.168.1.3 netmask 255.255.255.255 # return [A-GigabitEthernet0/0/1]display nat static Static Nat Information: Interface : GigabitEthernet0/0/1 Global IP/Port : 14.4.3.15/---- Inside IP/Port : 192.168.1.3/---- Protocol : ---- VPN instance-name : ---- Acl number : ---- Netmask : 255.255.255.255 Description : ---- Total : 1

ISP路由器

复制代码
1
2
3
4
5
6
7
8
9
10
11
<Huawei>u t m <Huawei>sys [Huawei]sy isp [isp]user-interface co0 [isp-ui-console0]id 0 0 [isp-ui-console0]q [isp]int g0/0/0 [isp-GigabitEthernet0/0/0]ip add 202.10.100.2 24 [isp-GigabitEthernet0/0/0]undo shutdown [isp-GigabitEthernet0/0/0]q [isp]ip route-static 14.4.3.15 32 202.10.100.1

这是在PC1上pingISP服务器是通的,但是PC2不通

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

1)配置NAT地址池

全局下打nat address-group 1 15.0.0.10 15.0.0.11

2)配置ACL抓取内网地址段

[]acl 2000

[]rule permit source 网段 反掩码

这里是网段是指总网段

3)对接外网口上调用

接口下打nat outbound 2000 address-gtoup 1

公网接入路由器

[]ip route-static 15.0.0.0 24 下一跳地址  //ISP回指一条路由指向公司NAT外网地址池

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<Huawei>u t m <Huawei>sys [Huawei]sy A [A]user-interface CO0 [A-ui-console0]id 0 0 [A-ui-console0]q [A]int g0/0/0 [A-GigabitEthernet0/0/0]ip add 192.168.1.1 24 [A-GigabitEthernet0/0/0]undo shutdown [A-GigabitEthernet0/0/0]int g0/0/1 [A-GigabitEthernet0/0/1]ip add 202.10.100.1 24 [A-GigabitEthernet0/0/1]undo shutdown [A-GigabitEthernet0/0/1]q [A]ip route-static 0.0.0.0 0 202.10.100.2 [A]nat address-group 1 15.0.0.10 15.0.0.11 [A]acl 2000 [A-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255 [A-acl-basic-2000]q [A]int g0/0/1 [A-GigabitEthernet0/0/1]nat outbound 2000 address-group 1
复制代码
1
2
3
4
5
6
7
8
9
10
11
<Huawei>u t m <Huawei>sy [Huawei]sy ISP [ISP]user-interface co0 [ISP-ui-console0]id 0 0 [ISP-ui-console0]q [ISP]int g0/0/0 [ISP-GigabitEthernet0/0/0]ip add 202.10.100.2 24 [ISP-GigabitEthernet0/0/0]undo shutdown [ISP-GigabitEthernet0/0/0]q [ISP]ip route-static 15.0.0.0 24 202.10.100.1

这里测试结果就是两台PC都可以ping通外网地址

 

 3.Easyip多个内网地址对一个接口

进入外网口

接口下输入nat outbound 2000

查看nat命令

display nat outbound

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<Huawei>u t m <Huawei>sy [Huawei]sy A [A]user-interface co0 [A-ui-console0]id 0 0 [A-ui-console0]int g0/0/0 [A-GigabitEthernet0/0/0]ip add 192.168.1.1 24 [A-GigabitEthernet0/0/0]undo shutdown [A-GigabitEthernet0/0/0]int g0/0/1 [A-GigabitEthernet0/0/1]ip add 202.10.100.1 24 [A-GigabitEthernet0/0/1]undo shutdown [A-GigabitEthernet0/0/1]q [A]ip route-static 0.0.0.0 0 202.10.100.2 [A]acl 2000 [A-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255 [A-acl-basic-2000]q [A]int g0/0/1 [A-GigabitEthernet0/0/1]nat outbound 2000 [A-GigabitEthernet0/0/1]q
复制代码
1
2
3
4
5
6
7
8
9
10
<Huawei>u t m <Huawei>sy [Huawei]SY ISP [ISP]user-interface co0 [ISP-ui-console0]id 0 0 [ISP-ui-console0]q [ISP]int g0/0/0 [ISP-GigabitEthernet0/0/0]ip add 202.10.100.2 24 [ISP-GigabitEthernet0/0/0]undo shutdown [ISP-GigabitEthernet0/0/0]q

 这种情况下PC机都可以ping通ISP

4.静态PAT(一对一,是外网IP和服务映射内网服务器的IP和服务)

在中继路由器上配置NAT地址池

全局下打nat address-group 1 15.0.0.10 15.0.0.11

进入外网口

接口下输入nat server protocol tcp global 15.0.0.10 21(端口号)inside 内网服务器IP地址  端口号

验证

[]display nat sever//查看nat 外网IP和内网服务器服务的映射是否成功

注意:FTP服务默认数据端口没有开启,需要手工去开

全局下打nat alg ftp enable

             nat alg dns enable

             nat alg all enable  

 

 这里要注意把原来的PC机换成server服务器

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<Huawei>u t m <Huawei>sy [Huawei]sy A [A]user-interface co0 [A-ui-console0]id 0 0 [A-ui-console0]q [A]int g0/0/0 [A-GigabitEthernet0/0/0]ip add 192.168.1.1 24 [A-GigabitEthernet0/0/0]undo shutdown [A-GigabitEthernet0/0/0]int g0/0/1 [A-GigabitEthernet0/0/1]ip add 202.10.100.1 24 [A-GigabitEthernet0/0/1]undo shutdown [A-GigabitEthernet0/0/1]q [A]ip route-static 0.0.0.0 0 202.10.100.2 [A]nat address-group 1 15.0.0.10 15.0.0.11 [A]int g0/0/1 [A-GigabitEthernet0/0/1]nat server protocol tcp global 15.0.0.10 21 inside 192.1 68.1.3 21 [A-GigabitEthernet0/0/1]q
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
<Huawei>u t m <Huawei>sy [Huawei]SYS ISP [ISP]user-interface co0 [ISP-ui-console0]id 0 0 [ISP-ui-console0]q [ISP]int g0/0/0 [ISP-GigabitEthernet0/0/0]ip add 202.10.100.2 24 [ISP-GigabitEthernet0/0/0]undo shutdown [ISP-GigabitEthernet0/0/0]q [ISP]ip route-static 15.0.0.10 32 202.10.100.1 [ISP]q

配置结束后,在server服务器上开启ftp功能,然后在外网机上连接内网服务

复制代码
1
2
3
4
5
6
7
8
9
10
11
<ISP>ftp 15.0.0.10 Trying 15.0.0.10 ... Press CTRL+K to abort Connected to 15.0.0.10. 220 FtpServerTry FtpD for free User(15.0.0.10:(none)): 331 Password required for . Enter password: 230 User logged in , proceed

 总结

四种NAT设置方法

nat的优点

最后

以上就是开放唇膏最近收集整理的关于NAT(地址转换技术)详解的全部内容,更多相关NAT(地址转换技术)详解内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(82)

评论列表共有 0 条评论

立即
投稿
返回
顶部