DNS master & slave server 만들기

|


참고 : http://www.server-world.info/en/note?os=CentOS_6&p=dns&f=6

         + @



주 DNS 서버 및 보조 DNS 서버를 만들어봤다.

추가 및 변동된 부분만 추려 기재한다.




1. 주 DNS 서버 및 보조 DNS 서버에 관련 PKG 설치


# yum install bind*




2. 주 DNS 서버 측 설정


# vi /etc/named.conf

     11         listen-on port 53 { any; };

     12         listen-on-v6 port 53 { any; };

     17         allow-query     { any; };

     18         allow-transfer  { 보조DNS서버ip; };

     19         recursion no;


# vi /etc/named.rfc1912.zones

주 DNS 서버 도메인

     44 zone "dns.com" IN {

     45         type master;

파일 이름 변경 가능

     46         file "dns.z";

     47         allow-update { none; };

     48 };

     49

주 DNS 서버 ip의 네트워크 부분 ip

     50 zone "1.168.192.in-addr.arpa" IN {

     51         type master;

     52         file "dns.r";

     53         allow-update { none; };

     54 };

     55

보조 DNS 서버 도메인

     56 zone "sedns.com" IN {

     57         type master;

     58         file "sedns.z";

     59         allow-update { none; };

     60 };


# vi /var/named/dns.z

      1 $TTL 1D

      2 @       IN      SOA     ns.dns.com. root.dns.com.(

      3                         2014122301

      4                         3H

      5                         15M

      6                         1W

      7                         1D)

      8            IN      NS      ns.dns.com.

      9            IN      NS      ns.sedns.com.

     10

     11            IN      A       192.168.1.224

도메인의  host 부분

     12 ns        IN      A       192.168.1.224

     13 www     IN      A       192.168.1.224

     14 ftp        IN      CNAME   dns.com.


# vi /var/named/dns.r

      1 $TTL 1D

      2 @       IN      SOA     ns.dns.com. root.dns.com.(

      3                         2014122301

      4                         3H

      5                         15M

      6                         1W

      7                         1D)

      8           IN      NS      ns.dns.com.

      9           IN      NS      ns.sedns.com.

     10          IN      A       192.168.1.224

     11

주 DNS 서버 도메인

     12 224     IN      PTR     dns.com.

     13 224     IN      PTR     ns.dns.com.

     14 224     IN      PTR     www.dns.com.

보조 DNS 서버 도메인. 주 DNS 서버 도메인과 같은 네트워크 대역대라 파일 1개에 묶었음

     15 222     IN      PTR     sedns.com.

     16 222     IN      PTR     ns.sedns.com.

     17 222     IN      PTR     www.sedns.com.


# vi /var/named/sedns.z

      1 $TTL 1D

      2 @       IN      SOA     ns.dns.com. root.dns.com.(

      3                         2014122301

      4                         3H

      5                         15M

      6                         1W

      7                         1D)

      8            IN      NS      ns.dns.com.

      9            IN      NS      ns.sedns.com.

     10

     11            IN      A       192.168.1.222

     12 ns        IN      A       192.168.1.222

     13 www     IN      A       192.168.1.222


원할한 운영을 위한 권한 및 소유권 설정

# chmod 660 /var/named/dns* /var/named/min*

# chown .named /var/named/dns* /var/named/min*


데몬 재시작 및 시작프로그램에 등록

# /etc/rc.d/init.d/named restart

# chkconfig named on





3. 보조 DNS 서버 설정


# vi /etc/named.conf

     11         listen-on port 53 { any; };

     12         listen-on-v6 port 53 { any; };

     17         allow-query     { any; };

     18         recursion no;


# vi /etc/named.rfc1912.zones

     43 zone "dns.com" IN {

보조 DNS 서버의 성격 기술

     44         type slave;

     45         masters { 주DNS서버ip; };

     46         file "slaves/dns.z";

     47         notify no;

     48 };

     49

     50 zone "1.168.192.in-addr.arpa" IN {

     51         type slave;

     52         masters { 주DNS서버ip; };

     53         file "slaves/dns.r";

     54         notify no;

     55 };

     56

     57 zone "minimal.com" IN {

     58         type slave;

     59         masters { 주DNS서버ip; };

     60         file "slaves/sedns.z";

     61         notify no;

     62 };


데몬 재시작 및 시작프로그램에 등록

# /etc/rc.d/init.d/named restart

# chkconfig named on





4. 확인


각 서버에서 nslookup 을 통해 본인이 지정한 도메인 및 ip를 넣어서 정상 작동하는지 확인.

특히 보조 DNS 서버에서는 /var/named/slaves/ 에 제대로 파일들이 들어왔는지 확인


만약 잘 안되었다면 각 서버에서 아래의 명령어를 통해 서버 셋팅 적용해보길.


# rndc reload

# /etc/rc.d/init.d/named restart




And


[34] Apache

|


- 2014.12.23


기존 사용하던 server 삭제 후 새로운 압축 해제




1. Apache


웹 서비스를 제공하는 서버

HTML, PHP 및 JSP 페이지가 실행 될 수 있는 환경을 제공하는 '웹 서버 프로그램'



1) 웹 서버의 기본적인 동작


웹 브라우저로 Client가 페이지 요청

HTTP(Hypertext Transfer Protocol)을 사용하여 웹 브라우저와 웹 서버간 의사소통 - 80번 포트




2) Apache 특징


공개형 웹서버 프로그램

다양한 플랫폼에서 동작하는 유연한 설계




[실습]


cd 안에 있는 httpd* PKG 설치

=> 최신 패키지가 있는 것은 nodeps 옵션으로 제거 후 재설치




