CentOS 7.x PXE 서버 설정

LINUX 2017. 9. 13. 16:20

CentOS 7.x PXE 서버 설정


리눅스 PXE Boot 서버 설정입니다.

설치 CD없이 PXE 로 설치하는 방법입니다. DNSMASQ 대신에 DHCP + TFTP-SERVER 로 대체하여도 됩니다.


1. 패키지 설치

yum install dnsmasq vsftpd syslinux

tftp-server 는 dnsmasq 로 할 때는 설치하지 않아도 됩니다.

대신에 /var/lib/tftpboot 폴더는 만들어 주거나 다른 폴더로 대체하여야 합니다.


2. dnsmasq 설정

vi /etc/dnsmasq.d/dhcp.conf

dhcp-range=192.168.1.3,proxy
enable-tftp
tftp-root=/var/lib/tftpboot
pxe-service=x86PC, "PXE-Linux on 192.168.1.3", "pxelinux.0", 192.168.1.3

굵은 글씨 부분을 자신의 환경에 맞게 수정하면 됩니다.

좀 더 복잡한 설정 :


3. CentOS 7.x ISO 다운로드 및 복사

wget http://ftp.daumkakao.com/centos/7.3.1611/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso
mkdir /mnt/centos7
mount -o loop CentOS-7-x86_64-Minimal-1611.iso /mnt/centos7
cp -av /mnt/centos7/* /var/ftp/pub/


4. PXE Boot 디렉토리 작업

mkdir /var/lib/tftpboot/pxelinux.cfg
mkdir /var/lib/tftpboot/centos7
cp -rv /usr/share/syslinux/* /var/lib/tftpboot/
cp -v /mnt/centos7/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7/
cp -v /mnt/centos7/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/


5. PXE Boot 메뉴 작업

vi /var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 100
ontimeout 1
menu title ### PXE Boot Menu ###
label 1
menu label ^1) Install CentOS 7 x64 (ftp://192.168.1.26/pub)
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://192.168.1.3/pub devfs=nomount
label 2
menu label ^2) Install CentOS 7 x64 (http://mirror.centos.org)
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://mirror.centos.org/centos/7/os/x86_64/ devfs=nomount


6. 데몬 시작

systemctl enable dnsmasq
systemctl enable vsftpd
systemctl start dnsmasq
systemctl start vsftpd


7. 방화벽 설정

firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --permanent --zone=public --add-service=dns
firewall-cmd --permanent --zone=public --add-service=dhcp
firewall-cmd --permanent --zone=public --add-port=69/udp
firewall-cmd --permanent --zone=public --add-port=4011/udp
firewall-cmd --reload


이제 설정이 모두 완료되었습니다.

reboot 으로 재부팅 한번 하고 난뒤에 테스트 하면 됩니다.


PXE 설치 동영상 보기 https://youtu.be/QkMbobbBrEU



dnsmasq 대신에 dhcp + tftp-server 로 하는 방법입니다.

위의 1번 과정에서 yum install tftp-server dhcp vsftpd syslinux


2번 과정을 아래로 대체합니다.

vi /etc/xinet.d/tftp

service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

disable = yes 를 disable = no 로 변경 후 저장

systemctl enable tftp

systemctl start tftp


dhcp 설정

vi /etc/dhcp/dhcpd.conf

subnet 192.168.1.0 netmask 255.255.255.0 {
    range dynamic-bootp 192.168.1.100 192.168.1.200;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option broadcast-address 192.168.1.255;
    option routers 192.168.1.1;
}
filename "pxelinux.0";


systemctl enable dhcpd

systemctl start dhcpd

그리고 방화벽 설정에서

--add-service=dns 와 --add-port=4011/udp 는 필요가 없습니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,