Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- SAA-C03
- vmware
- NAT
- DNS
- IAM
- Ebs
- aws cloud school
- ALB
- ELB
- load balancer
- tftp
- FTP
- EC2 인스턴스
- AWS 자격증
- aws cloud
- aws saa
- Kubernetes
- AWS
- vyos
- KUBECTL
- aws cloud shcool 8
- aws iam
- docker
- GNS3
- 네트워크
- EC2
- linux
- Troubleshooting
- Firewall
- aws SAA-c03
Archives
- Today
- Total
나의 공부기록
[VMware] 08. FTP & TFTP & PxE 본문
FTP(File Transfer Protocol)
- 파일 전송 프로토콜
- TCP 사용
- 신뢰성 있는 통신을 함
- Port : 21(세션 수립), 20(데이터 전송)
FTP 실습
FTP 서버
1. 초기 설정
- 방화벽 해제
[root@ftp ~]# systemctl stop firewalld
[root@ftp ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
- SELINUX 해제
[root@ftp ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 레포지토리 해제
[root@ftp ~]# cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
> [base]
> name=CentOS-$releasever - Base
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #released updates
> [updates]
> name=CentOS-$releasever - Updates
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-$releasever - Contrib
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
- 재부팅
[root@ftp ~]# init 6
2. vsftpd 패키지 설치
- /var/ftp : ftp 사용자 접속 시, 기본 루트 디렉토리
[root@ftp ~]# yum install -y vsftpd
# 활성화
[root@ftp ~]# systemctl restart vsftpd
[root@ftp ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
3. /var/ftp에 파일 생성
- client 접속 시, 보여야 하는 파일
[root@ftp ~]# ls /var/ftp
pub
# 클라이언트가 접속 시, 보여야 하는 파일
[root@ftp ~]# touch /var/ftp/ftp-test.txt
[root@ftp ~]# echo 'ftp-test file' > /var/ftp/ftp-test.txt
[root@ftp ~]# cat /var/ftp/ftp-test.txt
ftp-test file
Client 설정
1. 초기 설정
- 방화벽 해제
[root@ftp ~]# systemctl stop firewalld
[root@ftp ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
- SELINUX 해제
[root@ftp ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 레포지토리 해제
[root@ftp ~]# cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
> [base]
> name=CentOS-$releasever - Base
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #released updates
> [updates]
> name=CentOS-$releasever - Updates
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-$releasever - Contrib
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
- 재부팅
[root@ftp ~]# init 6
2. ftpd 패키지 설치
[root@client ~]# yum install -y ftp
3. ftp 접속
- anonymous 사용자로 접속
# anonymous로 접속하면 /var/ftp 하위 경로들이 나옴
[root@client ~]# ftp 211.183.3.21
Connected to 211.183.3.21 (211.183.3.21).
220 (vsFTPd 3.0.2)
# 로그인 성공
Name (211.183.3.21:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
# ftp 서버에서 만든 파일도 확인 가능
ftp> dir
227 Entering Passive Mode (211,183,3,21,177,57).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 14 Jan 22 02:21 ftp-test.txt
drwxr-xr-x 2 0 0 6 Jun 09 2021 pub
226 Directory send OK.
# ftp 서버의 파일 가져오기
ftp> get ftp-test.txt
local: ftp-test.txt remote: ftp-test.txt
227 Entering Passive Mode (211,183,3,21,90,47).
150 Opening BINARY mode data connection for ftp-test.txt (14 bytes).
226 Transfer complete.
14 bytes received in 8e-05 secs (175.00 Kbytes/sec)
# 가져온 파일 client 확인 가능
[root@client ~]# ls
anaconda-ks.cfg ftp-test.txt
# ftp-test.txt 파일 내용 확인 가능
[root@client ~]# cat ftp-test.txt
ftp-test file
- user1 사용자로 접속
[root@client ~]# ftp 211.183.3.21
Connected to 211.183.3.21 (211.183.3.21).
220 (vsFTPd 3.0.2)
Name (211.183.3.21:root): user1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
# ftp 서버의 다른 경로로 접근했기 때문에,
# ftp 서버에서 생성한 파일 확인 불가능
ftp> dir
227 Entering Passive Mode (211,183,3,21,128,89).
150 Here comes the directory listing.
226 Directory send OK.
# user1의 경로로 ftp 접근
ftp> pwd
257 "/home/user1"
[ ftp server ]
# /home/user1에 파일 생성
[root@ftp ~]# echo 'user1-home file' > /home/user1/test.txt
# client에서 확인 가능
ftp> dir
227 Entering Passive Mode (211,183,3,21,219,89).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 16 Jan 22 02:39 test.txt
226 Directory send OK.
# user1의 test.txt 파일 가져오기
ftp> get test.txt
local: test.txt remote: test.txt
227 Entering Passive Mode (211,183,3,21,62,242).
150 Opening BINARY mode data connection for test.txt (16 bytes).
226 Transfer complete.
16 bytes received in 0.000162 secs (98.77 Kbytes/sec)
ftp> quit
221 Goodbye
# client 서버에서 가져온 파일 확인 가능
[root@client ~]# ls
anaconda-ks.cfg ftp-test.txt test.txt
[root@client ~]# cat test.txt
user1-home file
💡user에 대한 내용 확인 - Linux 전반에 대한 내용
- 계정 정보 확인
- 사용 UID & 사용자 home dir & 사용하는 shell 정보 확인 가능
[root@ftp ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
user1:x:1000:1000:user1:/home/user1:/bin/bash
- user1 : 사용자
- x : 암호
- 1000 : uid
- 1000 : gid
- /home/user1 : 사용자 홈 디렉토리
- /bin/bash : 사용중인 shell
TFTP(Trivail FTP)
- Trivail : 사소한
- UDP로, 간단한 파일을 신뢰성 없이 일방적으로 전송할 때, 사용
- Port : 69
TFTP 실습
TFTP Server
1. 초기 설정
- 방화벽 해제
[root@ftp ~]# systemctl stop firewalld
[root@ftp ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
- SELINUX 해제
[root@ftp ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 레포지토리 해제
[root@ftp ~]# cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
> [base]
> name=CentOS-$releasever - Base
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #released updates
> [updates]
> name=CentOS-$releasever - Updates
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-$releasever - Contrib
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
- 재부팅
[root@ftp ~]# init 6
2. tftp-server 패키지 다운로드
[root@ftp ~]# yum install -y tftp-server
[root@ftp ~]# systemctl restart tftp
[root@ftp ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
3. tftp 설정 파일 수정
- /etc/xinetd.d/tftp : tftp 설정 파일
[root@ftp ~]# vi /etc/xinetd.d/tftp
# 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 /var/lib/tftpboot
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
➡️ server_args = -s /var/lib/tftpboot : tftp root 디렉토리
➡️ disable = no : tftp 활성화 수정(선택)
# 변경사항 반영
[root@ftp ~]# systemctl restart tftp
[root@ftp ~]# systemctl enable tftp
4. tftp 루트 디렉토리에 테스트 파일 생성
[root@ftp ~]# echo 'tftp test file' > /var/lib/tftpboot/test.txt
TFTP Client
1. 초기 설정
- 방화벽 해제
[root@ftp ~]# systemctl stop firewalld
[root@ftp ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
- SELINUX 해제
[root@ftp ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 레포지토리 해제
[root@ftp ~]# cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
> [base]
> name=CentOS-$releasever - Base
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #released updates
> [updates]
> name=CentOS-$releasever - Updates
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-$releasever - Contrib
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
- 재부팅
[root@ftp ~]# init 6
2. tftp 패키지 설치
[root@client ~]# yum install -y tftp
3. tftp 서버 접속
[root@client ~]# tftp 211.183.3.21
# tftp 서버의 /var/lib/tftpboot 경로의 파일을 가져옴
tftp> get test.txt
4. 가져온 파일 내용 확인(필수)
- 신뢰성이 없기 때문에, 파일 내용 확인은 필수🌟
- server의 방화벽을 활성화하면, 방화벽 때문에 파일 내용을 못 가져옴
[root@client ~]# ls
anaconda-ks.cfg ftp-test.txt test.txt
[root@client ~]# cat test.txt
tftp test file
- server의 방화벽 활성화
- 방화벽 때문에, client에서 파일 내용을 못 가져옴
- get 명령어는 해당 파일을 생성한 후, 내용을 server로부터 받아오는데, 방화벽 때문에 못 받아옴
# 방화벽때문에, 파일의 내용을 못 받아옴(=신뢰성 X)
# 파일을 생성 -> 내용을 받아오는데, 방화벽 때문에 못 받아옴
[server]
# tftp 서버의 방화벽 활성화
[root@ftp ~]# systemctl restart firewalld
[client]
[root@client ~]# rm -rf test.txt
[root@client ~]# tftp 211.183.3.21
tftp> get test.txt
[root@client ~]# ls
anaconda-ks.cfg nothing.txt
ftp-test.txt test.txt
[root@client ~]# cat test.txt
➡️ 파일을 가져오기는 했지만, 내용이 없음
PxE(Preboot eXecution Environment) 서버
- 다수의 Bare-metal(OS가 설치되지 않은) 서버에 OS를 설치하는 메커니즘(기술)
- Bare-metal
- OS가 설치되지 않은 서버 의미
- Bare-metal 서버와 PxE 서버가 다른 네트워크 상에 있어도 Discover 메세지가 전달이 되면 상관없음
PxE 서버 처리 과정
- DHCP Server
- Bare-metal 서버는 운영체제가 없으면 부팅할 때, 네트워크를 통해 IP 할당을 요청하는 Discover 메세지를 보냄
- DHCP Server가 IP를 부여
- TFTP Server
- 부팅에 필요한 파일 전송
- 부팅 환경 & RAM ➡️ 디스크처럼 만드는 파일을 전송 받음
- ↔️ 가상 메모리(디스크 ➡️ RAM)
- FTP ( or http) Server
- 운영체제 설치 파일 전송
💡왜 굳이 tftp와 ftp로 나눠서 파일을 전송하는가?
- TFTP와 FTP의 차이점을 먼저 알아야 한다. FTP는 부팅을 위한 환경이 갖춰지지 않으면 20 포트로 세션을 매칭할 수 없어 사용이 어렵고, TFTP는 부팅에 필요한 환경이 갖춰지지 않아도 통신이 가능한 간단하고 일방적인 프로토콜로, 초기 부팅 단계에서 사용이 가능하다.
- 그렇기 때문에 TFTP와 FTP로 나누어서 파일을 전송받는다.
💡tftp를 통해 운영체제 설치 파일을 전송받으면 안 되는가?
- TFTP는 일방적이고 신뢰성이 없는 통신이기 때문에, TFTP로 통신을 하게 되면 운영체제 설치 파일이 전송이 잘 되지 않을 수 있고(신뢰성 문제), 용량이 큰 파일(운영체제)을 전송하기 적합하지 않기 때문에, FTP 통신이 가능한 환경이 만들어지면 FTP를 사용하는 것이다.
+ FTP가 TFTP보다 전송 속도가 빠름
PxE Server 설정
1. 초기 설정
- 방화벽 해제
[root@pxe ~]# systemctl stop firewalld
[root@pxe ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
- SELINUX 해제
[root@pxe ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 레포지토리 해제
[root@pxe ~]# cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
> [base]
> name=CentOS-$releasever - Base
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #released updates
> [updates]
> name=CentOS-$releasever - Updates
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-$releasever - Contrib
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
> baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
- 재부팅
[root@pxe ~]# init 6
2. dhcp & tftp-server & vsftpd 패키지 설치
- pxe 서버 구현에 필요한 3가지 패키지 설치
[root@pxe ~]# yum install -y dhcp tftp-server vsftpd
3. DHCP Server 구성
1) Pool 설정
- 이전과 달리 range dynamic-bootp가 추가됨
root@pxe ~]# vi /etc/dhcp/dhcpd.conf
[dhcp 설정]
subnet 211.183.3.0 netmask 255.255.255.0
{
option routers 211.183.3.2;
#GW
option subnet-mask 255.255.255.0;
#SM
range dynamic-bootp 211.183.3.220 211.183.3.240;
# 고전적인 방식(IP를 받을 범위 설정)
option domain-name-servers 8.8.8.8;
#DNS
allow booting;
#부팅 허용.
next-server 211.183.3.44;
#PxE 서버의 주소
filename "pxelinux.0";
# next-server에 가서 받아올 파일.
}
✅Pool 설정 양식
더보기
subnet 211.183.3.0 netmask 255.255.255.0
{
option routers 211.183.3.2;
#GW
option subnet-mask 255.255.255.0;
#SM
range dynamic-bootp 211.183.3.240 211.183.3.250;
# 고전적인 방식
option domain-name-servers 8.8.8.8;
#DNS
allow booting;
#부팅 허용.
next-server 211.183.3.67;
# PxE(tftp) 서버의 주소
# IP를 부여 받은 후, tftp 서버에 가서 부팅환경 세팅 파일을 받기 위한 서버 IP
filename "pxelinux.0";
# next-server에 가서 받아올 파일.
# 부팅에 필요한 설정 파일
}
2) dhcpd 재시작
[root@pxe ~]# systemctl restart dhcpd
[root@pxe ~]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service
3) client의 IP 할당 확인
4. TFTP Server 구성
- DHCP를 통해 IP를 부여받은 pxe client가 TFTP를 통해 부팅 및 파일 전송에 필요한 환경이 구성되도록 해당 파일을 복사
1) TFTP Server의 iso 파일 다시 연결
- 부팅이 끝나면 iso 파일이 존재하는 장치의 연결이 해제 ➡️ 파일을 다시 연결해줘야 함
2) iso 파일 위치 mount
- /dev/cdrom : 운영체제의 ios 파일의 위치
- 해당 장치의 iso 파일에 접근하기 위해 /media라는 mount point로 마운팅
- /dev/cdrom = 장치 ➡️ 직접적인 접근 불가능
- USB나 외장하드라고 이해하면, mount 하는 것이 이해가 됨
[root@pxe ~]# mount /dev/cdrom /media
mount: /dev/sr0 is write-protected, mounting read-only
[root@pxe ~]# ls /media
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
3) 부팅 환경 세팅 파일 복사
- /var/lib/tftpboot :
- pxelinux.0
- pxe 부팅에 필요한 파일
- ios 파일이 없어서 다운받아야 함
- initrd.img
- 램 디스크 파일(RAM ➡️ Disk처럼 사용)
- 현재 사용할 준비가 되어있는 보조 기억장치(디스크)가 없어서, 해당 파일을 통해 RAM을 Disk처럼 사용할 예정
💡RAM ➡️ Disk / Disk ➡️ RAM
- 내가 헷갈린 부분은 물리적으로 Disk가 RAM보다 속도가 훨씬 느린데, 어떻게 RAM처럼 사용하는가(속도 측면에서)?
✅ Disk를 RAM의 용도로 사용하는 것이며, 속도가 느린 것은 감수하고 사용한다는 의미(용도)
가상메모리(Disk ➡️ RAM) = SWAP의 형태로 존재
- vmlinuz
- 압축된 리눅스 커널 파일
[root@pxe ~]# cp /media/images/pxeboot/vmlinuz /var/lib/tftpboot
[root@pxe ~]# cp /media/images/pxeboot/initrd.img /var/lib/tftpboot
[root@pxe ~]# yum install -y syslinux
[root@pxe ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
[root@pxe ~]# ls /var/lib/tftpboot
initrd.img pxelinux.0 vmlinuz
[root@pxe ~]# ls -al /var/lib/tftpboot
total 60484
drwxr-xr-x. 2 root root 57 Jan 22 01:52 .
drwxr-xr-x. 26 root root 4096 Jan 22 01:39 ..
-rw-r--r-- 1 root root 55129656 Jan 22 01:52 initrd.img
-rw-r--r-- 1 root root 26759 Jan 22 01:52 pxelinux.0
-rwxr-xr-x 1 root root 6769256 Jan 22 01:51 vmlinuz
[root@pxe ~]# systemctl restart tftp
[root@pxe ~]# systemctl enable tftpㅣ
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
4) 절차 설정 파일
- Client에게 다음 절차인 실행 파일을 받아오라고 알려주는 파일 설정(/pxelinux.cfg/default)
- LABEL 설정으로 멀티부팅 가능
# 파일 같아 보이지만 디렉토리
[root@pxe ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@pxe ~]# cd /var/lib/tftpboot/pxelinux.cfg
[root@pxe pxelinux.cfg]# pwd
/var/lib/tftpboot/pxelinux.cfg
# default라는 파일을 통해 어떤 방식으로 부팅을 할지 결정
# 어떤 방식?
[root@pxe pxelinux.cfg]# vi default
[추가 내용]
DEFAULT centos7_pxe
LABEL centos7_pxe # 부팅방식
kernel vmlinuz
APPEND initrd=initrd.img repo=ftp://211.183.3.44/pub
# initrd : 램디스크
# repo : 운영체제 저장소
# - 운영체제 설치파일이 있는 저장소
# - ftp 프로토콜 설정
5) tftp 재부팅
[root@pxe ~]# systemctl restart tftp
[root@pxe ~]# systemctl enable tftpㅣ
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
5. FTP Server 구성
- OS 설치에 필요한 파일들을 FTP를 통해 보내줄 예정 - HTTP로 보내줄 수 있음
1) /media에 있는 파일을 /var/ftp/pub에 복사
[root@pxe ~]# cp -r /media/* /var/ftp/pub
-r : 하위 파일, 폴더 전부
[root@pxe ~]# ls /var/ftp/pub
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
'CS > Linux' 카테고리의 다른 글
[VMware] 09-2. PxE 서버(DHCP, TFTP, FTP-HTTP) 분리 실습 (0) | 2025.01.23 |
---|---|
[VMware]09-1. PxE Server - KickStart 파일 만드는법 (0) | 2025.01.23 |
[VMware] 07. NFS(Network File System) (0) | 2025.01.22 |
[VMware] 06. DNS(Domain Name System) (0) | 2025.01.21 |
[VMware] 04. 정적 웹 서버 - template 적용 & 실습 (0) | 2025.01.10 |