在企业网络环境中,二层交换机无法进行三层转发,通常部署于网络的接入层,而防火墙通常部署在汇聚或出口位置,负责跨VLAN路由、DHCP地址分配、安全策略管控和NAT转换。
项目 | 配置对象 | 说明 |
---|---|---|
VLAN 配置 | 二层交换机 | 用户接口划入各自 VLAN,连接防火墙的接口为 trunk |
三层转发 | 防火墙(子接口/VLANIF) | 为不同 VLAN 分配 IP,作为网关 |
DHCP 分配 | 防火墙接口 | 接口启用 DHCP Server |
NAT 转换 | 防火墙 PAT 模式 | 实现私网地址到公网地址转换 |
安全策略 | 防火墙 | 域间(trust→untrust)访问放通 |
Internet 出口 | 防火墙 | 公网 IP 地址及缺省路由配置 |
<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 GigabitEthernet0/0/1
[Switch-GigabitEthernet0/0/1] port link-type trunk
[Switch-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 3
[Switch-GigabitEthernet0/0/1] quit
<USG6600> system-view
# 配置子接口
[USG6600] interface GigabitEthernet1/0/1.1
[USG6600-GE1/0/1.1] vlan-type dot1q 2
[USG6600-GE1/0/1.1] ip address 192.168.1.1 255.255.255.0
[USG6600-GE1/0/1.1] dhcp select interface
[USG6600-GE1/0/1.1] dhcp server dns-list 114.114.114.114 223.5.5.5
[USG6600-GE1/0/1.1] quit
[USG6600] interface GigabitEthernet1/0/1.2
[USG6600-GE1/0/1.2] vlan-type dot1q 3
[USG6600-GE1/0/1.2] ip address 192.168.2.1 255.255.255.0
[USG6600-GE1/0/1.2] dhcp select interface
[USG6600-GE1/0/1.2] dhcp server dns-list 114.114.114.114 223.5.5.5
[USG6600] interface GigabitEthernet1/0/2
[USG6600-GE1/0/2] ip address 203.0.113.2 255.255.255.0
[USG6600] ip route-static 0.0.0.0 0.0.0.0 203.0.113.1
[USG6600] firewall zone trust
[USG6600-zone-trust] add interface GigabitEthernet1/0/1
[USG6600-zone-trust] add interface GigabitEthernet1/0/1.1
[USG6600-zone-trust] add interface GigabitEthernet1/0/1.2
[USG6600] firewall zone untrust
[USG6600-zone-untrust] add interface GigabitEthernet1/0/2
# 放通策略
[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] nat address-group addressgroup1
[USG6600-addressgroup1] mode pat
[USG6600-addressgroup1] route enable
[USG6600-addressgroup1] section 0 203.0.113.2 203.0.113.2
[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
适用于接口模式为二层(portswitch)时使用 VLANIF 终结。
[USG6600] vlan batch 2 3
[USG6600] interface GigabitEthernet1/0/1
[USG6600-GE1/0/1] portswitch
[USG6600-GE1/0/1] port link-type hybrid
[USG6600-GE1/0/1] port hybrid tagged vlan 2 to 3
# 配置 VLANIF 接口 IP
[USG6600] interface Vlanif2
[USG6600-Vlanif2] ip address 192.168.1.1 24
[USG6600-Vlanif2] dhcp select interface
[USG6600-Vlanif2] dhcp server dns-list 114.114.114.114 223.5.5.5
[USG6600] interface Vlanif3
[USG6600-Vlanif3] ip address 192.168.2.1 24
[USG6600-Vlanif3] dhcp select interface
[USG6600-Vlanif3] dhcp server dns-list 114.114.114.114 223.5.5.5
其余配置(公网接口、安全域、安全策略、NAT)与子接口方式一致。
PC1/PC2 > ping 203.0.113.1
方案 | 特点 | 场景适用 |
---|---|---|
子接口 | 每个 VLAN 对应一个子接口,三层终结在物理端口子接口 | 更灵活,配置清晰,适合多 VLAN 跨网段 |
VLANIF 接口 | 防火墙端口为二层 hybrid 模式,三层终结在 VLANIF | 接入方式灵活,更类似三层交换模式 |
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。