Tech Docs
/

ตั้งค่า FortiGate เบื้องต้น

ในบทนี้เราจะแนะนำการตั้งค่า FortiGate ให้เครื่องคอมพิวเตอร์ภายใน Internal network สามารถออก Internet ได้ เป็นพื้นฐานที่จำเป็นสำหรับการเริ่มต้นใช้งาน FortiGate ทุกตัว

Scope

  • อุปกรณ์ทดสอบ: FortiGate 60F firmware v7.6.6
  • โหมดการทำงาน: NAT mode (default)
  • Configuration อื่น ๆ: ใช้ค่า default ทั้งหมด

Topology

┌──────────┐      ┌──────────┐         ┌─────────────────┐         ┌──────────────────┐
│ Internet │ ───→ │  Router  │ ──────→ │    FortiGate    │ ──────→ │ Internal Network │
└──────────┘      └─────┬────┘         └──┬───────────┬──┘         └────────┬─────────┘
                        │                 │           │                     │
                    LAN port            wan1       internal              Clients
                  192.168.0.2/24   192.168.0.1/24 192.168.1.99/24         (DHCP)
                        │                 │           │                     │
                        └─── WAN link ────┘           └──── LAN link ───────┘
                            192.168.0.0/24                192.168.1.0/24
Segment Subnet อุปกรณ์ในเซกเมนต์
WAN-side link 192.168.0.0/24 Router LAN port (.0.2) ↔ FortiGate wan1 (.0.1)
LAN-side link 192.168.1.0/24 FortiGate internal (.1.99) ↔ Clients (DHCP .1.100-.1.200)

หมายเหตุ: บน FortiGate 60F และรุ่นที่มี VLAN Switch เป็น default — interface ที่ชื่อ internal จะรวม physical port internal1 ถึง internal5 ไว้เป็น 1 ก้อน เราจะตั้งค่าที่ internal ทีเดียวพอ ไม่ต้องตั้ง internal1 internal2 แยกกัน

ภาพรวมขั้นตอน

หลังจากที่ติดตั้งอุปกรณ์เข้ากับ network ตาม topology แล้ว สิ่งที่ต้องทำมี 3 ขั้น:

  1. ตั้งค่า Interface — กำหนด IP ให้ขา WAN และขา LAN
  2. ตั้งค่า Routing — บอก FortiGate ว่า traffic ขาออกไปทางไหน
  3. ตั้งค่า Firewall Policy — อนุญาตให้ traffic จาก LAN ออก WAN ได้

Step 1: ตั้งค่า Interface

ไปที่ Network → Interfaces

หน้าจอ Network → Interfaces ใน FortiGate 60F แสดง wan1, dmz, internal รูป 1: หน้ารวม Interfaces — เห็น wan1 (Physical), internal (VLAN Switch รวม internal1-5)

1.1 ตั้งค่า WAN1 (เชื่อมไป Router)

ดับเบิลคลิกที่ wan1 แล้วตั้งค่า:

หน้าจอแก้ไข wan1 — IP 192.168.0.1/24, Role WAN, Administrative Access เปิดเฉพาะ PING รูป 2: Edit Interface wan1

Field ค่า
Addressing mode Manual
IP / Netmask 192.168.0.1/24
Administrative Access PING เท่านั้น (ไม่เปิด HTTPS/SSH ที่ฝั่ง WAN)
Role WAN

เหตุผลที่ไม่เปิด HTTPS บน wan1: เพื่อความปลอดภัย — หากต้อง remote เข้าจาก Internet ใช้ VPN เข้ามาแทน

📋 CLI equivalent (คลิกเพื่อขยาย)
config system interface
    edit "wan1"
        set mode static
        set ip 192.168.0.1 255.255.255.0
        set allowaccess ping
        set role wan
    next
end

1.2 ตั้งค่า Internal (เชื่อมไป Client)

ดับเบิลคลิกที่ internal แล้วตั้งค่า:

