NAT:网络地址转换技术
解决IPV4公网地址短缺问题,公网IP个数2的32次方个地址,目前IPV4地址已经分配完,需要访问互联网资源的话需要公网的IP,那么就产生了NAT技术,来解决内网环境下大量私网IP可以使用同一个公网IP进行转发。
NAT技术分类
静态NAT:一个私网IP对应一个公网IP
system-view
interface GigabitEthernet0/0/1
ip address 192.168.0.1 255.255.255.0
nat outbound
quit
interface GigabitEthernet0/0/0
ip address 203.0.113.1 255.255.255.0
nat indound
quit
nat static global 203.0.113.2 inside 192.168.0.10
动态NAT:多个私网IP可以对应一个公网地址池,第一步是配置公网地址池,第二步是配置ACL匹配私网网段,第三步绑定私网网段和公网地址池的对应关系
system-view
acl number 3000
rule permit source 192.168.0.0 0.0.0.255
quit
ip pool natpool 1 203.0.113.2 203.0.113.10
nat address-group 1 203.0.113.2 203.0.113.10
interface GigabitEthernet0/0/1
ip address 192.168.0.1 255.255.255.0
nat outbound
quit
nat outbound acl 3000 address-group 1 no-pat
NAPT:多个私网IP对应同一个公网IP ,每台设备数据转发时路由器会生成一个虚拟的端口号,转发到互联网,互联网回复数据的时候根据虚拟的端口号来确定内网的设备并转发到该设备。
system-view
interface GigabitEthernet0/0/1
ip address 192.168.0.1 255.255.255.0
nat outbound
quit
interface GigabitEthernet0/0/0
ip address 203.0.113.1 255.255.255.0
nat inbound
quit
acl number 3000
rule permit source 192.168.0.0 0.0.0.255
quit
ip pool natpool 1 203.0.113.2
nat address-group 1 203.0.113.2
nat outbound acl 3000 address-group 1
Easy IP: 直接将路由器的出接口公网IP作为NAT地址
system-view
acl number 2000
rule 10 permit source 192.168.0.0 0.0.0.255
interface GigabitEthernet0/0/1
ip address 192.168.0.1 255.255.255.0
nat outbound
interface GigabitEthernet0/0/0
ip address 203.0.113.1 255.255.255.0
nat outbound acl 2000
NAT Server:互联网访问内网服务器,将端口映射到公网IP上
system-view
interface GigabitEthernet0/0/0
ip address 203.0.113.1 255.255.255.0
quit
nat server protocol tcp global 203.0.113.1 80 inside 192.168.0.100 80