คู่มือการติดตั้ง Active Directory Domain Services และ Active Directory Certificate Services
Windows Server 2022
รูปแบบการติดตั้ง: แยก AD DS และ AD CS คนละเครื่อง
วัตถุประสงค์: ใช้งานระบบ Certificate ภายในองค์กร
ประเภทเอกสาร: Installation & Configuration Guide
จัดทำสำหรับผู้ดูแลระบบ Windows Server และระบบเครือข่ายองค์กร
สารบัญ
- วัตถุประสงค์
- ออกแบบระบบและกำหนด IP Address
- เตรียมความพร้อมก่อนติดตั้ง
- ติดตั้ง Active Directory Domain Services (DC01)
- ตรวจสอบระบบ Active Directory และ DNS
- เตรียมเครื่อง Certificate Authority (CA01)
- Join CA01 เข้า Domain
- ติดตั้ง Active Directory Certificate Services
- Configure Enterprise Root CA
- ตั้งค่า Certificate Template
- ตั้งค่า Group Policy Auto Enrollment
- ทดสอบการออก Certificate จาก Client
- ตรวจสอบ Firewall และ Network
- Backup และ Security
- Troubleshooting
- Checklist ตรวจรับระบบ
- แหล่งอ้างอิง Microsoft
1. วัตถุประสงค์
เอกสารฉบับนี้จัดทำขึ้นเพื่ออธิบายขั้นตอนการติดตั้งและตั้งค่าระบบ Active Directory Domain Services (AD DS) และ Active Directory Certificate Services (AD CS) บน Windows Server 2022 โดยแยกการติดตั้งออกเป็น 2 เครื่อง Server
ระบบจะประกอบด้วย
- DC01 ทำหน้าที่ Domain Controller และ DNS Server
- CA01 ทำหน้าที่ Enterprise Certificate Authority
- Client Windows 10/11 สำหรับทดสอบการรับ Certificate
วัตถุประสงค์ในการใช้งาน ได้แก่
- บริหารจัดการ User และ Computer ภายในองค์กร
- จัดการสิทธิ์การใช้งานผ่าน Active Directory
- ออกและจัดการ Digital Certificate ภายในองค์กร
- รองรับ HTTPS และ SSL สำหรับระบบภายใน
- รองรับ Certificate Authentication
- รองรับ Certificate Auto Enrollment ผ่าน Group Policy
2. ออกแบบระบบและกำหนด IP Address
2.1 Network Diagram
โครงสร้างระบบตัวอย่าง
INTERNAL NETWORK: 192.168.10.0/24
SERVER 01
- Hostname: DC01
- IP: 192.168.10.10
- Role: AD DS / DNS
- Domain: company.local
SERVER 02
- Hostname: CA01
- IP: 192.168.10.20
- Role: AD CS
- CA Name: COMPANY-CA
CLIENT
- Hostname: CLIENT01
- IP: 192.168.10.100
- Role: Domain Client
2.2 ตาราง IP Address
| รายการ | DC01 | CA01 | CLIENT01 |
|---|---|---|---|
| IP Address | 192.168.10.10 | 192.168.10.20 | 192.168.10.100 |
| Subnet | /24 | /24 | /24 |
| Gateway | .1 | .1 | .1 |
| DNS | .10 | .10 | .10 |
| Hostname | DC01 | CA01 | CLIENT01 |
Domain Name: company.local
หมายเหตุ: IP Address และ Domain Name เป็นตัวอย่าง ต้องปรับให้ตรงกับระบบเครือข่ายจริงขององค์กร แนะนำให้ใช้ DNS Subdomain ที่องค์กรเป็นเจ้าของ เช่น ad.company.com สำหรับระบบใหม่
3. เตรียมความพร้อมก่อนติดตั้ง
ตรวจสอบรายการต่อไปนี้ก่อนเริ่มติดตั้ง
- ติดตั้ง Windows Server 2022 เรียบร้อยแล้ว
- เปิดใช้งาน Windows Server และติดตั้ง Updates
- กำหนด Static IP Address
- ตั้งชื่อ Server ให้เรียบร้อย
- ตรวจสอบ Network Connectivity
- ตรวจสอบเวลาและ Time Zone
- เตรียมบัญชี Administrator
- เตรียมรหัสผ่าน DSRM
- เตรียมพื้นที่สำหรับ Backup
ควรใช้บัญชีผู้ดูแลระบบที่เหมาะสมกับแต่ละขั้นตอน และไม่ใช้ Domain Administrator เป็นบัญชีทำงานประจำวัน
4. ติดตั้ง Active Directory Domain Services (DC01)
4.1 เปลี่ยนชื่อเครื่อง Server
เปิด PowerShell แบบ Run as Administrator:
powershell
Rename-Computer -NewName "DC01" -Restart
หลังจาก Server Restart ให้ Login อีกครั้ง
4.2 กำหนด Static IP Address
ตรวจสอบชื่อ Network Adapter
powershell
Get-NetAdapter
กำหนด IP Address
powershell
New-NetIPAddress `
-InterfaceAlias "Ethernet" `
-IPAddress "192.168.10.10" `
-PrefixLength 24 `
-DefaultGateway "192.168.10.1"
กำหนด DNS
powershell
Set-DnsClientServerAddress `
-InterfaceAlias "Ethernet" `
-ServerAddresses "127.0.0.1"
ตรวจสอบ IP
powershell
Get-NetIPConfiguration
หมายเหตุ: หากมี IP เดิมจาก DHCP ให้เปลี่ยน Adapter เป็น Static หรือจัดการค่าที่มีอยู่ก่อน เพื่อป้องกันการกำหนด IP ซ้ำ
4.3 ติดตั้ง AD DS และ DNS
powershell
Install-WindowsFeature `
-Name AD-Domain-Services,DNS `
-IncludeManagementTools
ตรวจสอบ
powershell
Get-WindowsFeature AD-Domain-Services,DNS
ผลลัพธ์ที่ต้องการคือ Install State แสดง Installed
4.4 สร้าง Domain และ Forest ใหม่
กำหนด Domain Name เป็น company.local
powershell
Install-ADDSForest `
-DomainName "company.local" `
-DomainNetbiosName "COMPANY" `
-InstallDNS
ระบบจะให้กำหนด DSRM Password
หลังดำเนินการ Server จะ Restart อัตโนมัติ
4.5 Login เข้าระบบ Domain
ใช้บัญชี
text
COMPANY\Administrator
4.6 ตรวจสอบ Domain
Get-ADDomain
powershell
Get-ADForest
ตรวจสอบ Domain Controller
powershell
Get-ADDomainController -Filter *
ตรวจสอบสุขภาพระบบ
powershell
dcdiag /v
ตรวจสอบ DNS
powershell
nslookup company.local
ตรวจสอบ SRV Record
powershell
nslookup -type=SRV _ldap._tcp.dc._msdcs.company.local
ผลลัพธ์ที่ต้องการ
- Domain สามารถค้นหาได้
- DNS สามารถ Resolve ชื่อ DC01 ได้
- SRV Record ของ Active Directory แสดง Domain Controller
- ไม่มี Error สำคัญจาก DCDIAG
5. เตรียมเครื่อง Certificate Authority (CA01)
5.1 ตั้งชื่อเครื่อง
เปิด PowerShell แบบ Administrator
powershell
Rename-Computer -NewName "CA01" -Restart
5.2 กำหนด Static IP
New-NetIPAddress `
-InterfaceAlias "Ethernet" `
-IPAddress "192.168.10.20" `
-PrefixLength 24 `
-DefaultGateway "192.168.10.1"
กำหนด DNS ให้ชี้ไป DC01
Set-DnsClientServerAddress `
-InterfaceAlias "Ethernet" `
-ServerAddresses "192.168.10.10"
ตรวจสอบ DNS
nslookup DC01.company.local
ผลลัพธ์ควรได้ 192.168.10.10
5.3 ทดสอบการเชื่อมต่อ Domain Controller
Test-NetConnection DC01.company.local -Port 389
ตรวจสอบ DNS
Resolve-DnsName company.local
6. Join CA01 เข้า Domain
เปิด PowerShell แบบ Administrator
Add-Computer `
-DomainName "company.local" `
-Credential (Get-Credential) `
-Restart
กรอกบัญชี Domain Admin ที่ได้รับอนุญาต
ตัวอย่าง
COMPANY\Administrator
หลัง Restart ตรวจสอบ
Get-CimInstance Win32_ComputerSystem |
Select-Object Name,Domain,PartOfDomain
ผลลัพธ์ที่ต้องการ
Name : CA01
Domain : company.local
PartOfDomain : True
7. ติดตั้ง Active Directory Certificate Services
7.1 ข้อกำหนดก่อนติดตั้ง
ตรวจสอบว่า
- CA01 Join Domain สำเร็จ
- DNS ทำงานปกติ
- ติดต่อ DC01 ได้
- เวลา Server ถูกต้อง
- ผู้ติดตั้งมีสิทธิ์ Enterprise Admins และ Domain Admins ของ Root Domain ตามข้อกำหนดของ Microsoft
7.2 ติดตั้ง AD CS Role
เปิด PowerShell แบบ Administrator
Install-WindowsFeature `
-Name ADCS-Cert-Authority `
-IncludeManagementTools
ตรวจสอบ
Get-WindowsFeature ADCS-Cert-Authority
7.3 Configure Enterprise Root CA
กำหนดรายละเอียด
| รายการ | ค่า |
|---|---|
| CA Type | Enterprise Root CA |
| CA Name | COMPANY-CA |
| Key Length | 2048 |
| Hash Algorithm | SHA256 |
| Validity Period | 5 Years |
หมายเหตุ: ใช้ค่า RSA 2048 ตามค่าเริ่มต้นที่ Microsoft แนะนำเพื่อความเข้ากันได้ และควรประเมินอายุ CA ตามนโยบาย PKI ขององค์กร
7.4 Configure ผ่าน PowerShell
Install-AdcsCertificationAuthority `
-CAType EnterpriseRootCA `
-CACommonName "COMPANY-CA" `
-KeyLength 2048 `
-HashAlgorithmName SHA256 `
-ValidityPeriod Years `
-ValidityPeriodUnits 5 `
-Force
คำสั่งนี้จะสร้าง Private Key และ CA Certificate รวมถึงลงทะเบียน Enterprise CA เข้ากับ Active Directory
ข้อควรระวัง: ชื่อ CA เป็นค่าที่สำคัญมาก ไม่ควรเปลี่ยนหลังติดตั้ง และต้องมีแผนสำรอง CA Private Key ก่อนนำระบบไปใช้งานจริง
7.5 ตรวจสอบบริการ CA
Get-Service CertSvc
ผลลัพธ์ที่ต้องการ
Status : Running
Name : CertSvc
ตรวจสอบ CA
certutil -getconfigcertutil -config - -ping
ผลลัพธ์ควรพบ
CA01.company.local\COMPANY-CA
8. ตั้งค่า Certificate Template
8.1 เปิด Certificate Templates Console
ที่เครื่อง CA01
กด Windows + R
certtmpl.msc
จะปรากฏหน้าต่าง Certificate Templates
8.2 Duplicate Computer Template
- ค้นหา Template ชื่อ Computer
- คลิกขวา Computer
- เลือก Duplicate Template
- เลือก Compatibility ให้เหมาะสมกับ Windows Server 2022 และ Client ที่จะใช้งาน
- ตั้งชื่อ Template เป็น COMPANY-Computer
8.3 ตั้งค่า General
- Template Display Name: COMPANY-Computer
- Validity Period: 1 Year
- Renewal Period: ตามนโยบายองค์กร
8.4 ตั้งค่า Security
เพิ่มกลุ่ม Domain Computers
กำหนดสิทธิ์
| Permission | Setting |
|---|---|
| Read | Allow |
| Enroll | Allow |
| Autoenroll | Allow |
ไม่ควรให้ Domain Users หรือ Authenticated Users มีสิทธิ์ออก Certificate ที่มีความสำคัญโดยไม่จำเป็น
ตรวจสอบแท็บ Subject Name และ Extensions ให้เหมาะกับวัตถุประสงค์การใช้งาน Certificate โดยเฉพาะหากจะใช้กับ HTTPS หรือ Client Authentication
8.5 Publish Template
เปิด Certification Authority
certsrv.msc
ดำเนินการ
- ขยาย CA01
- คลิกขวา Certificate Templates
- เลือก New
- เลือก Certificate Template to Issue
- เลือก COMPANY-Computer
- กด OK
ตรวจสอบว่ามี COMPANY-Computer ปรากฏในรายการ Certificate Templates
9. ตั้งค่า Group Policy Auto Enrollment
9.1 เปิด Group Policy Management
บน DC01 กด Windows + R
gpmc.msc
สร้าง GPO ใหม่ชื่อ
COMPANY-Certificate-AutoEnrollment
Link GPO ไปยัง OU ที่มี Computer เป้าหมายอยู่
9.2 ตั้งค่า Auto Enrollment
เปิด Edit GPO แล้วไปที่
Computer Configuration
Policies
Windows Settings
Security Settings
Public Key Policies
Certificate Services Client - Auto-Enrollment
กำหนด
- Configuration Model: Enabled
- Renew expired certificates, update pending certificates, and remove revoked certificates: Checked
- Update certificates that use certificate templates: Checked
กด Apply และ OK
หมายเหตุ: ต้องสร้างและ Publish User Template เพิ่มต่างหาก หากต้องการ Auto Enrollment ให้ User
10. ทดสอบ Certificate จาก Client
10.1 เตรียม Client
ตั้งค่า IP
IP Address: 192.168.10.100
Subnet Mask: 255.255.255.0
Gateway: 192.168.10.1
DNS: 192.168.10.10
ทดสอบ DNS
nslookup DC01.company.local
Join Domain
Add-Computer `
-DomainName "company.local" `
-Credential (Get-Credential) `
-Restart
10.2 สั่ง Update Group Policy
เปิด PowerShell แบบ Administrator
gpupdate /force
ตรวจสอบ GPO
gpresult /r
10.3 สั่ง Certificate Auto Enrollment
certutil -pulse
10.4 ตรวจสอบ Certificate
กด Windows + R
certlm.msc
เปิด
Certificates (Local Computer)
Personal
Certificates
ตรวจสอบว่ามี Certificate ของ CLIENT01 และ Issuer เป็น COMPANY-CA
10.5 ตรวจสอบผ่าน PowerShell
Get-ChildItem Cert:\LocalMachine\My |
Select-Object Subject,Issuer,NotBefore,NotAfter,Thumbprint
ผลลัพธ์ที่ต้องการ
- มี Certificate ของเครื่อง
- Issuer เป็น COMPANY-CA
- Certificate ยังไม่หมดอายุ
- มี Enhanced Key Usage ที่ตรงกับ Template
- Certificate Chain สามารถตรวจสอบได้
11. ตรวจสอบ Firewall และ Network
Port ที่เกี่ยวข้อง
| Port | Protocol | Service |
|---|---|---|
| 53 | TCP/UDP | DNS |
| 88 | TCP/UDP | Kerberos |
| 123 | UDP | NTP |
| 135 | TCP | RPC |
| 389 | TCP/UDP | LDAP |
| 445 | TCP | SMB |
| 464 | TCP/UDP | Kerberos Password |
| 636 | TCP | LDAPS |
| 3268 | TCP | Global Catalog |
| 3269 | TCP | Global Catalog SSL |
| 49152–65535 | TCP | Dynamic RPC |
สำหรับ AD CS ต้องตรวจสอบการเชื่อมต่อ RPC/DCOM และ Dynamic RPC ระหว่าง CA และ Client รวมถึงช่องทาง HTTP/HTTPS สำหรับ CRL หรือ AIA หากมีการกำหนดให้เผยแพร่ผ่าน Web Server
ไม่ควรเปิด Port ทั้งหมดให้ทุกเครือข่าย ควรจำกัด Source และ Destination ตามการใช้งานจริง
ทดสอบ Port
Test-NetConnection DC01.company.local -Port 389Test-NetConnection CA01.company.local -Port 135
12. Backup และ Security
12.1 Backup AD CS
สร้าง Folder สำหรับ Backup
New-Item -Path "C:\CABackup" `
-ItemType Directory -Force
Backup CA
Backup-CARoleService `
-Path "C:\CABackup"
ต้องตรวจสอบผลการ Backup และจัดเก็บสำเนาในพื้นที่ปลอดภัยที่แยกจาก CA01
รายการที่ต้องสำรอง
- CA Database
- CA Private Key
- CA Certificate
- CA Configuration
- CAPolicy.inf (ถ้ามี)
- CRL และข้อมูลที่เกี่ยวข้อง
ควรทดสอบ Restore ตามแผน Disaster Recovery ขององค์กร
12.2 Security Recommendation
- จำกัดสิทธิ์ CA Administrator
- แยกบัญชี Admin จากบัญชีใช้งานประจำวัน
- ป้องกันการเข้าถึง Private Key
- จำกัดสิทธิ์ Certificate Template
- เปิด Windows Firewall
- ติดตั้ง Windows Updates
- สำรอง CA Database และ Private Key
- ตรวจสอบ Certificate ที่ถูกออกเป็นประจำ
- กำหนด CRL Publication และตรวจสอบการเข้าถึง CRL
- วางแผนการต่ออายุ CA Certificate ก่อนหมดอายุ
ข้อแนะนำด้านสถาปัตยกรรม: การติดตั้ง Enterprise Root CA บน Domain Member Server เป็นระบบ One-Tier PKI ซึ่งเหมาะกับ Lab หรือองค์กรขนาดเล็กที่ยอมรับความเสี่ยงได้ สำหรับระบบ Production ที่ต้องการความปลอดภัยสูง ควรใช้ Two-Tier PKI โดยแยก Offline Standalone Root CA ออกจาก Online Enterprise Subordinate CA
13. Troubleshooting
ปัญหา 1 Join Domain ไม่ได้
ตรวจสอบ DNS
ipconfig /allnslookup company.local
ตรวจสอบ Port
Test-NetConnection DC01.company.local -Port 389
สาเหตุที่พบบ่อย: ตั้ง DNS ผิด หรือ Client ไม่สามารถติดต่อ Domain Controller ได้
ปัญหา 2 CA Service ไม่ทำงาน
Get-Service CertSvc
ตรวจสอบ Event Log
Get-WinEvent -LogName System -MaxEvents 50
ปัญหา 3 Client ไม่ได้รับ Certificate
ตรวจสอบ
gpresult /rcertutil -pulse
ตรวจสอบ Template ว่า
- Publish บน CA แล้ว
- มีสิทธิ์ Enroll และ Autoenroll
- GPO ถูก Link ไปยัง OU ที่ถูกต้อง
- Client มีสิทธิ์เข้าถึง CA
- Template มีการกำหนด Subject Name และ EKU ถูกต้อง
ปัญหา 4 Certificate Chain ไม่สมบูรณ์
ตรวจสอบ Root CA Certificate
certutil -store Root
ตรวจสอบ Certificate Revocation List
certutil -urlfetch -verify C:\Temp\client.cer
ตรวจสอบว่า CRL Distribution Point สามารถเข้าถึงได้และ CRL ยังไม่หมดอายุ
14. Checklist ตรวจรับระบบ
| ลำดับ | รายการตรวจสอบ | สถานะ |
|---|---|---|
| 1 | ติดตั้ง Windows Server 2022 | □ |
| 2 | กำหนด Static IP DC01 | □ |
| 3 | ติดตั้ง AD DS | □ |
| 4 | ติดตั้ง DNS | □ |
| 5 | สร้าง Domain | □ |
| 6 | ตรวจสอบ DCDIAG | □ |
| 7 | กำหนด Static IP CA01 | □ |
| 8 | Join CA01 เข้า Domain | □ |
| 9 | ติดตั้ง AD CS | □ |
| 10 | Configure Enterprise CA | □ |
| 11 | Publish Certificate Template | □ |
| 12 | ตั้งค่า Group Policy | □ |
| 13 | Join Client เข้า Domain | □ |
| 14 | ทดสอบ Auto Enrollment | □ |
| 15 | ตรวจสอบ Certificate Chain | □ |
| 16 | Backup CA สำเร็จ | □ |
| 17 | ทดสอบ CRL และ Revocation | □ |
15. สรุปผลการติดตั้ง
เมื่อดำเนินการครบทุกขั้นตอน จะได้ระบบดังนี้
SERVER 01: DC01
- Active Directory Domain Services
- DNS Server
- Domain Controller
- Group Policy Management
SERVER 02: CA01
- Active Directory Certificate Services
- Enterprise Root CA
- Certificate Templates
- Certificate Issuance
- Certificate Management
CLIENT
- Join Domain
- รับ Group Policy
- รับ Certificate ผ่าน Auto Enrollment
- ตรวจสอบ Certificate Chain
ระบบนี้สามารถนำไปใช้เป็นพื้นฐานสำหรับ Internal PKI ขององค์กร และต่อยอดไปยังระบบ HTTPS, VPN, Wi-Fi Enterprise และ Computer Authentication ได้
16. แหล่งอ้างอิง Microsoft
- Install Active Directory Domain Services: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-
- Install the Certification Authority on Windows Server: https://learn.microsoft.com/en-us/windows-server/networking/core-network-guide/cncg/server-certs/install-the-certification-authority
- Install-AdcsCertificationAuthority PowerShell: https://learn.microsoft.com/en-us/powershell/module/adcsdeployment/install-adcscertificationauthority?view=windowsserver2022-ps
- Install-ADDSForest PowerShell: https://learn.microsoft.com/en-us/powershell/module/addsdeployment/install-addsforest?view=windowsserver2022-ps
สิ้นสุดเอกสาร
ชื่อเอกสาร: Windows Server 2022 AD DS & AD CS Installation Guide
เวอร์ชันเอกสาร: 1.0
ประเภท: Internal IT Infrastructure Documentation
หมายเหตุ: เอกสารนี้เป็นคู่มือการติดตั้งและทดสอบ ไม่ใช่หลักฐานว่าระบบได้ผ่านการติดตั้งจริงแล้ว ผู้ดูแลระบบต้องบันทึกผลการทดสอบและค่าการตั้งค่าจริงก่อนส่งมอบงาน
ไม่มีความคิดเห็น:
แสดงความคิดเห็น