前言:NAT技术是用来解决当今IP地址资源枯竭的一种技术,同时也是IPv4到IPv6的过渡技术,绝大多数网络环境中在使用NAT技术
NAT Server(粗泛)
NAT Server(精细)
[USG6000V1]display firewall server-map
Current Total Server-map : 2
正向 Type: Nat Server, ANY -> 202.96.1.10:445[192.168.1.4:445], Zone:---, protocol:tcp
Vpn: public -> public
反向 Type: Nat Server Reverse, 192.168.1.4[202.96.1.10] -> ANY, Zone:---, protocol:tcp
Vpn: public -> public, counter: 1
防火墙接口从收到一个报文到最终发送出去需要经历一系列处理流程,而NAT只是其中的一项任务。NAT的配置受到路由及安全策略的影响,所以了解NAT对报文的处理流程对配置AT有非常大的帮助。NAT对报文的处理流程如下图所示
从上图中可以看出来,因为防火墙处理报文的顺序是目标地址转换→安全策略→源地址转换,所以在NAT环境中,安全策略的源地址应该是源地址转换之前的地址,目标地址应该是目标地址转换之后的地址
一个报文,一般在同一个网络设备上,只会存在一种转换条目,即要么转换源地址(除NAT-Server类型的NAT转换之外),要么转换目的地址(NAT-Server类型的NAT转换)。源地址和目的地址的转换不会同时存在同一个网络设备上
NAT处理报文的流程如下
因为防火墙处理报文的顺序是目标地址转换→安全策略→源地址转换,所以在NAT环境中,安全策略的源地址应该是源地址转换之前的地址,目标地址应该是目标地址转换后的地址
[USG6000V1]dis cu
2020-02-13 05:17:57.580
!Software Version V500R005C10SPC300
#
sysname USG6000V1
#
。。。。省略部分内容
interface GigabitEthernet1/0/0
undo shutdown
ip address 100.1.1.2 255.255.255.252
#
interface GigabitEthernet1/0/1
undo shutdown
ip address 192.168.0.1 255.255.255.0
#
interface GigabitEthernet1/0/2
undo shutdown
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet1/0/3
undo shutdown
ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet1/0/4
undo shutdown
ip address 192.168.3.1 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 100.1.1.1
#
return
[R1]dis cu
#
sysname R1
#
interface GigabitEthernet0/0/0
ip address 100.1.1.1 255.255.255.252
#
interface GigabitEthernet0/0/1
ip address 200.1.1.1 255.255.255.0
#
ip route-static 100.2.2.8 255.255.255.248 100.1.1.2
//该地址为汇总后的地址
#
return
[USG6000V1]firewall zone trust //trust区域
[USG6000V1-zone-trust]add in g1/0/4
[USG6000V1-zone-trust]add in g1/0/3
[USG6000V1-zone-trust]add in g1/0/2
[USG6000V1-zone-trust]quit
[USG6000V1]firewall zone dmz //dmz区域
[USG6000V1-zone-dmz]add in g1/0/1
[USG6000V1-zone-dmz]quit
[USG6000V1]firewall zone untrust //untrust区域
[USG6000V1-zone-untrust]add in g1/0/0
[USG6000V1]security-policy
[USG6000V1-policy-security]rule name aqcl //定义安全策略名字
[USG6000V1-policy-security-rule-aqcl]source-zone trust //源区域为trust
[USG6000V1-policy-security-rule-aqcl]destination-zone untrust //目标区域为untrust
[USG6000V1-policy-security-rule-aqcl]action permit //动作为允许
[USG6000V1]nat-policy
[USG6000V1-policy-nat]rule name natcl 定义NAT策略名字
[USG6000V1-policy-nat-rule-natcl]source-address 192.168.3.0 24 //定义源地址
[USG6000V1-policy-nat-rule-natcl]source-zone trust //定义源区域
[USG6000V1-policy-nat-rule-natcl]destination-zone untrust //定义目标区域
[USG6000V1-policy-nat-rule-natcl]action nat easy-ip //配置出接口方式
[USG6000V1]dis firewall session table //使用dis firewall session table命令查看
2020-02-13 05:48:14.820
Current Total Sessions : 4
icmp VPN: public --> public 192.168.3.2:62177[100.1.1.2:2051] --> 200.1.1.2:2
048
icmp VPN: public --> public 192.168.3.2:61921[100.1.1.2:2050] --> 200.1.1.2:2
048
icmp VPN: public --> public 192.168.3.2:62689[100.1.1.2:2053] --> 200.1.1.2:2
048
icmp VPN: public --> public 192.168.3.2:62433[100.1.1.2:2052] --> 200.1.1.2:2
048
[USG6000V1]
配置行政部属于trust区域,通过NAPT访问internet(使用100.2.2.12/29)
由于在上面配置Easy-ip的NAT类型时,配置了安全策略,
所以接下来trust区域访问untrust区域的流量就不用配置安全策略了
配置NAT地址组,地址组中的地址对应的是公网地址100.2.2.12/29
[USG6000V1]nat address-group napt //定义nat地址组名
[USG6000V1-address-group-napt]section 0 100.2.2.12 //定义组中的地址
[USG6000V1-address-group-napt]mode pat //配置为NAPT方式
[USG6000V1-address-group-napt]quit
[USG6000V1]nat-policy
[USG6000V1-policy-nat]rule name napt //自定义nat策略的组名
[USG6000V1-policy-nat-rule-napt]source-address 192.168.2.0 24 ####定义需要转换的源地址
[USG6000V1-policy-nat-rule-napt]source-zone trust //定义源区域
[USG6000V1-policy-nat-rule-napt]destination-zone untrust //定义目标区域
[USG6000V1-policy-nat-rule-napt]action source-nat address-group napt //关联地址组
[USG6000V1] ip route-static 100.2.2.12 32 NULL 0
[USG6000V1]dis firewall session table
2020-02-13 07:58:11.940
Current Total Sessions : 5
icmp VPN: public --> public 192.168.2.2:26877[100.2.2.12:2067] --> 200.1.1.2:
2048
icmp VPN: public --> public 192.168.2.2:28413[100.2.2.12:2072] --> 200.1.1.2:
2048
icmp VPN: public --> public 192.168.2.2:27133[100.2.2.12:2068] --> 200.1.1.2:
2048
icmp VPN: public --> public 192.168.2.2:28669[100.2.2.12:2073] --> 200.1.1.2:
2048
icmp VPN: public --> public 192.168.2.2:30973[100.2.2.12:2079] --> 200.1.1.2:
2048
配置财务部属于trust区域,通过no-pat访问internet(使用100.2.2.10/29-100.2.2.11/29)
配置NAT地址组,地址组中的地址对应的是公网地址100.2.2.10–100.2.2.11
[USG6000V1]nat address-group natnopat //定义nat地址组名
[USG6000V1-address-group-natnopat]section 0 100.2.2.10 100.2.2.11 //定义组中的地址
[USG6000V1-address-group-natnopat]mode no-pat local //配置为NAT No-PAT方式
[USG6000V1-address-group-natnopat]quit
[USG6000V1]nat-policy
[USG6000V1-policy-nat]rule name nopat //自定义nat策略的组名
[USG6000V1-policy-nat-rule-nopat]source-address 192.168.1.0 24 //定义需要转换的源地址
[USG6000V1-policy-nat-rule-nopat]source-zone trust //定义源区域
[USG6000V1-policy-nat-rule-nopat]destination-zone untrust //定义目标区域
[USG6000V1-policy-nat-rule-nopat]action source-nat address-group natnopat //关联地址组
[USG6000V1-policy-nat-rule-nopat]quit
[USG6000V1]ip route-static 100.2.2.10 32 NULL 0
[USG6000V1]ip route-static 100.2.2.11 32 NULL 0
[USG6000V1]dis firewall session table //查看会话表
2020-02-13 08:16:46.280
Current Total Sessions : 5
icmp VPN: public --> public 192.168.1.2:22017[100.2.2.10:22017] --> 200.1.1.2
:2048
icmp VPN: public --> public 192.168.1.2:22785[100.2.2.10:22785] --> 200.1.1.2
:2048
icmp VPN: public --> public 192.168.1.2:22529[100.2.2.10:22529] --> 200.1.1.2
:2048
icmp VPN: public --> public 192.168.1.2:23041[100.2.2.10:23041] --> 200.1.1.2
:2048
icmp VPN: public --> public 192.168.1.2:22273[100.2.2.10:22273] --> 200.1.1.2
:2048
[USG6000V1]dis firewall server-map //查看server-map表
2020-02-13 08:17:47.660
Current Total Server-map : 2
Type: No-Pat Reverse, ANY -> 100.2.2.10[192.168.1.2], Zone: untrust
Protocol: ANY, TTL:---, Left-Time:---, Pool: 1, Section: 0
Vpn: public
Type: No-Pat, 192.168.1.2[100.2.2.10] -> ANY, Zone: untrust
Protocol: ANY, TTL:360, Left-Time:311, Pool: 1, Section: 0
Vpn: public
[USG6000V1]security-policy
[USG6000V1-policy-security]rule name todmz
[USG6000V1-policy-security-rule-todmz]source-zone untrust
[USG6000V1-policy-security-rule-todmz]destination-zone dmz
[USG6000V1-policy-security-rule-todmz]destination-address 192.168.0.0 24
[USG6000V1-policy-security-rule-todmz]service ftp
[USG6000V1-policy-security-rule-todmz]service http
[USG6000V1-policy-security-rule-todmz]action permit
[USG6000V1]nat server ftp protocol tcp global 100.2.2.9 21 inside 192.168.0.2 21
[USG6000V1]nat server http protocol tcp global 100.2.2.9 80 inside 192.168.0.3 80
[USG6000V1]dis firewall session table
2020-02-13 08:46:51.680
Current Total Sessions : 3
ftp VPN: public --> public 200.1.1.2:2055 +-> 100.2.2.9:21[192.168.0.2:21]
http VPN: public --> public 200.1.1.2:2057 --> 100.2.2.9:80[192.168.0.3:80]
ftp VPN: public --> public 200.1.1.2:2053 +-> 100.2.2.9:21[192.168.0.2:21]
[USG6000V1]dis firewall server-map
2020-02-13 08:48:09.740
Current Total Server-map : 4
Type: Nat Server, ANY -> 100.2.2.9:80[192.168.0.3:80], Zone:---, protocol:tc
p
Vpn: public -> public
Type: Nat Server, ANY -> 100.2.2.9:21[192.168.0.2:21], Zone:---, protocol:tc
p
Vpn: public -> public
Type: Nat Server Reverse, 192.168.0.2[100.2.2.9] -> ANY, Zone:---, protocol:
tcp
Vpn: public -> public, counter: 1
Type: Nat Server Reverse, 192.168.0.3[100.2.2.9] -> ANY, Zone:---, protocol:
tcp
Vpn: public -> public, counter: 1