0
点赞
收藏
分享

微信扫一扫

动态NAT(NAPT)

源nat:

私网到公网的转换(私网访问公网,目的ip没变,只转换了源ip)。

实验要求:

  1. 假设一个企业从运营商那获得一段公网地址(21.16.1.248/29);
  2. 要求内网电脑可以正常上外放,并能访问外网服务器;
  3. 在ISP路由器配置环回接口,模拟外网地址;
  4. 企业内网服务器的http业务需要映射到外网,供外网用户访问,外网用户只能访问页面,不能ping通服务器。
  5. ISP为运营商设备,模拟外网环境。

网络拓扑

image-20221208212001-1hfp66n.png

配置思路:

NAPT、PAT、NAT SERVER-20221210195531-ygexnnb.png

ISP运营商配置

  1. 修改设备名称(省略);
  2. 接口配置(省略)

R1路由器配置(出口设备)

  1. 修改设备名称(省略);

  2. 接口配置;

    1. 外网出口;

      #
      interface GigabitEthernet0/0/0
       description ISP
       ip address 21.16.1.254 255.255.255.248 
      #
      
    2. 内网接口;

      #
      interface GigabitEthernet0/0/2
       description office
       ip address 192.168.31.254 255.255.255.0 
      #
      
  3. 缺省路由配置;

    #
    ip route-static 0.0.0.0 0.0.0.0 21.16.1.249
    #
    
  4. 创建规则;允许指定地址做地址转换

    #
    acl number 2000  
     step 10
     rule 10 permit source 192.168.31.0 0.0.0.255 
    #
    
  5. 创建地址组;NAT地址池

    #
     nat address-group 0 21.16.1.250 21.16.1.253
    #
    
  6. 动态地址转换(源NAT);

    1. no-pat;

      #
      interface GigabitEthernet0/0/0
       description ISP
       nat outbound 2000 address-group 0 no-pat
      #
      

      image-20221208213424-05orkxx.png

    2. NAPT;

      #
      interface GigabitEthernet0/0/0
       description ISP
       ip address 21.16.1.254 255.255.255.248 
       nat outbound 2000 address-group 0 
      #
      

      image-20221208213508-8ex39hg.png

      注意:PAT与NO-PAT的区别是NAPT转换源端口,NO-PAT不转换源端口。

    3. easy ip;

      #
      interface GigabitEthernet0/0/0
       description ISP
       ip address 21.16.1.254 255.255.255.248 
       nat outbound 2000
      #
      

image-20221208213632-e1ejopl.png

注意:Easy-ip是NAPT的一种特例是单向转换的,配置时候不需要创建公网地址池。

  1. NAT SERVER ,服务器映射(目的NAT);

目的nat:公网到私网的转换(公网访问私网,源地址没变,只转换了目的ip),也叫端口映射。

1. 命令格式:

    ```powershell
    nat server + global / protocol + prot number / icmp / tcp / udp + global  ip / current-interface / interface +port number / server + inside + ip + port number / server 
    ```

    ```powershell
    #
    interface GigabitEthernet0/0/0
     description ISP
     nat server protocol tcp global current-interface www inside 192.168.31.3 www
    #
    ```

image-20221208214438-zu1sy0w.png

常用调试命令:

# 查看 nat server 服务相关信息
display nat server

image-20221210200930-tawwwlq.png

# 查看 nat地址池相关信息
display nat address-group

image-20221210201052-w8sezyq.png

# 查看所有的 nat 会话信息 
display nat session all

image-20221210201316-l8mdho5.png

# 查看所有 nat 的类型
display nat outbound

image-20221210201458-ppk9lm2.png

举报

相关推荐

0 条评论