在Ubuntu 16.04.2 i386 Server 建置 PXE Server
安裝套件:
# apt-get install isc-dhcp-server apache2 tftpd-hpa inetutils-inetd lftp openbsd-inetd syslinux
編輯tftpd-hpa檔案:
# nano /etc/default/tftpd-hpa
修改成以下內容:
[…]
RUN_DAEMON=”yes”
OPTIONS=”-l -s /var/lib/tftpboot”
修改inetd.conf:
# nano /etc/inetd.conf
在最後新增以下一行:
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
NOTE: if you are using IPv6, you would need to use udp4 instead of udp.
# update-inetd –enable BOOT
# /etc/init.d/openbsd-inetd restart
重啟tftpd-hpa:
# systemctl restart tftpd-hpa
檢查tftpd-hpa service status:
# systemctl status tftpd-hpa
確認以下訊息:
Active: active (running)
Mount安裝系統用ISO檔:
# mount -o loop <OS>.iso /mnt/
Mount完後cd進mnt並copy檔案至/var/lib/tftpboot:
cd ..
# cd /mnt/
# cp -fr install/netboot/* /var/lib/tftpboot/
在/var/www/html/下建立資料夾用來放置從ISO複製出來的檔案:
# mkdir /var/www/html/<Your desired name for the file>
複製ISO檔案:
# cp -fr /mnt/* /var/www/html/<Your loaction>
編輯 /var/lib/tftpboot/pxelinux.cfg/default file
# nano /var/lib/tftpboot/pxelinux.cfg/default
新增以下內容[需參考系統架構對應路徑]:
[…]
label linux
kernel ubuntu-installer/amd64/linux
append ks=http://<YOUR PXE SREVER IP>/ks.cfg vga=normal initrd=ubuntu-installer/amd64/initrd.gz
ramdisk_size=16432 root=/dev/rd/0 rw —
NOTE: 32-bit architecture can use the following code
[…]
label linux
kernel ubuntu-installer/i386/linux
append ks=http://<YOUR PXE SERVER IP>/ks.cfg vga=normal initrd=ubuntu-installer/i386/initrd.gz
ramdisk_size=16432 root=/dev/rd/0 rw —
配置 DHCP Server 網路介面
# nano /etc/default/isc-dhcp-server
INTERFACES=”Your Interface Name”
配置 DHCP Server 設定
# nano /etc/dhcp/dhcpd.conf
[…]
authoritative;
[…]
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.30;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
Add the following lines at the end
allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server <YOUR PXE SERVER IP>;
filename “pxelinux.0”;
存檔離開並重啟DHCP服務及確認服務啟用狀態
# systemctl restart isc-dhcp-server
# systemctl status isc-dhcp-server