In this lab we build a small but very common branch design on a FortiGate firewall: two VLANs (Users and Servers) carried on a single 802.1Q trunk from a Cisco switch, a DHCP server for each VLAN on the FortiGate, Internet access with source NAT, and a controlled inter-VLAN firewall policy. Unlike a Layer 3 switch, the FortiGate inspects every packet that moves between VLANs, so you decide exactly which traffic is allowed. All configuration is done from the FortiGate CLI, which makes it easy to copy and repeat.
Lab Topology
- FortiGate port1 (WAN): connected to the ISP router, static IP 203.0.113.2/30, default gateway 203.0.113.1.
- FortiGate port2 (LAN trunk): connected to Cisco switch GigabitEthernet0/1 as an 802.1Q trunk. No IP address on the physical port.
- VLAN 10 - USERS: 192.168.10.0/24, gateway 192.168.10.1 on the FortiGate.
- VLAN 20 - SERVERS: 192.168.20.0/24, gateway 192.168.20.1 on the FortiGate.
- A test PC sits in VLAN 10 and a web server (192.168.20.10) sits in VLAN 20.
Goal: users get an address by DHCP, can browse the Internet, and can reach the server only on HTTPS and ping. Servers can reach the Internet for updates but cannot open sessions towards the users.
Step 1: Configure the Cisco switch trunk and access ports
Create the VLANs, make the uplink to the FortiGate a trunk that only carries VLANs 10 and 20, and put the host ports in the right VLANs. On switches that also support ISL (for example the 3560), add switchport trunk encapsulation dot1q before switchport mode trunk.
Switch(config)# vlan 10 Switch(config-vlan)# name USERS Switch(config-vlan)# vlan 20 Switch(config-vlan)# name SERVERS Switch(config-vlan)# exit Switch(config)# interface GigabitEthernet0/1 Switch(config-if)# description Trunk-to-FortiGate-port2 Switch(config-if)# switchport mode trunk Switch(config-if)# switchport trunk allowed vlan 10,20 Switch(config-if)# switchport nonegotiate Switch(config-if)# exit Switch(config)# interface GigabitEthernet0/2 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 10 Switch(config-if)# spanning-tree portfast Switch(config-if)# exit Switch(config)# interface GigabitEthernet0/3 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 20 Switch(config-if)# spanning-tree portfast
switchport nonegotiate disables DTP, which the FortiGate does not speak anyway.
Step 2: Configure the WAN interface and default route on the FortiGate
config system interface
edit "port1"
set mode static
set ip 203.0.113.2 255.255.255.252
set allowaccess ping
set role wan
next
end
config router static
edit 1
set gateway 203.0.113.1
set device "port1"
next
end
A static route without a dst value defaults to 0.0.0.0/0, so this is the default route.
Step 3: Create the VLAN sub-interfaces on port2
Each VLAN becomes its own logical interface with its own IP address. The physical parent (port2) stays in static mode with no IP.
config system interface
edit "VLAN10-USERS"
set vdom "root"
set ip 192.168.10.1 255.255.255.0
set allowaccess ping https ssh
set role lan
set interface "port2"
set vlanid 10
next
edit "VLAN20-SRV"
set vdom "root"
set ip 192.168.20.1 255.255.255.0
set allowaccess ping
set role lan
set interface "port2"
set vlanid 20
next
end
Keep interface names to 15 characters or fewer, which is the FortiOS limit. Only allow HTTPS/SSH management on the VLAN your admins actually use.
Step 4: Enable a DHCP server on each VLAN
config system dhcp server
edit 10
set dns-service default
set default-gateway 192.168.10.1
set netmask 255.255.255.0
set interface "VLAN10-USERS"
config ip-range
edit 1
set start-ip 192.168.10.100
set end-ip 192.168.10.200
next
end
next
edit 20
set dns-service default
set default-gateway 192.168.20.1
set netmask 255.255.255.0
set interface "VLAN20-SRV"
config ip-range
edit 1
set start-ip 192.168.20.100
set end-ip 192.168.20.150
next
end
next
end
dns-service default hands out the same DNS servers the FortiGate itself uses. The web server keeps a static address (192.168.20.10) outside the DHCP range.
Step 5: Create address objects and firewall policies
By default the FortiGate drops everything with the implicit deny policy, so traffic only flows where we create a policy.
config firewall address
edit "WEB-SRV-192.168.20.10"
set subnet 192.168.20.10 255.255.255.255
next
end
config firewall policy
edit 0
set name "USERS-to-Internet"
set srcintf "VLAN10-USERS"
set dstintf "port1"
set action accept
set srcaddr "all"
set dstaddr "all"
set schedule "always"
set service "ALL"
set nat enable
set logtraffic all
next
edit 0
set name "SRV-to-Internet"
set srcintf "VLAN20-SRV"
set dstintf "port1"
set action accept
set srcaddr "all"
set dstaddr "all"
set schedule "always"
set service "HTTP" "HTTPS" "DNS" "NTP"
set nat enable
next
edit 0
set name "USERS-to-WEB-SRV"
set srcintf "VLAN10-USERS"
set dstintf "VLAN20-SRV"
set action accept
set srcaddr "all"
set dstaddr "WEB-SRV-192.168.20.10"
set schedule "always"
set service "HTTPS" "PING"
set logtraffic all
next
end
edit 0 tells FortiOS to use the next free policy ID. Note that the inter-VLAN policy has NAT disabled, so the server sees the real client IP. There is no policy from VLAN20 to VLAN10, so servers cannot start sessions towards users, but replies to user sessions are still allowed because the firewall is stateful.
Verification
- Interfaces are up with the right IPs:
show system interface VLAN10-USERS get system interface physical port2
port2 should show status up, and the VLAN interface should show IP 192.168.10.1 with vlanid 10. - Clients received leases:
execute dhcp lease-list
You should see the test PC's MAC address with an IP from 192.168.10.100-200 under the VLAN10-USERS interface. - Trunk is working on the switch:
Switch# show interfaces trunk Switch# show vlan brief
Gi0/1 should be in trunking mode with VLANs 10 and 20 allowed and forwarding. - Traffic hits the expected policy: from the PC open https://192.168.20.10, then check the sessions:
diagnose sys session filter clear diagnose sys session filter dst 192.168.20.10 diagnose sys session list
The session output shows the policy ID inpolicy_id=, which should match USERS-to-WEB-SRV. - Packets on the wire:
diagnose sniffer packet any 'host 192.168.20.10 and icmp' 4
Verbosity 4 prints the interface name, so you will see the echo request arrive on VLAN10-USERS and leave on VLAN20-SRV.
Troubleshooting Tips
- No DHCP address: check the switch port is in the correct access VLAN and that the trunk allows that VLAN. A native VLAN mismatch will not break tagged VLANs, but a missing VLAN in
allowed vlanwill. - Traffic is dropped between VLANs: run the debug flow and look for "Denied by forward policy check (policy 0)", which means no policy matched:
diagnose debug flow filter clear diagnose debug flow filter addr 192.168.20.10 diagnose debug flow show function-name enable diagnose debug flow trace start 20 diagnose debug enable
Stop it withdiagnose debug disableanddiagnose debug reset. - Ping to the gateway fails: make sure
allowaccess pingis set on the VLAN interface; it controls traffic to the FortiGate itself, not through it. - Server sees the FortiGate IP instead of the client IP: NAT is enabled on the inter-VLAN policy. Disable it unless you really need it.
- Policy order: FortiOS matches policies top-down. Use
show firewall policyto check the order and move a specific rule above a broad one withmove.
0 Comments