display nat session all
sys
[Huawei]sysn SW1
[SW1]
[SW1]v b 10 20 30 40 50
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]p l a
[SW1-GigabitEthernet0/0/1]p d v 10
[SW1-GigabitEthernet0/0/1]un sh
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]p l a
[SW1-GigabitEthernet0/0/2]p d v 20
[SW1-GigabitEthernet0/0/2]un sh
[SW1-GigabitEthernet0/0/2]int g0/0/3
[SW1-GigabitEthernet0/0/3]p l a
[SW1-GigabitEthernet0/0/3]p d v 30
[SW1-GigabitEthernet0/0/3]un sh
Info: Interface GigabitEthernet0/0/3 is not shutdown.
[SW1-GigabitEthernet0/0/3]int g0/0/4
[SW1-GigabitEthernet0/0/4]p l a
[SW1-GigabitEthernet0/0/4]p d v 20
[SW1-GigabitEthernet0/0/4]un sh
[SW1-GigabitEthernet0/0/4]int g0/0/5
[SW1-GigabitEthernet0/0/5]p l a
[SW1-GigabitEthernet0/0/5]p d v 50
[SW1-GigabitEthernet0/0/5]un sh
[SW1-GigabitEthernet0/0/5]int g0/0/6
[SW1-GigabitEthernet0/0/6]p l a
[SW1-GigabitEthernet0/0/6]p d v 40
[SW1-GigabitEthernet0/0/6]un sh
[SW1]int vl 10
[SW1-Vlanif10]ip add 192.168.10.1 24
[SW1-Vlanif10]q
[SW1]int v 20
[SW1-Vlanif20]ip add 192.168.20.1 24
[SW1-Vlanif20]q
[SW1]int v30
[SW1-Vlanif30]ip address 192.168.30.1 24
[SW1-Vlanif30]q
[SW1]int v 40
[SW1-Vlanif40]
[SW1-Vlanif40]ip add 11.0.0.1 24
[SW1-Vlanif40]q
[SW1]int v 50
[SW1-Vlanif50]
[SW1-Vlanif50]ip add 192.168.50.1 24
[SW1-Vlanif50]q
[SW1]ip route-static 0.0.0.0 0.0.0.0 11.0.0.2
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 11.0.0.2 24
[R1-GigabitEthernet0/0/2]un sh
[R1-GigabitEthernet0/0/2]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/0]un sh
[R1-GigabitEthernet0/0/0]q
[R1]ip route-static 192.168.10.0 24 11.0.0.1
[R1]ip route-static 192.168.20.0 24 11.0.0.1
[R1]ip route-static 192.168.30.0 24 11.0.0.1
[R1]ip route-static 192.168.50.0 24 11.0.0.1
[R1]ip route-static 0.0.0.0 0.0.0.0 12.0.0.2
sys
[Huawei]sysn R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]un sh
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[R2-GigabitEthernet0/0/1]un sh
[R2-GigabitEthernet0/0/1]int loo 0
[R2-LoopBack0]ip add 111.111.111.111 32
[R2-LoopBack0]q
配置R1
[R1]nat static global 2.2.2.2 inside 192.168.10.10
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat static enable
配置R2
[R2]ip route-static 2.2.2.2 32 12.0.0.1
结果:成功转化地址,并通信
配置R1
[R1]nat address-group 1 100.0.0.100 100.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]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 2000 address-group 1 no-pat
配置R2
[R2]ip route-static 100.0.0.0 24 12.0.0.1
结果验证:20段的数据成功通过NAT转化与公网通信
R1配置
[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]q
实验验证:成功转化成12.0.0.1与公网通信
R1设置
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]nat server protocol tcp global current-interface www inside 192.168.50.10 www
Server1设置:新建一个html文件,随便输入内容,启动服务
结果验证
一个私网地址对应一个公网地址
第一种方式
全局模式下,输入
nat static global 2.2.2.2 inside 192.168.10.10
在接口上启动nat static enable 功能
int g0/0/0
nat static enable
第二种方法:直接在端口上声明nat static
int g0/0/0
nat static global 2.2.2.2 inside 192.168.10.10
多个私网地址对应多个公网地址
nat address-group 1 100.0.0.100 100.0.0.200 '//新建编号为1的地址池'
acl 2000 '//acl编号'
rule permit source 192.168.20.0 0.0.0.255 '//设置规则'
int g0/0/0
nat outbound 2000 address-group 1 no-pat
多个私网地址对应一个公网地址
acl 3000 '//acl编号'
rule permit ip source 192.168.30.0 0.0.0.255 '//设置规则'
int g0/0/0
nat outbound 3000
将公网地址端口映射到私网地址,实现访问
[R1]int g0/0/0
nat server protocol tcp global current-interface www inside 192.168.50.10 www '//使用物理地址映射192.168.50.10'