본문 바로가기

ETC/자격증

[리눅스마스터]제1701회 리눅스마스터 1급 2차 시험 작업식 풀이 2

반응형

14. 다음은 TCP Wrapper를 이용해 네트워크 서비스의 접근 통제 설정 절차이다.

조건에 맞게 ( 괄호 ) 안에 알맞은 내용을 적으시오.

# vi /etc/hosts.deny
ALL: ALL
# vi /etc/hosts.allow
( ① ): ( ② )
( ③ ): 10.20.30.40

<조 건>
- finger 서비스는 admin.net 네트워크 대역에 속한 호스트만 허가한다.
- telnet 서비스는 IP 주소가 10.20.30.40인 호스트인 경우에만 허가한다.

 

/etc/hosts.allow 파일에 정의된것은 허용

/etc/hosts.deny 파일에 정의된것은 거부

finger : 사용자 정보 확인 서비스telnet : 인터넷이나 로컬 영역 네트워크 연결

 

<데몬이름>:<Source IP주소 or 네트워크 or 이름>::[옵션]

 

[root@server1 ~]# vi /etc/hosts.deny
# hosts.deny    This file contains access rules which are used to
#               deny connections to network services that either use
#               the tcp_wrappers library or that have been
#               started through a tcp_wrappers-enabled xinetd.
#
#               The rules in this file can also be set up in
#               /etc/hosts.allow with a 'deny' option instead.
#
#               See 'man 5 hosts_options' and 'man 5 hosts_access'
#               for information on rule syntax.
#               See 'man tcpd' for information on tcp_wrappers

 

[root@server1 ~]# vi /etc/hosts.allow
#
# hosts.deny    This file contains access rules which are used to
#               deny connections to network services that either use
#               the tcp_wrappers library or that have been
#               started through a tcp_wrappers-enabled xinetd.
#
#               The rules in this file can also be set up in
#               /etc/hosts.allow with a 'deny' option instead.
#
#               See 'man 5 hosts_options' and 'man 5 hosts_access'
#               for information on rule syntax.
#               See 'man tcpd' for information on tcp_wrappers

 

① in.fingerd

② .admin.net

③ in.telnetd

 

15. 다음은 named.conf 설정이다. 조건에 맞게 ( 괄호 ) 안에 알맞은 내용을 적으시오.

