

图 1 三层交换机与防火墙对接上网组网图

三层交换机是具有路由功能的交换机。 由于路由属于 OSI 模型中第三层(网络层)的功能,因此称为三层交换机。
特点如下:
以下型号在指定版本及以后支持 DHCP Server 功能(完整列表略)
📌 具体默认适用版本请参考《案例适用的产品和版本说明》。
如图 1 所示:
整体采用如下设计思路:
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] vlan batch 2 3
[Switch] interface GigabitEthernet0/0/2
[Switch-GigabitEthernet0/0/2] port link-type access
[Switch-GigabitEthernet0/0/2] port default vlan 2
[Switch-GigabitEthernet0/0/2] quit
[Switch] interface GigabitEthernet0/0/3
[Switch-GigabitEthernet0/0/3] port link-type access
[Switch-GigabitEthernet0/0/3] port default vlan 3
[Switch-GigabitEthernet0/0/3] quit
[Switch] interface Vlanif2
[Switch-Vlanif2] ip address 192.168.1.1 24
[Switch-Vlanif2] quit
[Switch] interface Vlanif3
[Switch-Vlanif3] ip address 192.168.2.1 24
[Switch-Vlanif3] quit
[Switch] vlan batch 100
[Switch] interface GigabitEthernet0/0/1
[Switch-GigabitEthernet0/0/1] port link-type access
[Switch-GigabitEthernet0/0/1] port default vlan 100
[Switch-GigabitEthernet0/0/1] quit
[Switch] interface Vlanif100
[Switch-Vlanif100] ip address 192.168.100.2 24
[Switch-Vlanif100] quit
[Switch] ip route-static 0.0.0.0 0.0.0.0 192.168.100.1
默认路由指向防火墙内网接口
[Switch] dhcp enable
[Switch] interface Vlanif2
[Switch-Vlanif2] dhcp select interface
[Switch-Vlanif2] dhcp server dns-list 114.114.114.114 223.5.5.5
[Switch-Vlanif2] quit
[Switch] interface Vlanif3
[Switch-Vlanif3] dhcp select interface
[Switch-Vlanif3] dhcp server dns-list 114.114.114.114 223.5.5.5
[Switch-Vlanif3] quit
<USG6600> system-view
[USG6600] interface GigabitEthernet1/0/1
[USG6600-GigabitEthernet1/0/1] ip address 192.168.100.1 255.255.255.0
[USG6600-GigabitEthernet1/0/1] quit
[USG6600] interface GigabitEthernet1/0/2
[USG6600-GigabitEthernet1/0/2] ip address 203.0.113.2 255.255.255.0
[USG6600-GigabitEthernet1/0/2] quit
[USG6600] ip route-static 0.0.0.0 0.0.0.0 203.0.113.1
[USG6600] ip route-static 192.168.0.0 255.255.0.0 192.168.100.2
[USG6600] firewall zone trust
[USG6600-zone-trust] add interface GigabitEthernet1/0/1
[USG6600-zone-trust] quit
[USG6600] firewall zone untrust
[USG6600-zone-untrust] add interface GigabitEthernet1/0/2
[USG6600-zone-untrust] quit
[USG6600] security-policy
[USG6600-policy-security] rule name policy1
[USG6600-policy-security-rule-policy1] source-zone trust
[USG6600-policy-security-rule-policy1] destination-zone untrust
[USG6600-policy-security-rule-policy1] source-address 192.168.0.0 mask 255.255.0.0
[USG6600-policy-security-rule-policy1] action permit
[USG6600-policy-security-rule-policy1] quit
[USG6600-policy-security] quit
[USG6600] nat address-group addressgroup1
[USG6600-address-group-addressgroup1] mode pat
[USG6600-address-group-addressgroup1] route enable
[USG6600-address-group-addressgroup1] section 0 203.0.113.2 203.0.113.2
[USG6600-address-group-addressgroup1] quit
[USG6600] nat-policy
[USG6600-policy-nat] rule name policy_nat1
[USG6600-policy-nat-rule-policy_nat1] source-zone trust
[USG6600-policy-nat-rule-policy_nat1] destination-zone untrust
[USG6600-policy-nat-rule-policy_nat1] source-address 192.168.0.0 mask 255.255.0.0
[USG6600-policy-nat-rule-policy_nat1] action nat address-group addressgroup1
[USG6600-policy-nat-rule-policy_nat1] quit
[USG6600-policy-nat] quit
✅ PC1 / PC2 均可 Ping 通外网 ✅ PC1 / PC2 均可正常访问 Internet
sysname Switch
vlan batch 2 to 3 100
dhcp enable
interface Vlanif2
ip address 192.168.1.1 255.255.255.0
dhcp select interface
dhcp server dns-list 114.114.114.114 223.5.5.5
interface Vlanif3
ip address 192.168.2.1 255.255.255.0
dhcp select interface
dhcp server dns-list 114.114.114.114 223.5.5.5
interface Vlanif100
ip address 192.168.100.2 255.255.255.0
interface GigabitEthernet0/0/1
port link-type access
port default vlan 100
interface GigabitEthernet0/0/2
port link-type access
port default vlan 2
interface GigabitEthernet0/0/3
port link-type access
port default vlan 3
ip route-static 0.0.0.0 0.0.0.0 192.168.100.1
interface GigabitEthernet1/0/1
ip address 192.168.100.1 255.255.255.0
interface GigabitEthernet1/0/2
ip address 203.0.113.2 255.255.255.0
firewall zone trust
add interface GigabitEthernet1/0/1
firewall zone untrust
add interface GigabitEthernet1/0/2
ip route-static 0.0.0.0 0.0.0.0 203.0.113.1
ip route-static 192.168.0.0 255.255.0.0 192.168.100.2
nat address-group addressgroup1
mode pat
route enable
section 0 203.0.113.2 203.0.113.2
security-policy
rule name policy1
source-zone trust
destination-zone untrust
source-address 192.168.0.0 mask 255.255.0.0
action permit
nat-policy
rule name policy_nat1
source-zone trust
destination-zone untrust
source-address 192.168.0.0 mask 255.255.0.0
action nat address-group addressgroup1