หน้าจอแก้ไข internal interface — VLAN Switch, IP 192.168.1.99/24, Role LAN รูป 3: Edit Interface internal

Field ค่า
Type VLAN Switch (default — มี internal1-internal5 เป็น member)
Role LAN
Addressing mode Manual
IP / Netmask 192.168.1.99/24

เกี่ยวกับ IP 192.168.1.99: ค่านี้เป็น default ของ FortiGate (มาจากโรงงาน) — ใน Lab นี้เราใช้ค่า default ตามที่มี ถ้าต้องการเปลี่ยนเป็น IP อื่น (เช่น 192.168.1.1) สามารถแก้ที่ช่อง IP/Netmask ในหน้าเดียวกันนี้ได้เลย แล้วอย่าลืมแก้ Default Gateway ของ DHCP (ขั้น 1.3) ให้ตรงกัน

📋 CLI equivalent (คลิกเพื่อขยาย)
config system interface
    edit "internal"
        set ip 192.168.1.99 255.255.255.0
        set allowaccess ping https
        set role lan
    next
end

1.3 (ทางเลือก) แจก DHCP ให้ Client

หน้าเดียวกับ 1.2 — เลื่อนลงล่างจะเห็น section Administrative Access + DHCP Server เปิด toggle และตั้งค่า:

หน้าจอตั้งค่า DHCP Server — Range .100-.200, Gateway 192.168.1.99, DNS 1.1.1.1 + 8.8.8.8 รูป 4: Administrative Access (PING + HTTPS) และ DHCP Server

Field ค่า
Administrative Access PING, HTTPS
DHCP status Enabled
Address range 192.168.1.100 - 192.168.1.200
Netmask 255.255.255.0
Default gateway Same as Interface IP (= 192.168.1.99)
DNS server Specify → 1.1.1.1, 8.8.8.8
📋 CLI equivalent (คลิกเพื่อขยาย)
config system dhcp server
    edit 1
        set default-gateway 192.168.1.99
        set netmask 255.255.255.0
        set interface "internal"
        config ip-range
            edit 1
                set start-ip 192.168.1.100
                set end-ip 192.168.1.200
            next
        end
        set dns-service specify
        set dns-server1 1.1.1.1
        set dns-server2 8.8.8.8
    next
end

Step 2: ตั้งค่า Static Routing

ไปที่ Network → Static Routes แล้วคลิก Create New

หน้า Static Routes ว่างเปล่า — ยังไม่มี route ใด ๆ รูป 5: หน้า Static Routes ก่อนสร้าง

ใส่ข้อมูล default route:

หน้าจอ New Static Route — Destination 0.0.0.0/0, Gateway 192.168.0.2, Interface wan1 รูป 6: New Static Route — default route ผ่าน wan1 ไปยัง Router

Field ค่า
Destination Subnet 0.0.0.0/0.0.0.0
Gateway Address Specify → 192.168.0.2
Interface wan1
Administrative Distance 10 (default)
Status Enabled

อธิบาย: การกำหนด destination เป็น 0.0.0.0/0 หมายถึง Default Route — ถ้าไม่มี route ไหน match ที่เฉพาะเจาะจงกว่านี้ ทุก traffic จะใช้ rule นี้ (ส่งไปให้ Router ที่ 192.168.0.2)

📋 CLI equivalent (คลิกเพื่อขยาย)
config router static
    edit 0
        set dst 0.0.0.0 0.0.0.0
        set gateway 192.168.0.2
        set device "wan1"
    next
end

Step 3: ตั้งค่า Firewall Policy

ไปที่ Policy & Objects → Firewall Policy

หน้า Firewall Policy แสดง default policy internal → wan1 ที่ firmware สร้างไว้แล้ว รูป 7: หน้า Firewall Policy บน firmware 7.6.6 — มี default policy internal → wan1 อยู่แล้ว

