华为,思科、华三3大厂商nat技术总结

举报
rivers 发表于 2021/12/22 22:50:58 2021/12/22
【摘要】 文章目录 三大厂商的nat技术的实现华为 nat 技术配置CISCO nat技术配置H3C nat技术配置 三大厂商的nat技术的实现 华为 nat 技术配置 1.技术背景 ...

三大厂商的nat技术的实现

在这里插入图片描述

华为 nat 技术配置

1.技术背景

  • NAT技术简介

    1.网络地址转换NAT(Network Address Translation)是将IP数据报文头中的IP地址转换为另一个IP地址的过程。
    2.随着Internet的发展和网络应用的增多,IPv4地址枯竭已成为制约网络发展的瓶颈

    3.NAT主要用于实现内部网络(简称内网,使用私有IP地址)访问外部网络(简称外网,使用公有IP地址)的功能

    4.NAT通过地址重用的方法来满足IP地址的需要,可以在一定程度上缓解IP地址空间枯竭的压力。还有2个好处:

    • 有效避免来自外网的攻击,可以很大程度上提高网络安全性。
    • 控制内网主机访问外网,同时也可以控制外网主机访问内网,解决了内网和外网不能互通的问题
  • NAT技术分类

    Basic NAT是实现一对一的IP地址转换,而NAPT可以实现多个私有IP地址映射到同一个公有IP地址上。

在这里插入图片描述

现网环境下,NAT功能的实现还得依据Basic NAT和NAPT的原理,NAT实现主要包括:Easy IP、地址池NAT、NAT Server和静态NAT/NAPT。
由于Basic NAT这种一对一的转换方式并未实现公网地址的复用,不能有效解决IP地址短缺的问题,因此在实际应用中并不常用。
NAT设备拥有的公有IP地址数目要远少于内部网络的主机数目,这是因为所有内部主机并不会同时访问外部网络。公有IP地址数目的确定,应根据网络高峰期可能访问外部网络的内部主机数目的统计值来确定。


  
 
  • 1
  • 2
  • 3
  • 4

2.实验拓扑

在这里插入图片描述

3.实验需求

配置nat使私网能够访问公网,公网可以访问私网的服务器

4.实验步骤

1.1基础配置

