서브 도메인
<파일 수정>
cd /var/named
vi (zone 파일)
<파일 내용추가>
$TTL 0
@ IN SOA test.co.kr. admin.test.co.kr. (
20230821 ; Serial
1D ; Refresh
1H ; Retry
1W ; Expire
1W ; Minimum TTL
)
IN NS test.co.kr.
IN A 192.168.0.174
centser1 IN A 192.168.0.174 <= 서버1
centser2 IN A 192.168.0.173 <= 서버2
centcli1 IN A 192.168.0.181 <= 서버3
centcli2 IN A 192.168.0.184 <= 서버4
<DNS서버 주소 확인>
#Gerated by NetworkManager
nameserver 192.168.0.174
결과 (리눅스-리눅스)
각 서버로 서브 도메인을 통해 접속 가능
telnet centser1.test.co.kr <= 서버1
telnet centser2.test.co.kr <= 서버2
telnet centcli1.test.co.kr <= 서버3
telnet centcli2.test.co.kr <= 서버4
결과 (윈도우-리눅스)
윈도우에서도 동일하게 접근이 가능하다.
마스터-슬레이브 설정
- 마스터-슬레이브 관계를 통해 DNS 서버의 이중화를 구현
<슬레이브 서버 초기 설정>
1. bind 패키지 설치
2. /etc/named.conf <= any;로 수정
<서버1 (마스터)>
* /etc/named.rfc1912.zones 파일 수정
zone "test3.co.kr" IN {
type master;
file "test3.co.kr.zone";
allow-update { 192.168.0.184; }; <= 업데이트 허가 옵션 (슬레이브 ip 지정)
<서버4 (슬레이브)>
* /etc/named.rfc1912.zones 파일 수정
zone "test3.co.kr" IN {
type slave; <= slave 타입으로 설정
file "slaves/test3.co.kr.zone"; <= 받아올 zone 파일 저장 장소 설정
masters { 192.168.0.174; }; <= 마스터 서버로 매칭
<슬레이브 서버 DNS 설정>
/etc/resolv.conf 파일 내용을 마스터 서버 ip주소 지정
<슬레이브 서버 slaves 디렉토리 확인>
cd /var/named/slaves
결과
![](https://velog.velcdn.com/images/orangestar/post/20b880ad-5f47-48f1-b6f2-f8a5a68a5a85/image.png)
/var/named/slaves
디렉토리에 마스터 서버에서 받아온 zone 파일
(동기화를 통해 Zone 파일을 백업함)
(마스터 서버의 named.conf 파일에서 dnssec 설정을 통한 암호화 상태)
.zone 파일 각 항목 설명
20230821 ; Serial <= 마스터-슬레이브 간 고유 식별번호
1D ; Refresh <= 단위 기간마다 업데이트
1H ; Retry <= 업데이트를 못했을 시 해당 시간마다 업데이트 시도
1W ; Expire
1W ; Minimum TTL <= 유효기간
DNS 레코드
A(정방향) : 도메인 -> IP 주소(IPv4)
AAAA : 도메인 -> IP 주소(IPv6)
PTR(역방향) : IP 주소 -> 도메인
CNAME : 하위 도메인 지정
MX : 메일 서버 지정
TXT : 도메인에 대한 간단한 텍스트 입력
NS : 네임 서버 이름(지정)
SOA : 서버 권한의 시작(관리자 정보 저장)
SVR : 특정 서비스에 대한 포트 지정
웹 서버
초기 세팅
<rfc1912 파일 수정>
zone "test.co.kr" IN {
type master;
file "test.co.kr.zone";
allow-update { none; };
};
zone "kbs.co.kr" IN {
type master;
file "kbs.co.kr.zone";
allow-update { none; };
};
zone "mbc.co.kr" IN {
type master;
file "mbc.co.kr.zone";
allow-update { none; };
};
zone "sbs.co.kr" IN {
type master;
file "sbs.co.kr.zone";
allow-update { none ; };
};
<.zone 파일 설정>
각 도메인은 kbs, mbc, sbs로 설정 + 정방향 ip 주소는 dns 서버로 설정
<resolv.conf 파일 설정>
네임 서버는 dns 서버 ip 주소로 설정
설정 후 해당 도메인과 ip 주소가 매칭된 모습
프로그램
httpd <= 서버(Apache)
httpd <= 데몬이름
환경설정파일
/etc/httpd/conf/httpd.conf <= 주 환경 설정 파일
/etc/httpd/conf.d <= 보조 환경 설정 파일
웹 서버 설치
yum -y install httpd*
결과
웹 서버의 테스팅 페이지
(test.co.kr외에 kbs/mbc/sbs.co.kr로 접속하여도 같은 화면이 뜬다.)
index.html
cd /var/www/html <= 메인 호스트에 대한 초기화면 설정 파일의 위치
계정별 웹 사이트 설정
<환경설정 디렉토리 생성>
cd /home
chmod 775 kbs <= index.html을 불러올때 오류가 없도록 허가권 설정
cd kbs
mkdir public_html <= 환경설정 디렉터리 생성
cd public_html
vi index.html <= index.html 생성 및 내용 추가
<보조환경설정 파일 수정>
vi /etc/httpd/conf.d/userdir.conf
17번째 줄 #UserDir disabled <= 주석처리
24번째 줄 UserDir public_html <= 주석해제
<계정별 웹사이트 접속>
kbs.co.kr/~kbs
결과
kbs.co.kr/~kbs
로 해당 계정의 웹사이트 접속 가능
가상호스팅
/etc/httpd/conf.d/vhost.conf <= 파일 생성
<vhost.conf 파일 수정>
NameVirtualHost *:80
<VirtualHost *:80> <= 메인 호스트에 대한 설정
DocumentRoot /var/www/html <= index.html 파일의 위치
ServerName test.co.kr <= 연결할 도메인 매칭
</VirtualHost>
<VirtualHost *:80> <= kbs 계정에 대한 설정
DocumentRoot /home/kbs/public_html <= index.html 파일의 위치
ServerName kbs.co.kr <= 연결할 도메인 매칭
</VirtualHost>
결과
test, kbs, mbc, sbs 각 도메인별로 설정한 index.html이 보여짐
cf. 디렉터리명 설정법 (public_html -> www)
/home/kbs
의 public_html 디렉토리 명을 www로
/etc/httpd/conf.d/vhost.conf
의 kbs/public_html을 www로
/etc/httpd/conf.d/userdir.conf
의 Userdir public_html을 www로
/etc/httpd/conf.d/userdir.conf
의 <Directory "/home/*/public_html">을 www로
cf. 윈도우 DNS 캐시 삭제
<cmd 창에서>
ipconfig /flushdns <= 명령어 실행
메인
31 ServerRoot "/etc/httpd"
56 Include conf.modules.d/*.conf
66 User apache <= 유저 및 그룹 지정
67 Group apache
86 ServerAdmin root@localhost <= 웹서버 관리자 이메일
119 DocumentRoot "/var/www/html"
164 DirectoryIndex index.html
182 ErrorLog "logs/error_log"
189 LogLevel warn
217 CustomLog "logs/access_log" combined
316 AddDefaultCharset UTF-8
332 #ErrorDocument 500 "The server made a boo boo."
333 #ErrorDocument 404 /missing.html
334 #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
335 #ErrorDocument 402 http://www.example.com/subscription_info.html
353 IncludeOptional conf.d/*.conr
접근통제
루트서버 차단
vi /etc/httpd/conf/httpd.conf
156번째 줄 Require all denied <= default는 granted
* granted는 허용
* denied는 차단
- test.co.kr 사이트는 차단
그외 kbs, mbc, sbs 사이트는 접속 가능
일반계정 사이트 차단
vi /etc/httpd/conf.d/userdir.conf
34번째줄 #Require method GET POST OPTIONS <= 주석처리
Require all Denied <= 차단을 위해 해당 줄 추가
- test.co.kr 사이트는 접속 가능
그외 kbs, mbc, sbs 사이트는 차단
특정 사용자 차단
vi /etc/httpd/conf/httpd.conf
156번째 줄
<RequireAll>
Require all greanted
Require not ip 192.168.0.174 <= 특정 ip 차단
</RequireAll>
* ip 192.168.0.174 192.168.0.180 <= 다수의 특정 ip 차단
* ip 192.168.0.0/25 <= 특정 대역의 ip 차단
실제장비
<초기 설치 패키지>
yum - y install vsftpd*
yum - y install bind*
yum - y install httpd*
yum - y install php --skip-broken
yum - y install php* --skip-broken
yum - y install php-* --skip-broken
yum - y install mariadb*