บทความนี้เป็นตอนต่อจาก “ติดตั้ง FOG Project บน Ubuntu 18.04 Server” หลังจาก แตกไฟล์ มาเสร็จแล้ว มาดูขั้นตอนติดตั้ง
sudo ./installfog.sh
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog01.jpg)
เลือก 2
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog02.jpg)
กด Y และ Enter
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog03.jpg)
กด N และ Enter
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog04-1.jpg)
ตัวอย่าง จะติดตั้ง fog server ให้ใช้ IP 10.0.100.254 และ ตอบ N ทุกคำถาม Would you like … ตรงนี้ ซึ่งจะเกี่ยวข้องกับ DHCP server ว่า จะติดตั้งลงใน fog server มั้ย
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog05.jpg)
ตรวจสอบ พร้อมแล้ว ก็กด Y และ Enter
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog06.jpg)
สำหรับ Ubuntu 18.04 นั้น ถ้าเราติดตั้ง MySQL ไม่จำเป็นต้องตั้ง password เราก็ใช้คำสั่ง mysql เพื่อเข้าไปทำงานได้ ก็ต่อเมื่อ เราเป็น user ที่เป็น sudo จึงไม่ต้องตั้ง password แต่จะตั้งก็ได้ ไม่ผิด
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog07.jpg)
ใกล้เสร็จแล้ว ให้ไปที่หน้าเว็บ http://fog_server_ip/fog/management เพื่อตั้งค่า database
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog07-254.jpg)
แล้วกลับมาทำการตั้งค่าต่อ กด Enter
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog09.jpg)
สังเกต มีคำว่า Skipped ที่บรรทัด DHCP Server
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog10.jpg)
เสร็จกระบวนการติดตั้ง fog server
ถัดไปจะติดตั้ง dnsmasq เพื่อเป็น Proxy DHCP ไปติดต่อกับ DHCP server ของตึก
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog11.jpg)
ทำตาม link นี้ https://wiki.fogproject.org/wiki/index.php?title=ProxyDHCP_with_dnsmasq
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog12.jpg)
พิมพ์คำสั่งเพื่อติดตั้ง ดังนี้
sudo apt install dnsmasq -y
เสร็จแล้ว ไปหาเครื่องที่สามารถใช้งานแบบ กราฟิก GUI เพื่อ copy ข้อความหลาย ๆ บรรทัดได้ เช่น เปิด bash ใน Windows แล้วใช้คำสั่ง ssh เข้าไปยัง fog server IP ดังนี้
ssh mama@10.0.100.254
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog13.jpg)
จะทำให้สะดวกกว่า คีย์เอง ทีละบรรทัด
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog14.jpg)
สร้างไฟล์ชื่อ fog.conf ไว้ภายในไดเรกทอรี /etc/dnsmasq.d ใส่ข้อความ ดังนี้
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog15.jpg)
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog16.jpg)
ข้อความที่จะให้ copy ไป paste คือ
# Don't function as a DNS server: port=0 # Log lots of extra information about DHCP transactions. log-dhcp # Set the root directory for files available via FTP. tftp-root=/tftpboot # The boot filename, Server name, Server Ip Address dhcp-boot=undionly.kpxe,,10.0.100.254 # Disable re-use of the DHCP servername and filename fields as extra # option space. That's to avoid confusing some old or broken DHCP clients. dhcp-no-override # inspect the vendor class string and match the text to set the tag dhcp-vendorclass=BIOS,PXEClient:Arch:00000 dhcp-vendorclass=UEFI32,PXEClient:Arch:00006 dhcp-vendorclass=UEFI,PXEClient:Arch:00007 dhcp-vendorclass=UEFI64,PXEClient:Arch:00009 # Set the boot file name based on the matching tag from the vendor class (above) dhcp-boot=net:UEFI32,i386-efi/ipxe.efi,,10.0.100.254 dhcp-boot=net:UEFI,ipxe.efi,,10.0.100.254 dhcp-boot=net:UEFI64,ipxe.efi,,10.0.100.254 # PXE menu. The first part is the text displayed to the user. The second is the timeout, in seconds. pxe-prompt="Booting FOG Client", 1 # The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86, # Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI # This option is first and will be the default if there is no input from the user. pxe-service=X86PC, "Boot to FOG", undionly.kpxe pxe-service=X86-64_EFI, "Boot to FOG UEFI", ipxe.efi pxe-service=BC_EFI, "Boot to FOG UEFI PXE-BC", ipxe.efi dhcp-range=10.0.100.254,proxy
ให้แทนที่ 10.0.100.254 ด้วย fog server IP ของคุณ แล้ว save ออกมาจากการแก้ไขไฟล์ แล้ว ตรวจสอบด้วยการรัน service ดูว่า ทำงานได้ ไม่ error
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog17.jpg)
รันคำสั่งดังนี้
sudo systemctl restart dnsmasq.service
ตรวจสอบ status
sudo systemctl status dnsmasq.service
กด q ออก
ถ้ามี error ให้ตรวจสอบว่า ในไดเรกทอรี /etc/dnsmasq.d มีไฟล์คอนฟิกสักไฟล์ที่มีคำว่า bind-interfaces อยู่ข้างในมั้ย ถ้าไม่มีก็สร้างไฟล์ชื่อ etc.conf และมี 1 บรรทัดใส่คำว่า bind-interfaces และ save แล้ว รีสตาร์ท dnsmasq ก็น่าจะใช้งานได้
แล้วตั้งค่าให้ dnsmasq ทำงานเมื่อเปิดเครื่อง
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog18.jpg)
รันคำสั่ง
sudo systemctl enable dnsmasq.service
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog19.jpg)
ออกจาก ssh และ reboot fog server เพื่อดูว่า service dnsmasq เรียบร้อย
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog20.jpg)
เมื่อ boot Windows 7 จะเห็นว่า มันจะไปขอ DHCP IP จาก 10.0.100.1 ในที่นี้คือ DHCP server ของตึก (router) และมันจะรู้ด้วยว่า fog server คือ 10.0.100.254
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog21.jpg)
ตัวอย่าง ใน LAN configuration ก็จะมีข้อมูลบอกว่า DHCP Server ที่แจก IP มาให้ Windows คือ 10.0.100.1
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog37.jpg)
เมื่อดูใน /var/log/syslog ของเครื่อง fog server จะเห็น service dnsmasq ทำงาน
ต่อไปเป็นการใช้งาน เพื่อทดสอบว่า กระบวนการติดตั้ง fog server ใช้งานแบบ proxy DHCP ทำงานได้จริง
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog22.jpg)
เลือกรายการ Quick Registration and Inventory เพื่อลงทะเบียนแบบ manual ทีละเครื่อง
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog23.jpg)
แล้วกลับมาอีกรอบ คราวนี้ก็เลือก Boot from hard disk เมื่อเข้า Windows ได้แล้วลองไปตรวจสอบ IP
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog07-dhcp-9.jpg)
หน้าต่าง login ก็ใส่ค่า default username คือ fog และ password คือ password
ต่อไปมาดูในหน้าเว็บ ของ fog จะเห็นว่า มีเครื่องที่เรากด ลงทะเบียน เข้ามาแล้ว
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog24.jpg)
ต่อไป เราจะไปหน้าเว็บเพจ images เพื่อสร้างชื่อ image ว่า windows7 ก่อนที่จะ cloning ได้
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog25.jpg)
กดเลือก Create New Image
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog26.jpg)
ตั้งค่าเลือก Operating System เป็นชนิด Windows 7 – (5)
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog27.jpg)
และใช้ค่า default แล้วกด Add (วันหลังค่อยลองเปลี่ยนใช้แบบอื่น ๆ)
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog28.jpg)
เราต้องผูก image เข้ากับ host ให้คลิกเข้าไปที่ชื่อ host ในตัวอย่างคือ 080027888888
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog29.jpg)
ผูก host นี้กับ Image ชื่อ windows7 ที่เราสร้างไว้
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog30.jpg)
ส่วนที่เหลือ เป็นค่า default แล้วกด Update
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog31.jpg)
กลับมาที่หน้าเว็บเพจ Host จะเห็นว่ามี Assigned Image เข้ามาแล้ว ให้คลิก Capture
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog32.jpg)
หน้านี้จะเด้งขึ้นมา เป็นค่า default ทั้งหมด แล้วกด Task
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog33.jpg)
จะได้หน้าต่างบอกว่า กำหนด Task แล้ว
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog34.jpg)
ไปที่เมนู Tasks จะเห็นรายการว่า กำลังรอให้เรา cloning ต้นฉบับ
เราก็ไปเปิดเครื่อง Windows ต้นฉบับที่จะเก็บ
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog35.jpg)
มันก็จะขึ้นมาเรื่อย ๆ แบบนี้ จนได้หน้าต่างว่า กำลังใช้ Partclone ในการ cloning
![](https://sysadmin.psu.ac.th/wp-content/uploads/2019/09/fog36.jpg)
ก็รอจนเสร็จ
ขอให้สนุก