R1
<Huawei>sy
[Huawei]sy R1
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip ad 10.1.12.1 24 
[R1-GigabitEthernet0/0/1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip ad 192.168.1.254 24

R2
<Huawei>sy
[Huawei]sy R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip ad 10.1.12.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip ad 100.1.1.2 24

R3
<Huawei>sy
[Huawei]sy R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip ad 100.1.1.3 24

路由配置
[R1]ip route-static 0.0.0.0 0 10.1.12.2
[R2]ip route-static 0.0.0.0 0 10.1.12.1

  
 
  • 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

NAT配置步骤

在这里插入图片描述

1.配置静态NAT

①在接口下配置

[R2]int g0/0/1	
[R2-GigabitEthernet0/0/1]nat static global 100.1.1.10 inside 192.168.1.1

  
 
  • 1
  • 2

②在全局下配置

[R2]nat static global 100.1.1.20 inside 192.168.1.2 
[R2-GigabitEthernet0/0/1]nat static enable 

  
 
  • 1
  • 2

PC2访问外网

PC>ping 100.1.1.3

Ping 100.1.1.3: 32 data bytes, Press Ctrl_C to break
From 100.1.1.3: bytes=32 seq=1 ttl=253 time=31 ms
From 100.1.1.3: bytes=32 seq=2 ttl=253 time=32 ms
From 100.1.1.3: bytes=32 seq=3 ttl=253 time=46 ms
From 100.1.1.3: bytes=32 seq=4 ttl=253 time=47 ms
From 100.1.1.3: bytes=32 seq=5 ttl=253 time=63 ms

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

2.配置动态NAT

[R2]nat address-group 1 100.1.1.10 100.1.1.20
[R2]acl 2000
[R2-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]nat outbound 2000 address-group 1 no-pat

  
 
  • 1
  • 2
  • 3
  • 4
  • 5

查看NAT的类型

[R2]dis nat  outbound address-group 1
 NAT Outbound Information:
 --------------------------------------------------------------------------
 Interface                     Acl     Address-group/IP/Interface      Type
 --------------------------------------------------------------------------
 GigabitEthernet0/0/1         2000                              1    no-pat
 --------------------------------------------------------------------------
  Total : 1


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

3.配置NAPT

R2

[R2]nat address-group 1 100.1.1.10 100.1.1.20
[R2]acl 2000
[R2-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]nat outbound 2000 address-group 1

  
 
  • 1
  • 2
  • 3
  • 4
  • 5

查看NAT的类型

[R2]dis nat ou ad 1
 NAT Outbound Information:
 --------------------------------------------------------------------------
 Interface                     Acl     Address-group/IP/Interface      Type
 --------------------------------------------------------------------------
 GigabitEthernet0/0/1         2000                              1       pat
 --------------------------------------------------------------------------
  Total : 1

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

4.配置easy-ip

[R2]acl 2000
[R2-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]nat outbound 2000

  
 
  • 1
  • 2
  • 3
  • 4

查看NAT的类型

[R2]dis nat outbound acl 2000
 NAT Outbound Information:
 --------------------------------------------------------------------------
 Interface                     Acl     Address-group/IP/Interface      Type
 --------------------------------------------------------------------------
 GigabitEthernet0/0/1         2000                      100.1.1.2    easyip  
 --------------------------------------------------------------------------
  Total : 1

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

5.配置nat服务器实现外网能访问内网的服务器

[R2-GigabitEthernet0/0/1]nat server global 100.1.1.30 inside 192.168.1.2

  
 
  • 1

看完华为的NAT技术配置,你是不是也想思科、华三的NAT配置呢?
其实原理都一样,知识配置命令略有差别。

在这里插入图片描述

CISCO nat技术配置

1.实验图谱

在这里插入图片描述

2.实验需求

server 通过静态转换到 10.1.1.3。

PC1 通过拿地址池 IP 地址动态转换。

PC2 通过 PAT 做端口复用转化到 S1/1 接口 IP 地址上

3.实验解法

  • ISP基本配置

    Router>enable
    Router#conf t
    Router(config)#hostname isp
    isp(config)#int e0/0
    isp(config-if)#ip add 10.1.1.2 255.255.255.0
    isp(config-if)#no sh
    isp(config-if)#exit
    isp(config)#
    isp(config)#int lo 0 
    isp(config-if)#ip add 202.100.1.1 255.255.255.0
    isp(config-if)#no sh
    isp(config-if)#exit
    isp(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.1
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • gateway基本配置

    Router>enable
    Router#conf t
    Router(config)#hostname gateway
    gateway(config)#int e0/1
    gateway(config-if)#ip add 10.1.1.1 255.255.255.0
    gateway(config-if)#no sh
    gateway(config-if)#int e0/
    gateway(config-if)#int e0/0
    gateway(config-if)#ip add 192.168.1.1 255.255.255.0
    gateway(config-if)#no sh
    gateway(config-if)#exit
    gateway(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
  • l2_sw基本配置

    Switch>en
    Switch#conf t
    Switch(config)#no ip routing            #这里使用的是路由器镜像,所以模拟时,关闭了路由功能
    Switch(config)#hostname l2_sw
    l2_sw(config)#
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
  • Server配置

    Router>enable
    Router#conf t
    Router(config)#hostname Server
    Server(config)#no ip routing       #关闭路由功能
    Server(config)#int e0/0
    Server(config-if)#ip add 192.168.1.2 255.255.255.0
    Server(config-if)#no sh
    Server(config-if)#exit
    Server(config)#ip default-gateway 192.168.1.1    #配置网网关
    Server(config)#
    注释:PC1、PC2和server 配置类似,这里省略
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
  • NAT配置步骤
    在这里插入图片描述

    必须先定义  inside 和  outside,要满足正常  NAT 转换,必须满足三个条件:
    1.从inside接口进。2.从outside接口出。3.符合感兴趣流量
    
        
       
    • 1
    • 2

  • 静态NAT配置

  • 1.定义inside,outside接口

    gateway(config)#int e0/0
    gateway(config-if)#ip nat inside    #定义入接口
    gateway(config-if)#int e0/1
    gateway(config-if)#ip nat outside  #定义出接口
    gateway(config-if)#exit
    gateway(config)#
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 2.匹配流量

    gateway(config)#ip nat inside source static 192.168.1.2 10.1.1.3
    
        
       
    • 1
  • 测试:

    Server>ping 202.100.1.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 202.100.1.1, timeout is 2 seconds:
    .!!!!
    Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/2 ms
    Server>
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

  • 动态NAT配置

  • 1.定义感兴趣流量

    gateway(config)#access-list 101 per ip host 192.168.1.3 any 
    
        
       
    • 1
  • 2.定义地址池

    gateway(config)#ip nat pool dtpool 100.1.1.1 100.1.1.10 netmask 255.255.255.0
    
        
       
    • 1
  • 3.符合 ACL101 的流量从地址池 dt pool 拿一个公网 IP 地址出

    gateway(config)#ip nat inside source list 101 pool dtpool 
    
        
       
    • 1

  • PAT多对一转换

  • 1.定义匹配感兴趣流

    gateway(config)#access-list 102 permit ip host 192.168.1.4 any
    
        
       
    • 1
  • 2.配置转发

    gateway(config)#ip nat inside source list 102 interface e0/1                 
    gateway(config)#
    
        
       
    • 1
    • 2

H3C nat技术配置

1.实验图谱
在这里插入图片描述

2.实验需求

  1. 私网 A 通过 NAPT 使 Vlan10 和 Vlan20 都能够使用 R1 的公网地址访问互联网
  2. 私网 B 通过在 R3 上配置 EASY IP 访问互联网
  3. 私网 A 配置 NAT SERVER 把 FTPA 的 FTP 服务发布到公网,使 PCB 可以访问

注明:基础配置,参考图做配置

3.实验解法

  • 需求解析1
    在这里插入图片描述

     分析:根据需求得知,ACL 需要配置允许 192.168.1.0/24 和 192.168.2.0/24 网段;私网 A 只有 1 个公网地址可用,意味着创建的 NAT 地址池起始和结束地址就都是 100.1.1.1
    
        
       
    • 1
  • 1.在R1上创建基本ACL,抓取网段

    [R1]acl basic 2000
    [R1-acl-ipv4-basic-2000]rule permit source 192.168.1.0 0.0.0.255
    [R1-acl-ipv4-basic-2000]rule permit source 192.168.2.0 0.0.0.255
    
        
       
    • 1
    • 2
    • 3
  • 2.创建NAT地址池

    [R1]nat address-group 1
    [R1-address-group-1]address 100.1.1.1 100.1.1.1
    
        
       
    • 1
    • 2
  • 3.接口配置NAPT

    [R1]interface g0/1
    [R1-GigabitEthernet0/1]nat outbound 2000 address-group 1 
    
        
       
    • 1
    • 2
  • 4.测试访问互联网

    <PCA>ping 100.2.2.3
    Ping 100.2.2.3 (192.168.2.10): 56 data bytes, press CTRL_C to break
    56 bytes from 100.2.2.3: icmp_seq=0 ttl=254 time=22.000 ms
    56 bytes from 100.2.2.3: icmp_seq=1 ttl=254 time=51.000 ms
    56 bytes from 100.2.2.3: icmp_seq=2 ttl=254 time=21.000 ms
    56 bytes from 100.2.2.3: icmp_seq=3 ttl=254 time=43.000 ms
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

  • 需求解析2

    分析:根据需求得知,ACL 需要配置允许 192.168.1.0/24 网段;使用 EASY IP,就无需配置 NAT 地址池,直接在公网接口上配置即可,EASY IP 会自动识别公网接口的 IP 地址
    
        
       
    • 1
  • 1.R3上创建基本ACL

    [R3]acl basic 2000
    [R3-acl-ipv4-basic-2000]rule permit source 192.168.1.0 0.0.0.255
    
        
       
    • 1
    • 2
  • 2.接口配置EASY IP

    [R3]interface g0/0
    [R3-GigabitEthernet0/1]nat outbound 2000
    
        
       
    • 1
    • 2
  • 3.测试

    <PCB>ping 100.1.1.1
    Ping 100.1.1.1 (192.168.1.10): 56 data bytes, press CTRL_C to break
    56 bytes from 100.1.1.1: icmp_seq=0 ttl=254 time=32.000 ms
    56 bytes from 100.1.1.1: icmp_seq=1 ttl=254 time=29.000 ms
    56 bytes from 100.1.1.1: icmp_seq=2 ttl=254 time=41.000 ms
    56 bytes from 100.1.1.1: icmp_seq=3 ttl=254 time=33.000 ms
    56 bytes from 100.1.1.1: icmp_seq=4 ttl=254 time=34.000 ms
    
        
       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

  • 需求解析3

  • 1.在R1上配置NAT Server

    [R1-GigabitEthernet0/1]nat server protocol tcp global current-interface 20 21 inside 192.168.1.10 20 21
    
        
       
    • 1

在这里插入图片描述

哈哈。感谢您的关注,点赞。您的支持是我的分享动力!

文章来源: rivers.blog.csdn.net,作者:宝山的博客,版权归原作者所有,如需转载,请联系作者。

原文链接:rivers.blog.csdn.net/article/details/117293533

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200