หมายเหตุสำหรับ firmware 7.6.6: จะเห็นว่ามี default policy internal → wan1 (Source all → Destination all, Action ACCEPT, NAT enabled) สร้างไว้ให้แล้ว ตามทฤษฎีแค่นี้ client ก็ออก Internet ได้

แต่ในบทเรียนนี้เราจะ สาธิตการสร้าง policy ใหม่ด้วยตัวเอง เพื่อให้เข้าใจ field ทุกตัว

คลิก Create new เพื่อสร้าง policy ใหม่:

หน้า Create New Policy ส่วนบน — Name, Schedule, Action, Interface, Source/Destination/Service รูป 8: Create New Policy — ส่วนข้อมูลพื้นฐาน

Field ค่า
Name Allow internal to Internet
Schedule always
Action ACCEPT
Incoming interface internal
Outgoing interface wan1
Source all
Destination all
Service ALL

เลื่อนลง — ตั้งค่า NAT, Security Profiles และ Logging:

หน้า Create New Policy ส่วนล่าง — NAT enabled, Security Profiles ปิดทั้งหมด, Log All sessions รูป 9: Create New Policy — Firewall/Network Options และ Logging

Field ค่า
NAT Enabled
IP pool configuration Use Outgoing Interface Address
Security Profiles ปิดทั้งหมด (เน้นทดสอบ connectivity ก่อน)
SSL inspection no-inspection
Log Allowed Traffic All Sessions
📋 CLI equivalent (คลิกเพื่อขยาย)
config firewall policy
    edit 0
        set name "Allow internal to Internet"
        set srcintf "internal"
        set dstintf "wan1"
        set srcaddr "all"
        set dstaddr "all"
        set service "ALL"
        set action accept
        set schedule "always"
        set nat enable
        set logtraffic all
    next
end

ตรวจสอบผลลัพธ์

หลังตั้งค่าครบทั้ง 3 ขั้น ทดสอบจากเครื่อง client ใน internal network:

# ทดสอบจาก client
ping 192.168.1.99          # ทดสอบถึง FortiGate
ping 192.168.0.2           # ทดสอบถึง Router
ping 8.8.8.8               # ทดสอบออก Internet
nslookup www.google.com    # ทดสอบ DNS

Command Prompt บน Windows — ping 8.8.8.8 ได้ผลตอบกลับ 4/4 packets รูป 10: ทดสอบจาก client PC — Internet ใช้งานได้

ทดสอบจาก FortiGate เอง — เปิด CLI Console (ไอคอน >_ ที่ topbar):

# ตรวจสอบจาก FortiGate CLI
execute ping 8.8.8.8        # ทดสอบออก Internet

# ดู routing table
get router info routing-table all

CLI Console บน FortiGate — ping 1.1.1.1 ได้ผลตอบกลับ รูป 11: ทดสอบ ping จาก FortiGate ไปยัง Internet

ดู client ที่ได้รับ DHCP — กลับไป Network → Interfaces column DHCP clients ของ internal:

หน้า Interfaces แสดง DHCP clients = 1, range 192.168.1.100-192.168.1.200 รูป 12: client ได้รับ IP จาก DHCP server


ปัญหาที่พบบ่อย

อาการ สาเหตุที่เป็นไปได้
Client ping FortiGate (192.168.1.99) ไม่เจอ ลืมเปิด allowaccess ping บน internal
Client ไม่ได้ IP จาก DHCP DHCP Server ปิดอยู่ หรือ subnet ผิด
Ping ภายในได้ แต่ออก Internet ไม่ได้ ลืมสร้าง static route หรือ gateway ผิด
ออก Internet ได้แต่เปิดเว็บไม่ได้ DNS ไม่ทำงาน

Best Practices

  • อย่าเปิด allowaccess HTTPS/SSH บน WAN interface ใน production — ใช้ VPN เข้าแทน
  • ตั้งชื่อ policy ให้สื่อความหมายAllow internal to Internet ดีกว่า policy 1