Post List

2014/07/06

Network Booting OS 설치 #끝 - Mikrotik Router 설정


Network Booting 을 위한 CentOS Server 는 준비되었다.

1. TFTP 서버 : 파일을 전송하기 위한 서버
2. Syslinux : 부트로더
3. PXE 설정 : Preboot eXecution Environment
4. OS 설치 파일


마지막으로 필요한 것은 DHCP 서버에서 PXE 를 실행하기 위한 설정을 해 주는 것이다.

DHCP 서버는 CentOS 나 다른 OS 에서 설정할 수도 있지만 여기서는 Router (Mikrotik Router OS VM) 를 사용한다고 가정하므로 Router 에서 설정한다.


Winbox 를 실행시키고 / IP / DHCP Servers 로 들어간다.




현재 설정되어 있는 DHCP Server 를 더블 클릭한다.






Next Server : 부분에는 PXE 가 실행되고 있는 CentOS IP 를 입력하고
Boot File Name : 부분에는 부트로더 이름을 입력한다.


이제 또 다른 VM 을 하나 생성하고 Network Booting 이 가능한지 테스트 해 보자.

새로 생성하는 VM (혹인 Real Machine) 은 Mikrotik Router 와 같은 Network 을 사용하고 있어야 한다. (DHCP Server 가 인식 가능한 상태여야 한다.)




vSphere Host / 구성 / 네트워킹을 선택해서 확인해 보면
Mikrotik 과 New Virtual Machine 이 같은 vSwitch1 에 묶여 있음을 알 수 있다.



새 VM 의 전원을 넣으면...




위에서 설정했던 메뉴 화면이 나타나고 사용자의 선택을 기다린다.






Install CentOS ... 를 선택하니 뭔가 파일을 로딩하기 시작한다.





CentOS 설치 화면이 나타났다.


알아서 진행...








이제 필요한 파일들이 모두 로딩되고 GUI 환경의 설치 화면이 나타났다.

Next 를 눌러서 진행...


자세한 CentOS 설치 방법은 아래 post 참조..



vSphere 에 CentOS 6.5 설치




드.디.어.

Network Booting 을 이용한 CentOS 최종 설치 완료.

Congratulatin !!!









2014/07/03

Network Booting OS 설치 #2 - syslinux


부트로더인 syslinux 를 설치한다.
[root@localhost tftpboot]# rpm -qa syslinux
[root@localhost tftpboot]# yum install syslinux

... ...

================================================================================
 Package                 Arch         Version               Repository     Size
================================================================================
Installing:
 syslinux                x86_64       4.02-16.el6_5         updates       331 k
Installing for dependencies:
 syslinux-nonlinux       i686         4.02-16.el6_5         updates       513 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total download size: 844 k
Installed size: 2.0 M
Is this ok [y/N]: y

... ...

Running Transaction
  Installing : syslinux-4.02-16.el6_5.x86_64                                1/2 
  Installing : syslinux-nonlinux-4.02-16.el6_5.i686                         2/2 
  Verifying  : syslinux-nonlinux-4.02-16.el6_5.i686                         1/2 
  Verifying  : syslinux-4.02-16.el6_5.x86_64                                2/2 

Installed:
  syslinux.x86_64 0:4.02-16.el6_5                                               

Dependency Installed:
  syslinux-nonlinux.i686 0:4.02-16.el6_5                                        

Complete!
[root@localhost tftpboot]# 

설치 완료.




TFTP에 필요한 Directory 를 만들고 부트로더를 카피한다.


mkdir /tftpboot  # 이미 있으면 무시
mkdir /tftpboot/pxelinux.cfg

cp /usr/share/syslinux/pxelinux.0 /tftpboot/
cp /usr/share/syslinux/menu.c32 /tftpboot/
cp /usr/share/syslinux/memdisk /tftpboot/
cp /usr/share/syslinux/mboot.c32 /tftpboot/
cp /usr/share/syslinux/chain.c32 /tftpboot/



파일 확인



[root@localhost tftpboot]# ll /tftpboot
total 180
-rw-r--r--  1 root root 20448 Jul  3 16:00 chain.c32
-rw-r--r--  1 root root 35676 Jul  3 16:00 mboot.c32
-rw-r--r--  1 root root 24988 Jul  3 16:00 memdisk
-rw-r--r--  1 root root 61056 Jul  3 16:00 menu.c32
-rw-r--r--  1 root root 26595 Jul  3 16:00 pxelinux.0
drwxr-xr-x  2 root root  4096 Jul  3 15:55 pxelinux.cfg
-rw-r--r--. 1 root root     8 Jul  3 05:48 testme
[root@localhost tftpboot]# 



이제 OS 를 설치하기 위해 디렉토리를 만들고 파일을 복사한다.

CentOS ISO 파일이 /media/Centos_6.5_Final 에 mount 되어 있다고 가정한다.

[root@localhost CentOS_6.5_Final]# mkdir /tftpboot/centos6
[root@localhost CentOS_6.5_Final]# mkdir /tftpboot/centos6/i386
[root@localhost CentOS_6.5_Final]# cp /media/CentOS_6.5_Final/* -r /tftpboot/centos6/i386/
[root@localhost CentOS_6.5_Final]# 





