실습2_18일차)
우리 회사는 지금 rapa.com 도메인을 갖고 있다.
회사 내부 서버실에는 www.rapa.com 으로 접속 가능한 웹서버,
nfs.rapa.com 으로 접속 가능한 nfs 서버, 이를 위한 dns.rapa.com 도 갖고 있다.
1. client가 /remotestg 경로를 통해 nfs 서버에 접근하여 /originstg의 파일에 접근 가능하도록 구성하시오.
2. nfs-server의 /web 이라는 경로에 있는 index.html을 웹서버에 배포하고 싶다.
www.rapa.com으로 접속했을때 간단한 index.html 파일이 뜨도록 구성하세요.
index.html 파일의 내용은 ‘aws8 파이팅!’ 로 하세요! nfs-server의 /web이라는 경로에 있는 파일인 index.html 파일은 언제든지 변경가능하고, 실시간으로 변경사항이 웹서버에 적용되어야 한다.
마운트할 때, 다 영문주소로 접근하셔야 합니다.
ex) [root@web ~]# mount -t nfs nfs.rapa.com:/originstg /remotestg
우리 회사는 지금 rapa.com 도메인을 갖고 있다.
→ dns구성할때 rapa.com 영역을 만들면 되겠네
회사 내부 서버실에는 www.rapa.com 으로 접속 가능한 웹서버와 nfs.rapa.com 으로 접속 가능한 nfs 서버, 이를 위한 dns.rapa.com 도 갖고 있다.
→ 내부? 어딘가 내부와 외부의 경계를 만들어줘야 되겠네.
→ 서버 3개를 만들면 되겠네.
→ 영문주소로 접근해야하니까 DNS서버를 구성해야겠다.
1. client가 /remotestg 경로를 통해 nfs 서버에 접근하여 /originstg의 파일에 접근 가능하도록 구성하시오.
→ client에서 마운트하면 되겠네
2. nfs-server의 /web 이라는 경로에 있는 index.html을 웹서버에 배포하고 싶다. www.rapa.com으로 접속했을때 간단한 index.html 파일이 뜨도록 구성하세요. index.html 파일의 내용은 ‘aws8 파이팅!’ 로 하세요! nfs-server의 /web이라는 경로에 있는 파일인 index.html 파일은 언제든지 변경가능하고, 실시간으로 변경사항이 웹서버에 적용되어야 한다.
마운트를 하실때 다 영문주소로 접근 하셔야 합니다.
→ 웹서버는 웹루트디렉토리를 갖고있고,
실시간으로 변경사항이 웹서버에 적용되어야 한다.
→ 웹루트디렉토리를 nfs서버의 /web이라는 경로에 마운트를 하면 되겠다.
라우터 설정
int f0/0
ip add 10.10.1.150 255.255.255.0
no sh
int f0/1
ip add 211.183.3.250 255.255.255.0
no sh
- NAT 설정
access-list 1 per 10.10.1.0 0.0.0.255
int f0/0
ip nat inside
int f0/1
ip nat outside
ip nat inside source list 1 int f0/1 over
- 디폴트 루트 설정
ip route 0.0.0.0 0.0.0.0 211.183.3.2
NFS server 구성
- 초기설정, DNS지정, 외부통신 확인
[root@vm ~]# systemctl stop firewalld
[root@vm ~]# systemctl disable firewalld
# 방화벽 off
[root@vm ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
# 셀리눅스 off
[root@vm ~]# init 6
# 초기화
- 패키지 설치
[root@vm ~]# yum install nfs-utils
- 디렉토리 생성 및 nfs 설정
[root@vm ~]# mkdir /originstg /web
# /originstg 와 /web 이라는 디렉토리를 nfs로 구성하고 싶음
- 디렉토리에 대한 권한 부여
[root@vm ~]# chmod -R 777 /originstg
[root@vm ~]# chmod -R 777 /web
[root@vm ~]# vi /etc/exports
[root@vm ~]# exportfs -r
[root@vm ~]# systemctl restart nfs-server
[root@vm ~]# systemctl enable nfs-server
# 재부팅후, 방화벽, 셀리눅스 잘 꺼졌는지 확인하고, nfs-server의 동작 및 showmount -e까지 확인한다.
Client server 구성
- 패키지 설치
[root@client ~]# yum install -y bind-utils nfs-utils
DNS server 구성
- 패키지 설치
[root@dns ~]# yum install -y bind bind-utils
- /etc/named.conf 수정을 통해 기능적인(수신포트, 허용할 대상) 설정
[root@dns ~]# vi /etc/named.conf
- 영역 생성
[root@dns ~]# vi /etc/named.rfc1912.zones
# 아래 내용 추가
- 존(zone) 파일 생성
[root@dns ~]# vi /var/named/rapa.com.db
# 아래 내용 추가
$TTL 3H
@ SOA @ root (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
IN A 10.10.1.80
dns IN A 10.10.1.53
www IN A 10.10.1.80
nfs IN A 10.10.1.111
# 질의할 DNS서버가 10.10.1.53으로 됐는지 확인
# client에서 영문주소로 nfs 마운트 시도
- 질의할 서버를 변경
[root@client ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
[root@client ~]# systemctl restart network
- 마운팅
[root@client ~]# mount -t nfs nfs.rapa.com:/originstg /remotestg
# 마운트포인트로 접근했을때 아까 생성한 파일이 보이는지 확인
웹서버 구성
[root@web ~]# yum install -y httpd nfs-utils bind-utils
# 필요한 기능 = 영문주소로 nfs 마운트, 웹서비스
[root@web ~]# echo 'web-srv index file' > /var/www/html/index.html
# 웹루트디렉토리에 파일을 하나 생성 후
# 웹접속
- 질의할 서버를 변경
[root@web ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
[root@web ~]# systemctl restart network
- 마운팅
[root@web ~]# mount -t nfs nfs.rapa.com:/web /var/www/html
# 웹서버의 /var/www/html에 파일이 있는 상태에서 마운트를 걸기
# /var/www/html이 바라보는 대상이 웹서버의 스토리지에서 nfs.rapa.com:/web으로 변경됐다.
# 다시 마운트를 풀고 /var/www/html을 보면 기존에 index.html 파일이 존재하는걸 확인한다.
# 바라보는 대상이 변경이 될 수 있고, 변경이 됐다고 해서 기존의 내용이 사라지는건 아니다.
FTP(File Transfer Protocol)
- 파일 전송 프로토콜
- TCP, 21 (세션수립) , 20(데이터전송)
실습1)
VM 생성
hostname : ftp
IP : 211.183.3.21
2 core , 2GB , 20GB
- 방화벽 off , 셀리눅스 off , 레포 추가 , 외부 ping 확인
[root@ftp ~]# systemctl disable --now firewalld
[root@ftp ~]# init 6
FTP 서버
- 패키지 설치
[root@ftp ~]# yum install -y vsftpd
- 동작
[root@ftp ~]# systemctl restart vsftpd
[root@ftp ~]# systemctl enable vsftpd
[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
# 클라이언트에서 ftp로 접속시 저 파일이 보이는지 확인해보기 위해 테스트 파일을 만들어 놓자
Client 서버
- IP: 211.183.3.100 /24
[root@client ~]# yum install -y ftp
# 클라이언트에서 ftp 클라이언트 역할을 할 명령어를 설치
# 이번에는 ftp서버의 사용자인 user1로 ftp로그인
# 어디론가 접속한것 같은데 어딘인지 잘 모르겠음
[root@ftp ~]# echo 'user1-home' > /home/user1/test.txt
# 다시 FTP서버로 돌아와서 user1의 홈디렉토리인 /home/user1 에 테스트 파일 만들기
FileZilla
TFTP(Trivial FTP)
- UDP, 69번 포트 사용
- 간단한 파일을 신뢰성 없이, 일방적으로 전송할때
[root@ftp ~]# yum install tftp-server
[root@ftp ~]# systemctl restart tftp
[root@ftp ~]# systemctl enable tftp
- tftp 설정파일
[root@ftp ~]# vi /etc/xinetd.d/tftp
[root@ftp ~]# systemctl restart tftp
- tftp 루트디렉토리에 테스트 파일 생성
[root@ftp ~]# echo 'tftp test file' > /var/lib/tftpboot/ttest.txt
- 클라이언트에 패키지 설치
[root@client ~]# yum install -y tftp
- 클라이언트에서 명령어 설치 후 접속
[root@client ~]# tftp 211.183.3.21
# 만약에 의도한대로 됐다면, 현재 있는곳이 tftp서버의 /var/lib/tftpboot 경로일 것이고, 그곳에 파일을 하나 만들어뒀다.
# 신뢰성이 없기 때문에 꼭 파일 내용까지 확인
# tftp 서버의 방화벽을 활성화하고, client의 ttest.txt를 삭제한 후, 다시 get을 해보자.
# 방화벽때문에 파일의 내용을 못받아옴
실습2)
남은시간동안 VM을 하나 생성해서 ftp, tftp 서버를 구축해보세요.
VM 이름 : lunch
IP : 211.183.3.69
스펙 : 2 core , 2GB , 20GB
lunch
- 초기설정
[root@lunch ~]# systemctl stop firewalld
[root@lunch ~]# systemctl disable firewalld
[root@lunch ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
# 레포 파일 내용 복붙
FTP
[root@lunch ~]# yum install -y vsftpd
[root@lunch ~]# systemctl restart vsftpd
[root@lunch ~]# systemctl enable vsftpd
[root@lunch ~]# touch /var/ftp/hi_ftp.txt
[root@lunch ~]# echo 'hi ftp' > /var/ftp/hi_ftp.txt
[root@lunch ~]# cat /var/ftp/hi_ftp.txt
hi ftp
TFTP
[root@lunch ~]# yum install tftp-server
[root@lunch ~]# systemctl restart tftp
[root@lunch ~]# systemctl enable tftp
[root@lunch ~]# vi /etc/xinetd.d/tftp
# 아래 부분 수정
[root@lunch ~]# systemctl restart tftp
[root@lunch ~]# cat /var/lib/tftpboot/hi_tftp.txt
hi tftp
Client
FTP
[root@clientsrv ~]# yum install -y ftp
[root@clientsrv ~]# ftp 211.183.3.69
Name (211.183.3.69:root): anonymous
Password:
# 그냥 Enter 키 입력
ftp> get hi_ftp.txt
ftp> quit
TFTP
[root@clientsrv ~]# yum install -y tftp
[root@clientsrv ~]# ftp 211.183.3.69
Connected to 211.183.3.69 (211.183.3.69).
220 (vsFTPd 3.0.2)
Name (211.183.3.69:root): user1
331 Please specify the password.
Password:
# user1 입력
tftp> get hi_tftp.txt
tftp> quit
PxE (Preboot eXecution Environment) 서버
- 다수의 Bare-metal(OS가 설치되지 않은) 서버에 OS를 설치하는 매커니즘(기술)
# 운영체제가 설치되지않은 Bare-metal 서버들은 혹시라도 누군가 자신에게 아이피를 부여하지 않을까하는 마음에 계속 dhcp discover 메세지를 보낸다.
PxE 서버 구축
IP: 211.183.3.44
GW: 211.183.3.2
DNS: 8.8.8.8
- pxe 서버 구현에 필요한 3가지 패키지 설치
[root@pxe ~]# yum install -y dhcp tftp-server vsftpd
1. DHCP server 구성
[root@pxe ~]# vi /etc/dhcp/dhcpd.conf
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;
# 고전적인 방식
option domain-name-servers 8.8.8.8;
#DNS
allow booting;
#부팅 허용
next-server 211.183.3.44;
#PxE(tftp) 서버의 주소
filename "pxelinux.0";
# next-server에 가서 받아올 파일
}
[root@pxe ~]# systemctl restart dhcpd
[root@pxe ~]# systemctl enable dhcpd
2. tftp 서버 구성
dhcp를 통해 IP를 부여받은 pxe client가 tftp 서버를 통해 부팅 및 파일 전송에 필요한 환경이 구성되도록 해당 파일들을 복사해오자
[root@pxe ~]# ls /dev/cdrom
/dev/cdrom
# iso 파일 위치, 경로처럼 보이지만 폴더가 아닌 장치!
[root@pxe ~]# mount /dev/cdrom /media
mount: /dev/sr0 is write-protected, mounting read-only
# 해당 장치의 iso 파일에 접근하기 위해 /media 라는 마운트포인트로 마운팅
- pxelinux.0
pxe 부팅에 필요한 파일, iso 파일에 없으므로 다운받아야 함
- initrd.img
램디스크 파일(램을 마치 디스크처럼 사용 가능)
현재 사용할 준비가 되어있는 보조기억장치(디스크)가 없으므로 이 파일을 통해 램을 디스크처럼 사용할 예정
- vmlinuz
압축된 리눅스 커널 파일
* linux에서 가상메모리로 swap 사용하는데, 쿠버네티스 환경에서는 끄고 진행해야 한다,
[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 ~]# systemctl restart tftp
[root@pxe ~]# systemctl enable tftp
3. ftp 서버 구성
# OS설치에 필요한 파일들을 ftp를 통해 보낼 예정
[root@pxe ~]# cp -r /media/* /var/ftp/pub
# iso 파일 내용 전부를 ftp 디렉토리에 복사
[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
# 해당 경로로 이동
[root@pxe pxelinux.cfg]# vi default
# default라는 파일을 통해 어떤 방식으로 부팅할지 결정
DEFAULT centos7_pxe
LABEL centos7_pxe
kernel vmlinuz
APPEND initrd=initrd.img repo=ftp://211.183.3.44/pub
# 위의 내용 추가
[root@pxe pxelinux.cfg]# systemctl restart vsftpd
[root@pxe pxelinux.cfg]# systemctl enable vsftpd
- 확인
실습)
여러분들이 서버를 새로 파서 한번 더 해보세요.
잘 되는지 확인까지 해보세요.
+ http로는 어떻게 할까?
IP: 211.183.3.44
GW: 211.183.3.2
DNS: 8.8.8.8
newPxE
- 초기설정 후 패키지 설치
[root@newPxE ~]# yum install -y dhcp tftp-server vsftpd
1. DHCP server 구성
[root@newPxE ~]# vi /etc/dhcp/dhcpd.conf
# 아래 내용 추가
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;
# 고전적인 방식
option domain-name-servers 8.8.8.8;
#DNS
allow booting;
#부팅 허용
next-server 211.183.3.44;
#PxE(tftp) 서버의 주소
filename "pxelinux.0";
# next-server에 가서 받아올 파일
}
[root@newPxE ~]# systemctl restart dhcpd
[root@newPxE ~]# systemctl enable dhcpd
- Settings에서 connected 후
[root@newPxE ~]# systemctl restart network
2. tftp server 구성
[root@newPxE ~]# ls /dev/cdrom
/dev/cdrom
[root@newPxE ~]# mount /dev/cdrom /media
[root@newPxE ~]# ls /media
[root@newPxE ~]# cp /media/images/pxeboot/vmlinuz /var/lib/tftpboot
[root@newPxE ~]# cp /media/images/pxeboot/initrd.img /var/lib/tftpboot
[root@newPxE ~]# yum install -y syslinux
[root@newPxE ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
[root@newPxE ~]# ls -al /var/lib/tftpboot
[root@newPxE ~]# systemctl restart tftp
[root@newPxE ~]# systemctl enable tftp
3. ftp 서버 구성
[root@newPxE ~]# cp -r /media/* /var/ftp/pub
[root@newPxE ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@newPxE ~]# cd /var/lib/tftpboot/pxelinux.cfg
[root@newPxE pxelinux.cfg]# vi default
# 아래내용 추가
DEFAULT centos7_pxe
LABEL centos7_pxe
kernel vmlinuz
APPEND initrd=initrd.img repo=ftp://211.183.3.44/pub
[root@newPxE pxelinux.cfg]# systemctl restart vsftpd
[root@newPxE pxelinux.cfg]# systemctl enable vsftpd
4. http 서버 구성
[root@newPxE ~]# yum install -y httpd
[root@newPxE ~]# cp -r /media/* /var/www/html
[root@newPxE ~]# mkdir /var/www/html/pxelinux.cfg
[root@newPxE ~]# cd /var/www/html/pxelinux.cfg
DEFAULT centos7_pxe
LABEL centos7_pxe
kernel vmlinuz
APPEND initrd=initrd.img repo=http://211.183.3.44/var/www/html
[root@newPxE ~]# systemctl restart httpd
[root@newPxE ~]# systemctl enable httpd
※ iso 파일 다운로드
https://linuxmint.com/edition.php?id=281
# 리눅스 민트 iso 파일
https://mirror.cherryservers.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso
# centos7 GUI 설치 가능한 iso 파일
'AWS Cloud School 8기 > 리눅스(Xshell 8)' 카테고리의 다른 글
22일차) 2025-01-27 (LVM 실습, 시험_dhcp, dns, http/tftp/ftp, nfs, pxe) ♨ (2) | 2025.01.27 |
---|---|
20일차) 2025-01-23 (centGUI, dhcp/tftp/ftp/http, 포트) (2) | 2025.01.23 |
10일차) 2025-01-09 (Xshell 8에서 웹 템플릿 설정) (1) | 2025.01.09 |
9일차) 2025-01-08 (웹서버) (0) | 2025.01.08 |
8일차) 2025-01-07 (Xshell 8, Vim, 명령어) (1) | 2025.01.07 |