NAT地址转换实验

NAT地址转换

由于IP地址有限,又分为私网和公网地址,为了节省IP地址,私网地址可与公网地址重复,但不能出现在公网当中,当需要与公网数据通信时,则出现了一种地址转换技术,即NAT地址转换,通过在路由器上的配置实现。数据出路由器转换的是源IP地址,数据进路由器转换的是目标IP地址。NAT地址转换实验_第1张图片

NAT类型

  • 静态NAT:一个私网IP地址对应一个公网IP地址,并未节省IP地址
  • 动态NAT:多个私网IP地址对应多个公网IP地址,并不节省IP地址
  • EasyIP:多个私网IP地址对应外网口公网IP地址,最节省IP地址
  • NAT Server(映射)如下图:
    NAT地址转换实验_第2张图片

实验拓扑NAT地址转换实验_第3张图片

PC1采用静态NAT地址转换,在R1上配置,进入外网端口,配置如下:

[R1-GigabitEthernet0/0/0]nat static global 8.8.8.8 inside 192.168.10.10

PC2和PC4采用动态NAT地址转换,建立地址池1,在池中获取公网IP,配置如下:

[R1]nat address-group 1 212.0.0.100 212.0.0.200
[R1]acl 2000
[R1-acl-basic-2000]rule permit source 192.168.20.0 0.0.0.255
[R1-acl-basic-2000]rule permit source 11.0.0.0 0.0.0.255
[R1-acl-basic-2000]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 2000 address-group 1 no-pat

PC3采用EasyIP,配置如下:

[R1]acl 3000
[R1-acl-adv-3000]rule permit ip source 192.168.30.0 0.0.0.255
[R1-acl-adv-3000]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 3000

服务器上用NAT sever

[R1-GigabitEthernet0/0/0]nat server protocol tcp global 9.9.9.9 www inside 192.168.10.100 www

所有配置如下图所示:

R1
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 11.0.0.1 24
[R1-GigabitEthernet0/0/1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/0]q
[R1]ip route-static 192.168.10.0 24 11.0.0.2
[R1]ip route-static 192.168.20.0 24 11.0.0.2
[R1]ip route-static 192.168.30.0 24 11.0.0.2
[R1]ip route-static 0.0.0.0 0.0.0.0 12.0.0.2
[R1]int g0/0/0 
[R1-GigabitEthernet0/0/0]nat st [R1-GigabitEthernet0/0/0]nat static global 8.8.8.8 inside 192.168.10.10
[R1-GigabitEthernet0/0/0]q
[R1]nat address-group 1 212.0.0.100 212.0.0.200
[R1]acl 2000
[R1-acl-basic-2000]rule p 
[R1-acl-basic-2000]rule permit s 
[R1-acl-basic-2000]rule permit source 192.168.20.0 0.0.0.255
[R1-acl-basic-2000]rule permit source 11.0.0.0 0.0.0.255
[R1-acl-basic-2000]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 2000 address-group 1 no-pat
[R1-GigabitEthernet0/0/0]q
[R1]acl 3000
[R1-acl-adv-3000]rule permit ip source 192.168.30.0 0.0.0.255
[R1-acl-adv-3000]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 3000
[R1-GigabitEthernet0/0/0]nat server protocol tcp global 9.9.9.9 www inside 192.168.10.100 www
R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[R2-GigabitEthernet0/0/1]q
[R2]int loop 0
[R2-LoopBack0]ip add 114.114.114.114 32
[R2]ip route-static 11.0.0.0 24 12.0.0.1
[R2]ip route-static 192.168.10.0 24 12.0.0.1
[R2]ip route-static 192.168.20.0 24 12.0.0.1
[R2]ip route-static 192.168.30.0 24 12.0.0.1
[R2]ip route-static 8.8.8.8 32 12.0.0.1
[R2]ip route-static 9.9.9.9 32 12.0.0.1
[R2]ip route-static 212.0.0.0 24 12.0.0.1
SW1
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]p l a
[SW1-GigabitEthernet0/0/1]p d v 40
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]p l a
[SW1-GigabitEthernet0/0/2]p d v 10
[SW1-GigabitEthernet0/0/2]int g0/0/3
[SW1-GigabitEthernet0/0/3]p l a
[SW1-GigabitEthernet0/0/3]p d v 20
[SW1-GigabitEthernet0/0/3]int g0/0/4
[SW1-GigabitEthernet0/0/4]p l a
[SW1-GigabitEthernet0/0/4]p d v 30
[SW1-GigabitEthernet0/0/4]int g0/0/5
[SW1-GigabitEthernet0/0/5]p l a
[SW1-GigabitEthernet0/0/5]p d v 20
[SW1-GigabitEthernet0/0/5]int g0/0/6
[SW1-GigabitEthernet0/0/6]p l a 
[SW1-GigabitEthernet0/0/6]p de v 10
[SW1-GigabitEthernet0/0/6]q
[SW1]int vlanif 10
[SW1-Vlanif10]ip add 192.168.10.1 24
[SW1-Vlanif10]int vlanif 20
[SW1-Vlanif20]ip add 192.168.20.1 24
[SW1-Vlanif20]int vlanif 30
[SW1-Vlanif30]ip add 192.168.30.1 24
[SW1]ip route-static 0.0.0.0 0.0.0.0 11.0.0.1
[SW1]int vlanif 40
[SW1-Vlanif40]ip add 11.0.0.2 24

你可能感兴趣的:(NAT地址转换实验)