Step-by-Step Switch and Firewall Configuration Guide (VLAN, DHCP, NAT, and Routing)
This guide provides detailed commands to configure a switch for user access VLANs, set up a firewall as both a layer‑3 and layer‑2 device with VLAN interfaces, DHCP/DNS, security zones, static routing, and NAT to enable internal users to reach external networks.
Switch configuration (2 steps):
vlan batch 2 3interface gigabitethernet0/0/2port link-type accessport default vlan 2quitinterface gigabitethernet0/0/3port link-type accessport default vlan 3quitUplink to firewall (step 2):
interface gigabitethernet0/0/1port link-type trunkport trunk allow-pass vlan 2 3quitFirewall as a layer‑3 device (5 steps): Step 1 – Create sub‑interfaces:
vlan batch 2 3interface gigabitethernet0/0/1.1vlan-type dot1q 2ip address 192.168.1.1 24quitinterface gigabitethernet0/0/1.2vlan-type dot1q 3ip address 192.168.2.1 24quitStep 2 – Enable DHCP and DNS:
dhcp enableinterface gigabitethernet0/0/1.1dhcp select interfacedhcp server dns-list 114.114.114.114 223.5.5.5quitinterface gigabitethernet0/0/1.2dhcp select interfacedhcp server dns-list 114.114.114.114 223.5.5.5quitStep 3 – Configure security zones and default policy:
firewall zone trustadd interface gigabitethernet0/0/1add interface gigabitethernet0/0/1.1add interface gigabitethernet0/0/1.2quitfirewall zone untrustadd interface gigabitethernet0/0/2quitfirewall packet-filter default permit allStep 4 – Configure public interface IP and static route:
interface gigabitethernet0/0/2ip address 200.0.0.2 255.255.255.0quitip route-static 0.0.0.0 0.0.0.0 200.0.0.1Step 5 – Enable NAT for outbound traffic:
nat address-group 1 200.0.0.2 200.0.0.2nat-policy interzone trust untrust outboundpolicy 1policy source 192.168.0.0 0.0.255.255action source-nataddress-group 1quitFirewall as a layer‑2 device using VLANIF (5 steps): Step 1 – Create VLANIF interfaces:
vlan batch 2 3interface gigabitethernet0/0/1portswitchport link-type trunkport trunk permit vlan 2 3quitinterface vlanif 2ip address 192.168.1.1 24quitinterface vlanif 3ip address 192.168.2.1 24quitStep 2 – Enable DHCP and DNS on VLANIFs (same commands as above, applied to vlanif 2 and 3).
Step 3 – Configure zones and default policy (same as layer‑3 steps, using vlanif interfaces).
Step 4 – Configure public interface IP and static route (same as layer‑3 step 4).
Step 5 – Configure NAT for outbound traffic (same as layer‑3 step 5).
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