options {
directory "/var/named";
forward ( ① );
( ② ) { 8.8.8.8; };
( ③ ) 1024M(;
( ④ ) { 192.168.64/24; };
};

<조 건>
- 서버로 들어온 도메인 질의 요청은 8.8.8.8 IP주소를 가진 호스트로 넘기고, 해당 서버에서 응답이 없어도 질의에 응답하지 않는다.
- DNS 관련정보 캐싱을 하는데 사용하는 메모리를 1024M로 제한한다.
- 네임 서버에 질의할 수 있는 호스트를 192.168.64.0 네트워크 주소 대역에 속한 호스트만 질의할 수 있게 설정한다.

 

named.conf : 리눅스 DNS 서버 프로그램인 bind (데몬명 named)의 메인 설정 파일

 

[root@server1 ~]# find / -name named.conf
/etc/named.conf
/usr/lib/tmpfiles.d/named.conf
/usr/share/doc/bind-9.11.4/sample/etc/named.conf

 

[root@server1 ~]# vi /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

options {
        listen-on port 53 { 127.0.0.1; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { localhost; };

        /*
         - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
         - If you are building a RECURSIVE (caching) DNS server, you need to enable
           recursion.
         - If your recursive DNS server has a public IP address, you MUST enable access
           control to limit queries to your legitimate users. Failing to do so will
           cause your server to become part of large scale DNS amplification
           attacks. Implementing BCP38 within your network would greatly
           reduce such attack surface
        */
        recursion yes;

        dnssec-enable yes;
        dnssec-validation yes;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.root.key";

        managed-keys-directory "/var/named/dynamic";

        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
        type hint;
        file "named.ca";
};

- directory : zone 파일이 위치하는 디렉토리 명
- forwarders {네임서버 주소; 네임서버 주소; ...;}; : 도메인에 대한 질의를 다른 서버로 넘긴다.
- forward (only|first); : forwarder와 함께 사용되어야 한다.
    - only : 다른 서버가 응답이 없을 경우 자신도 응답하지 않는다.
    - first : 다른 서버에서 응답이 없으면 자신이 응답 한다.
- datasize 1024M : 캐시 메모리 최대 용량을 제한한다.
- allow-query { 192.168.64/24; }; : 네임서버에 질의할 수 있는 호스트를 지정한다.

 

① only

② forwarders

③ datasize

④ allow-query

 

16. 다음 조건에 맞게 iptables의 방화벽 정책을 설정하려고 한다. ( 괄호 ) 안에 알맞은 내용을 적으시오.

# iptables ( ① ) INPUT
# iptables -A INPUT ( ② ) lo -j ACCEPT
# iptables -A INPUT ( ③ ) tcp ( ④ ) ( ⑤ ) -j ACCEPT
# iptables -P INPUT ( ⑥ )

<조 건>
- 답안 작성시 대소문자를 구분한다.
- 첫 번째로 기존에 설정된 정책을 전부 삭제한다.
- 두 번째로 INPUT 체인에 loopback 인터페이스에 들어오는 모든 패킷에 대해 허용 정책을 추가 한다.
- 세 번째로 INPUT 체인에 프로토콜이 tcp이며 목적지포트가 22번부터 23번 포트인 패킷에 대해 허용 정책을 추가 한다.
- 마지막으로 INPUT 체인에 대한 기본 정책을 거부 메시지 없이 거절로 변경한다.

 

iptables : 리눅스의 패킷 필터링(Packet Filtering) 도구로서 방화벽 구성이나 NAT(Network Address Translation)에 사용

 

iptables  [-t 테이블] [액션] [체인] [매치] [-j 타겟]

 

[root@server1 ~]# find / -name iptables
/etc/sysconfig/iptables
/usr/sbin/iptables
/usr/share/bash-completion/completions/iptables
/usr/libexec/initscripts/legacy-actions/iptables
/usr/libexec/iptables

 

[root@server1 ~]# vi /etc/sysconfig/iptables
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

 

<액션>
-A : APPEND : 정책 추가
-I : INSERT : 정책 삽입
-D : DELETE : 정책 삭제
-R : REPLACE : 정책 교체
-F : FLUSH : 모든 정책 삭제
-P : POLICY : 기본 정책을 설정
-L : LIST : 정책 나열

<매치>
-s : 출발지 매칭. 도메인, IP 주소, 넷마스크 값을 이용하여 표기(––source, ––src)
-d : 목적지 매칭. 도메인, IP 주소, 넷마스크 값을 이용하여 표기(––destination, ––dst)
-p : 프로토콜과 매칭. TCP, UDP, ICMP 와 같은 이름을 사용하고 대소문자는 구분하지 않음
-i : 입력 인터페이스와 매칭(––in-interface)
-o : 출력 인터페이스와 매칭(––out-interface)
-j : 매치되는 패킷을 어떻게 처리할지 지정 (--jump)

<타켓>
- ACCEPT : 패킷을 허용한다.
- DROP : 패킷을 버린다(패킷이 전송된 적이 없던 것처럼)
- REJECT : 패킷을 버리고 이와 동시에 적절한 응답 패킷을 전송한다.(icmp-port-unreachable)
- LOG : 패킷을 syslog에 기록한다.
- SNAT --to [주소] : 소스 IP를 [변환(NAT)|NAT]한다.
- DNAT --to [주소] : 목적지 IP를 변환(NAT)한다.
- RETURN : 호출 체인 내에서 패킷 처리를 계속한다.

 

① -F

② -i

③ -p

④ --dport

⑤ 22:23

⑥ DROP

반응형