做个小实验供自己理解一下Easy-IP
Easy IP是一种利用出接口的公网IP地址作为NAT转换后的地址,同时转换地址和端口的地址转换方式。
对于接口是动态获取的场景,Easy IP也一样支持
通过防火墙实现nat装换
拓扑图
1、在这个拓扑图中我把192.168.1.0/24比作内网,172.16.1.0/24比作外网,使用防火墙将内网地址转换成外网地址,然后去访问PC2
防火墙必须将接口分配到安全区域内,并且配置数据包过滤才可让数据包通过,所以要先配置安全策略和网关地址
防火墙配置如下
<SRG>system-view
20:19:06 2021/09/25
Enter system view, return user view with Ctrl+Z.
[SRG]interface GigabitEthernet 0/0/1
20:19:15 2021/09/25
[SRG-GigabitEthernet0/0/1]ip address 192.168.1.254 24
[SRG-GigabitEthernet0/0/1]qu
[SRG]interface GigabitEthernet 0/0/2
20:19:34 2021/09/25
[SRG-GigabitEthernet0/0/2]ip address 172.16.1.254 24
[SRG-GigabitEthernet0/0/2]qu
[SRG]firewall zone trust
[SRG-zone-trust]add interface GigabitEthernet 0/0/1
[SRG-zone-trust]qu
[SRG]firewall zone untrust
20:20:55 2021/09/25
[SRG-zone-untrust]add interface GigabitEthernet 0/0/2
[SRG-zone-untrust]qu
[SRG]firewall packet-filter default permit interzone trust untrust direction out
bound
20:22:01 2021/09/25
Warning:Setting the default packet filtering to permit poses security risks. You
are advised to configure the security policy based on the actual data flows. Ar
e you sure you want to continue?[Y/N]y
这样使用PC1pingPC2就可以通,但是可以通过抓包观察到,地址没有转换
2、配置接口g0/0/2 将内网地址192.168.1.0/24使用Easy IP 方式转换成外网地址172.16.1.0/24
[SRG]nat-policy interzone trust untrust outbound
20:23:03 2021/09/25
[SRG-nat-policy-interzone-trust-untrust-outbound]policy 1
[SRG-nat-policy-interzone-trust-untrust-outbound-1]policy source 192.168.1.0 0.0.0.255
[SRG-nat-policy-interzone-trust-untrust-outbound-1]action source-nat
[SRG-nat-policy-interzone-trust-untrust-outbound-1]easy-ip GigabitEthernet 0/0/2
这样在看抓包记录,可以观察到地址发生了转换,而且就是接口g0/0/2的地址
通过路由器实现nat装换
拓扑图
1、路由器配上网关就可以是两个PC之间通信
路由器配置如下
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.1.254 24
[Huawei-GigabitEthernet0/0/1]q
[Huawei]interface GigabitEthernet 0/0/2
[Huawei-GigabitEthernet0/0/2]ip address 172.16.1.254 24
[Huawei-GigabitEthernet0/0/2]qu
[Huawei]
使用PC1pingPC2,抓包,
2、配置接口g0/0/2 将内网地址192.168.1.0/24使用Easy IP 方式转换成外网地址172.16.1.0/24
[Huawei]acl number 2000
[Huawei-acl-basic-2000]rule 5 permit source 192.168.1.0 0.0.0.255
[Huawei-acl-basic-2000]quit
[Huawei]int
[Huawei]interface g
[Huawei]interface GigabitEthernet 0/0/2
[Huawei-GigabitEthernet0/0/2]d th
[V200R003C00]
#
interface GigabitEthernet0/0/2
ip address 172.16.1.254 255.255.255.0
#
return
[Huawei-GigabitEthernet0/0/2]nat outbound 2000
[Huawei-GigabitEthernet0/0/2]qu
结果