3) Apache 설정 파일


/etc/httpd/conf/httpd.conf


[ Section1 : 전역 환경 설정 ]


ServerTokens 지시어 : 서버 HTTP 응답 헤더를 설정, 오류문 등 서버 메시지에 출력되는 서버에 대한 정보 설정


Full : 아파치 서버 버전, 운영체제, 모듈 정보 등을 모두 출력

OS : 아파치 서버 버전과 운영체제 정보만을 출력

Minor : 아파치 서버의 하위 버전까지 출력

Min : 아파치 서버의 모든 정보만을 출력

Major : 아파치 서버의 주 버전 정보만을 출력

Prod : 아파치 서버의 정보만을 보여줌


VM 내 브라우저에서 ip주소/asdfasdfasdf 치면 오류 뜨는데 너무 자세한 정보가 나옴

보안상의 이유로 OS -> Prod 로 변경


# vi /etc/httpd/conf/httpd.conf

     44 ServerTokens OS

# /etc/rc.d/init.d/httpd restart

=> VM 내 브라우저에서 이상한 주소 입력해도 최소의 정보만 출력됨


Apache 서버가 설치된 곳 & 사용하는 pid 정보 저장 위치

# vi /etc/httpd/conf/httpd.conf

     57 ServerRoot "/etc/httpd"

     65 PidFile run/httpd.pid

        => /etc/httpd/run/httpd.pid


사용자의 움직임 없을 시 접속 끊을 시간

     70 Timeout 60


페이지를 띄울 때마다 새로운 process 받을 것인지에 대한 여부

     76 KeepAlive Off


76번줄 on 으로 설정했을 시 먹힘. 최대 요청 개수 및 지속시간.

76번 on으로 하면 89번은 짧게 주는 것이 좋음(2~3초)yy

     83 MaxKeepAliveRequests 100

     89 KeepAliveTimeout 15


Apache 접근 포트 변경, 변경하는 경우 방화벽에 등록해야 함

    136 Listen 80


# /etc/rc.d/init.d/httpd restart




[ Section2 ]


문제 생겼을 시 받을 관리자 이메일

    262 ServerAdmin root@localhost


# /etc/rc.d/init.d/httpd restart

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

해당 오류 해결 위해 276번 복사, 주석 삭제 후 원하는 도메인 입력

    277 ServerName www.samadal.com:80


웹페이지 기본 경로

    293 DocumentRoot "/var/www/html"


기본이 안될때 보여줄 곳

    318 <Directory "/var/www/html">


293의 디렉터리 안에 어떤 파일을 올릴 것인지

    403 DirectoryIndex index.html index.php index.html.var




[문제]


host : ns, www

domain : samadal.com

Firefox에서 www.samadal.com 을 입력하면 아파치 화면이 아닌 글이나 그림 둘 중 한개가 뜨도록 설정



# vi /etc/resolv.conf

      4 nameserver 192.168.1.145

      5 nameserver 192.168.1.2

      6 nameserver 168.128.63.1


DNS 설정은 이전 실습 파일 참조


# vi /etc/named.conf

# vi /etc/named.rfc1912.zones

# /etc/rc.d/init.d/named restart


# vi /etc/httpd/conf/httpd.conf

    136 Listen 80

    277 ServerName www.samadal.com:80


# /etc/rc.d/init.d/httpd restart




[실습]


samadal 계정 경로 : /home/samadal => /export/home/samadal

웹 기본경로 : /var/www/html => /export/home/samadal

index.html -> sama.html 로 변경 후 내용이 뜨도록 설정


# mkdir -p /export/home/

# mv /home/samadal/ /export/home/

# usermod -d /export/home/samadal samadal


# mv /var/www/html/* /export/home/samadal/sama.html


# vi /etc/httpd/conf/httpd.conf

    293 DocumentRoot "/export/home/samadal"

    403 DirectoryIndex index.html index.php index.html.var sama.html


# chmod 711 /export/home/samadal


# /etc/rc.d/init.d/httpd restart




And


서버 시간 동기화(ntpd)

|


출처 : http://www.server-world.info/en/note?os=CentOS_6&p=ntp&f=1

         http://webdir.tistory.com/120




1. 시간 동기화 패키지(ntp) 설치


# yum install ntp





2. 패지키 실행 및 자동실행 설정


실행

# service ntpd start


부팅 시 자동 실행되도록 설정

# chkconfig ntpd on


설정값 확인 - 동기화까지 수분의 시간이 걸린다.

# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

+send.mx.cdnetwo 204.123.2.5      2 u    7   64    1   12.894   11.159   2.440

-211.39.136.4       204.123.2.5      2 u    7   64    1   13.739  -16.242   1.642

*211.233.84.186    204.123.2.5      2 u    7   64    1   11.972    0.499   1.980

+mail.funix.net      211.233.40.78    3 u    7   64    1   13.691    4.842   1.984


맨 앞에 * 이 붙어있으면 동기화 중인 것.





3. (Advanced) ntp 서버 설정


# vi /etc/ntp.conf

     22 server 0.centos.pool.ntp.org iburst

     23 server 1.centos.pool.ntp.org iburst

     24 server 2.centos.pool.ntp.org iburst

     25 server 3.centos.pool.ntp.org iburst


server 로 시작하는 위의 줄을 삭제하거나 맨 앞에 #으로 주석처리 한 뒤 26번줄 부터 원하는 ntp 서버를 입력하면 원하는 서버를 통해 직접 서버 시간을 설정할 수 있다.


ex)

server kr.pool.ntp.org

server time.bora.net

server time.kornet.net




And