PXE 환경설정 파일 생성
vi /etc/httpd/conf.d/pxeboot.conf

Alias /centos6/i386 /tftpboot/centos6/i386

<directory /tftpboot/centos6/i386>
 Options Indexes FollowSymLinks
 Order Deny,Allow
 Deny from all
 Allow from 127.0.0.1 192.168.88.0/24
</directory>




PXE Menu 파일 생성



vi /tftpboot/pxelinux.cfg/default


default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
menu title =========== PXE Boot Menu by Jay ===========

label 1
menu label ^1) Install CentOS 6.5 i386
kernel centos6/i386/images/pxeboot/vmlinuz
append initrd=centos6/i386/images/pxeboot/initrd.img method=http://192.168.88.245/centos6/i386 devfs=nomount

label 2
menu label ^2) Boot from local drive localboot


서버를 재시작 한다.

[root@localhost CentOS_6.5_Final]# /etc/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@localhost CentOS_6.5_Final]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@localhost CentOS_6.5_Final]# 


이제 tftp 를 포함해서 CentOS 쪽 설정은 끝났다.

남은 것은 Router 설정과 테스트 뿐이다.





Network Booting OS 설치 #1 - TFTP

Mikrotik RouterOS (x86) 과 CentOS 6.5 를 이용해서 Network Booting 을 구현해 보자.


TFTP (Trivial File Transfer Protocol) 는 파일을 전송하기 위한 프로토콜이다.
구조가 단순하고 구현이 쉽기 때문에 PXE 를 통한 Network Booting 등에서 많이 사용된다.




일단 TFTP 를 설치한다.


root 계정으로 로그인 한다.









tftp 설치 여부 확인



[root@localhost ~]# rpm -qa tftp tftp-server
[root@localhost ~]# 

당연히 없다. 설치하자..


[root@localhost ~]# rpm -qa tftp tftp-server
================================================================================
 Package            Arch          Version                     Repository   Size
================================================================================
Installing:
 tftp               x86_64        0.49-7.el6                  base         32 k
 tftp-server        x86_64        0.49-7.el6                  base         39 k
Installing for dependencies:
 xinetd             x86_64        2:2.3.14-39.el6_4           base        121 k

Transaction Summary
================================================================================
Install       3 Package(s)

Total download size: 192 k
Installed size: 362 k
Is this ok [y/N]: 


tftp 의 홈 디렉토리를 만들고 다운로드 테스트용으로 사용할 간단한 파일을 하나 작성한다.



[root@localhost ~]# rpm -qa tftp tftp-server
[root@localhost ~]#
[root@localhost ~]# mkdir /tftpboot
[root@localhost ~]# echo Test... > /tftpboot/testme
[root@localhost ~]# ll /tftpboot
total 4
-rw-r--r--. 1 root root 8 Jul  3 05:48 testme
[root@localhost ~]#




tftp 환경 설정


vi /etc/xinetd.d/tftp


server_args 와 disabled 부분을 수정한다.



# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

이제 서비스를 띄우고 테스트 해 보자


# default: off
# /etc/init.d/xinetd start
Starting xinetd:                                           [  OK  ]
[root@localhost ~]# tftp local-4 localhost
localhost: bad port number
tftp>
tftp> quit
[root@localhost ~]#


아직 작동이 안된다.

SELinux 설정을 확인해 본다.



[root@localhost ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted
[root@localhost ~]# 


SELinux 는 Security Enhanced Linux 로 Linux Kernel 의 보안을 획기적으로 높였다고 하는데
나는 아직 정확히 이해할 수 없어 일단은 disable 시키기로 한다.
(대부분의 사용자가 disable 시키고 사용하는 듯...)


[root@localhost ~]# sestatus
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


selinux 설정은 시스템을 리부팅해야 적용된다.


[root@localhost ~]# sestatus
reboot


시스템이 다시 부팅되면 selinux 설정을 다시 확인해 본다.

[root@localhost ~]# sestatus
[root@localhost ~]# sestatus
SELinux status:                 disabled



정상적으로 disable 되어 있다.

이제 다시 tftp 테스트를 해 보자.


[root@localhost ~]# sestatus
[root@localhost ~]# tftp -4 localhost
tftp> get testme
tftp>



아무런 오류 없이 tftp> 프롬프트가 나타났다.

실제로 파일을 받았는지 확인해 보자.





현재 디렉토리에 정상적으로 파일을 받아온 것을 확인할 수 있다.
이제 tftp 서버를 통해 파일을 주고 받는 게 가능하다.


localhost 가 아닌 다른 기기들간에 tftp 전송이 가능하려면 방화벽 설정을 확인해야 한다.

System / Administration / Firewall







Network Booting 을 위해서는 TFTP /  WWW (HTTP) 가 열려 있어야 한다.


이제 이렇게 구성된 TFTP 서버를 이용해서 Network Booting 을 구현해 보자.









Popular Posts