'solaris'에 해당되는 글 20건

  1. 2008.09.04 NTP(Network Time Protocol)
  2. 2008.09.04 DHCP(Dynamic Host Configuration Protocol) Server 2
  3. 2008.09.02 DNS Server Management
  4. 2008.09.02 nslookup CMD
  5. 2008.09.02 DNS Server(Domain Name System) 1
  6. 2008.09.01 IPv6-IPv4-IPv6 Tunnel Configuration
  7. 2008.08.29 ref_icmp
  8. 2008.08.29 ref_ipmp
  9. 2008.08.29 ref_ndd
  10. 2008.08.11 Chapter 9. 원격 접속과 파일전송
  11. 2008.08.08 Chapter 8. 프로세스 관리
  12. 2008.08.08 Chapter 7. Korn Shell Characteristic
  13. 2008.08.07 Chapter 6. Vi 편집기
  14. 2008.08.07 Chapter 5. Unix Basic Commands _ 아카이브/압축 관련 명령어
  15. 2008.08.07 Chapter 5. Unix Basic Commands _ 링크 관련 명령어
  16. 2008.07.19 Chapter 4. Solaris 9 Installation
  17. 2008.07.19 Chapter 3. Solaris Introducing
  18. 2008.07.19 Chapter 2. OS Overview
  19. 2008.07.19 Chapter 1. UNIX History
  20. 2008.07.19 solaris 알림
2008. 9. 4. 18:46

NTP(Network Time Protocol)

 

 

 

               NTP(Network Time Protocol)

 

 

 

 

 

0. Why NTP !!!!

__________________

 

많은 네트워크 프로그램들은 시간 동기화가 필요하게 된다. 네트워크 상에서 서로 연동하

는 시스템들 간에 시간이 일치 하지 않게 된다면 다수의 시스템 장애처리, 성능카운트,

분석, 로깅등 수많은 문제점을 갖게된다.

 

NFS Server

DB Server

Logging Server

NMS Program(Network Management Solution)

Encyption

기타

 

 

 

===== WebServerA =====                 ===== NFS Server ====

 Date: 12:00                                12:10

        /p/file1(12:10)                 /source/file1(12:10)

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

                                                  A

===== WebServerB =====                            |

 Date: 12:40                                      +---- file1 생성

        /p/file1(12:10)

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

 

             [그림] 서버간의 시간 동기화 이유

 

 

[참고] 실무에서 많이 사용하고 있는 방법 예

# rdate gps.bora.net

or

# ntpdate time.kriss.re.kr

 

# crontab -e

0 * * * * rdate gps.bora.net    (gps.bora.net:  210.120.246.46)

......

0 * * * * ntpdate time.kriss.re.kr

 

 

[EX] rdate 명령어 실습

 

# date

Fri Mar  7 10:45:34 KST 2008  (10 45 34)

 

# date 03070845               (03 07 08 45)

# date

Fri Mar  7 08:45:00 KST 2008  (03 07 08 45 00)

 

# rsh 172.16.8.254 date

 

# rdate 172.16.8.254

# date

(서버의 시간과 같은지 확인한다.)

 

 

 

 

 

1. NTP Server Overview

_________________________

 

NTP (network time protocol, 네트웍 시간 프로토콜)

 

NTP는 네트웍으로 연결되어 있는 컴퓨터들끼리 클록 시각을 동기화시키는데 사용되는 프

로토콜이다. NTP는 미국 델라웨어 대학의 데이빗 밀스에 의해 처음 개발되었으나, 이제는

인터넷 표준이 되었다. NTP는 컴퓨터 클록 시간을 1/1000 초 이하까지 동기화시키기 위

해 협정 세계시각(UTC)을 사용한다.

 

컴퓨터 네트웍 전반에 걸쳐 정확한 시각을 유지하는 것은 여러 가지 이유로 중요한데, 그

이유는 심지어 수십 분의 1초 정도의 차이만으로도 큰 문제가 발생될 수 있기 때문이다.

예를 들어 협정 세계시에 기반을 두면, 지역적으로 분산된 업무처리 환경에서도 작업 순

서가 정확히 유지될 수 있다. 보안 메커니즘 역시 네트웍 전체에 걸쳐 협정 세계시에 기

반을 두고 있다. 여러 대의 컴퓨터가 하나의 파일 시스템을 수정하는 것 역시 정확히 동

기화된 클록 시각에 의존해야 한다. 항공기의 운항 궤적을 그림으로 표시해 주는 항공관

제 시스템에도 매우 정확한 시간측정이 요구되는 것은 당연하다.

 

협정세계 시각은 무선이나 위성 시스템 등, 여러 가지 방법으로 얻어진다. GPS나 정부기

관 등과 같은 특수한 수신자들은 보다 높은 수준의 서비스를 이용하는 것이 가능하지만,

모든 컴퓨터에 수신기를 장착하는 것은 비경제적이며, 현실성이 없다. 그 대신에, 시각

서버로 지정된 컴퓨터들에만 수신기를 장착하고, 이 서버들과 네트웍으로 연결되어 있는

컴퓨터들의 클록 시각은 NTP와 같은 프로토콜을 사용하여 동기화하는 것이다.

 

협정세계시로부터 떨어져 있는 수준을 표시하기 위해 흔히 계층번호를 쓰는데, 0번 계층

은 전용 송신기 또는 위성 위치추적 시스템으로부터 수신된 실제 시각인 무선 클록을,

1번 계층은 이 무선 클록과 직접 연결되어 있는 컴퓨터의 클록을, 2번 계층은 1번 계층으

로부터 시각을 받은 컴퓨터 등으로 원천 협정 세계시로부터 멀수록 계층 번호가 커져 간다.

 

 

NTP라는 용어는, 프로토콜과 컴퓨터상에서 실행되는 클라이언트/서버 프로그램, 둘 모두

에 대해 사용된다. 프로그램은 사용자에 의해 NTP 클라이언트, NTP 서버, 또는 둘 모두로

해석될 수 있다. NTP 클라이언트는 시각 서버에 정확한 현재 시각을 교환할 것을 요구한다.

이 교환의 결과를 통해, 클라이언트는 서버의 시각과의 차이를 이용하여 링크 지연시간을

계산할 수 있으며, 자신의 클록을 서버에 있는 클록과 일치하도록 조정할 수 있다. 하나의

규칙으로서, 처음 클록을 맞추기 위해서는 5~10분 동안 모두 6번의 시각 교환이 요구된다.

일단 시각 동기화가 끝나면, 클라이언트는 매 10분마다 메시지 교환을 통해 클록을 수정

한다. 클록 동기화의 신뢰도 및 정확도를 높이기 위해, 여러 대의 서로 다른 서버와 다양

한 네트웍 경로가 사용된다. 클라이언트/서버 동기화에 아울러, NTP는 브로드캐스트를 통

한 컴퓨터 클록 동기화도 지원한다. NTP는 매우 높은 수준의 내고장성과 확장 가능성을

염두에 두고 설계되었다.

 

 

NTP 서버에서 사용되는 용어에 대해 알아보자.

 

(1). 기본적인 용어

■ Reference Clock   - GMT, UTC과 같이 표준시간 또는 참고 시간 (기준 시간)

■ Strata            - NTP 서버의 계층적 구조

■ Stratum-1 Server  - NTP 1계층 서버

   Stratum-2 Server  - NTP 2계층 서버

   ...    -15 ....   - NTP 15계층 서버(15까지 존재)

■ Drift File        - PPM(Parts-Per-Million)단위로 오프셋에 일치하는 단일 부동 소수

                       점이 들어가 있다. (예: /var/ntp/ntp.drift)

■ xntpd             - NTP 서버/클라이언트 데몬

■ ntp.conf          - NTP 서버/클라이언트 주 설정 파일

 

 

 

(2). 추가적인 용어

■ Resolution       - 시간 제공 장치에서 사용하는 시간의 최소 단위.

                       예) 손목시계의 Resolution : 1초

■ Precision        - 컴퓨터 프로그램에서 사용하는 시간의 최소 단위.

■ Accuracy         - 시간의 정확성. 기준시간(UTC)과 얼마나 근접한가를 나타냄.

■ Jitter           - 시간을 측정했을 때 생기는 오차 중 작은 값.

■ Wander           - 시간을 측정했을 때 생기는 오차 중 큰 값.

 

 

[참고] UTC & GMT

■ UTC(Universal Time Coordinate) 협정 세계시, 그리니치 표준시 대신 방송에 사용되

   는 표준시. 협정 세계시는 국제 사회가 사용하는 과학적 시간의 표준입니다.

   1972년 1월 1일부터 시행된 협정세계시에서는 67년 국제도량형총회가 정한 세슘원자의

   진동수에 의거한 초의 길이가 그 기준(원자초)으로 쓰인다. 그 때까지 시간의 기준으로

   는 지구의 자전에 의한 평균태양시와 지구의 공전에 의한 태양년에서 산출한 초의 길이

   가 쓰였다. 그리니치표준시(GMT)는 원래 평균태양시를 기준으로 한 것이었다. 따라서

   원자시계를 표준으로 하면서부터 GMT라는 명칭이 실체(實體)를 바르게 나타내지 못하는

   불합리한 점이 생겼다. 이러한 문제를 없애기 위해서 1978년 국제무선통신자문위원회

   (CCIS) 총회는 통신분야에서는 금후 그리니치평균시를 협정세계시(UTC)로 바꾸어 쓰자

   는 권고안을 채택하였다.

 

■ GMT(Greenwich Mean Time) 그리니치 표준시.

   그리니치천문대를 지나는 본초자오선(그리니치자오선)을 기준으로 하는 시. 약호 GMT.

   약칭하여 그리니치시라고도 한다. 1925년 이전의 그리니치시는 정오(正午)를 0시로 하여

   시간을 재기 시작하는 방식의 천문학용 평균태양시의 명칭이었다. 이에 반해 일상생활에

   서는 자정을 0시로 하여 시간을 재는 방식이 사용되었으며, 이것을 그리니치상용시(GCT)

   라고 하였다. 1925년 1월 1일 국제천문연합에서는 그리니치시를 12시간 앞당겨 그리니치

   상용시와 일치시켰으며, 이를 세계시(世界時)라고 하여 전세계 공통의 표준시로 사용하

   였다. 그러나 지구의 자전을 근거로 한 이 세계시는 수정시계나 원자시계와 비교한 결과

   지구 자전의 불규칙성에 의한 오차가 있으므로 1972년 이후에는 새로이 협정세계시가 세

   계표준시로 사용되었다. 협정세계시란 세계시와는 달리 원자 방사(放射)의 진동수를 기

   준으로 하고, 원자시의 초(秒)를 세분하여 세계시와의 차이가 0.9초 이내가 되도록 만든

   것이다.

 

[참고] 참고 URL(시, 시간의 인식, 시의 척도, 시법, 하루의 시작, 보시등)

http://kr.dic.yahoo.com/search/enc/result.html?p=UTC&pk=15348300&subtype=&type=enc&field=id

 

 

[참고] Stratum 1 / Stratum 2

http://www.ntp.org

Stratum 1 Server : http://support.ntp.org/bin/view/Servers/StratumOneTimeServers

Stratum 2 Server : http://support.ntp.org/bin/view/Servers/StratumTwoTimeServers

 

 

 

 

 

2. NTP Server Concept

________________________

 

 

(1). Startup Script

 

부팅시에 실행되는 스크립트로는 런레벨2에서 동작하는 S74xntpd 스크립트에 의해 xntpd

데몬이 동작하게 된다. xntpd 데몬은 기본값으로 123번 포트를 사용한다.

 

- /etc/init.d/xntpd stop/start

- /etc/rc2.d/S74xntpd

 

 

 

(2). NTP Network Transfer Time Check

 

 NTP Client           NTP Server

     |                     |

  T1 | ------------------> | T2

     |                     |

     |                     |

  T4 | <------------------ | T3

     |                     |

     |                     |

 

네트워크에서 보낸시간 = [(T2-T1)+(T4-T3)] / 2

 

 

(a). NTP Client는 NTP 서버에 현재 시간을 요구하는 요청을 보낼 때, 패킷에 클

     라이언트의 현재 시간(T1)을 포함하여 보낸다.

(b). 클라이언트의 요청을 받은 NTP 서버는 요청을 받았을 때의 서버 시간(T2)을

     패킷에 포함한다.

(c). NTP 서버는 현재 UTC 시간을 패킷에 포함하고, 클라리언트로 보내는 순가의

     서버 시간(T3)도 패킷에 포함하여 클라이언트의 요청에 응답한다.

(d). 클라이언트는 서버의 응답을 받는 순간의 시간(T4)과 나머지 시간들을 이용

     하여 네트워크에서 얼만큼의 시간을 보냈는지 판단하여 UTC 시간에 더한 후

     시스템의 시간으로 설정한다.

 

 

 

 

 

3. NTP Server Configuration

_____________________________

 

# cd /etc/inet

# ls ntp.*

(ntp.server, ntp.client) => ntp.conf

 

ntp.server : NTP Server Templete Configuration File

ntp.client : NTP Client Templete Configuration File

 

 

(1). Undiscipline Local Clock

# cd /etc/inet

# cp ntp.server ntp.conf

# vi ntp.conf

......

server 127.127.1.0 prefer         <----- 라인 수정(XType -> 1)

#fudge 127.127.XType.0 stratum 0  <----- 주석 처리

......

driftfile /var/ntp/ntp.drift      <----- 정보 확인

......

# touch /var/ntp/ntp.drift

# /etc/init.d/xntpd stop

# /etc/init.d/xntpd start

 

 

 

(2). Discipline Clock

 

# cp ntp.server ntp.conf

# vi ntp.conf

......

server time.kriss.re.kr prefer      <----- 라인 추가

server gps.bora.net                 <----- 라인 추가

server <NTP 서버 IP>                <----- 라인 추가

......

#fudge 127.127.XType.0 stratum 0    <----- 주석처리

......

 

# touch /var/ntp/ntp.drift

# /etc/init.d/xntpd stop

# /etc/init.d/xntpd start

 

 

[참고] server Directive

server 지시자 다음에 쓸수있는 대표적인 기관(IP)은 한국표준연구원입니다. 시스템(서버)

의 시간을 세계표준시(초단위까지)로 설정하고 싶다면 rdate 명령어를 사용하여 다음과

같이 사용합니다.

 

# rdate time.kriss.re.kr

or

# ntpdate time.kriss.re.kr

(time.kriss.re.kr : 210.98.16.100)

한국표준연구원 : http://www.kriss.re.kr

                 시간, 길이, 질량등 모든 표준을 관리합니다.

 

 

[참고] ntp.server 파일 해석

/etc/inet/ntp.server (/etc/inet/ntpd.conf) 파일의 해석에 대해 알아 보자.

ntp.conf 파일의 해석에 대한 글은 KIPA 사이트의 글을 인용하여 만들었습니다.

 

 

# vi /etc/inet/ntp.server

------------------- ntp.server 파일 해석 시작 -----------------------------

(a) 주석 부분 해석

 

/etc/inet/ntp.conf로 복사하여 수정할 수 있는 예제 파일입니다. 이

파일은 외부 하드웨어 클럭을 수신하여 로컬 클럭을 동기화시키고 NTP

멀티캐스트 넷에 자신을 발표하는 서버를 위한 환경 설정 템플릿으로

사용할 수 있습니다.

 

다음 클럭 장치들에 대해서는 RFC 1305를 참조하십시오.

이것은 외부 클럭 장치입니다. 다음 장치들은 xntpd 3.4y에 의해 인식됩니다.

 

XType 장치 이름 해설

 

# XType Device    RefID          Description

# -------------------------------------------------------

#  1    local     LCL            Undisciplined Local Clock

#  2    trak      GPS            TRAK 8820 GPS Receiver

#  3    pst       WWV            PSTI/Traconex WWV/WWVH Receiver

#  4    wwvb      WWVB           Spectracom WWVB Receiver

#  5    true      TRUE           TrueTime GPS/GOES Receivers

#  6    irig      IRIG           IRIG Audio Decoder

#  7    chu       CHU            Scratchbuilt CHU Receiver

#  8    parse     ----           Generic Reference Clock Driver

#  9    mx4200    GPS            Magnavox MX4200 GPS Receiver

# 10    as2201    GPS            Austron 2201A GPS Receiver

# 11    arbiter   GPS            Arbiter 1088A/B GPS Receiver

# 12    tpro      IRIG           KSI/Odetics TPRO/S IRIG Interface

# 13    leitch    ATOM           Leitch CSD 5300 Master Clock Controller

# 15    *         *              TrueTime GPS/TM-TMD Receiver

# 17    datum     DATM           Datum Precision Time System

# 18    acts      ACTS           NIST Automated Computer Time Service

# 19    heath     WWV            Heath WWV/WWVH Receiver

# 20    nmea      GPS            Generic NMEA GPS Receiver

# 22    atom      PPS            PPS Clock Discipline

# 23    ptb       TPTB           PTB Automated Computer Time Service

# 24    usno      USNO           USNO Modem Time Service

# 25    *         *              TrueTime generic receivers

# 26    hpgps     GPS            Hewlett Packard 58503A GPS Receiver

# 27    arc       MSFa           Arcron MSF Receiver

 

일부 장치들은 "fudge" 인자를 사용하여 도움을 얻을 수 있습니다.

xntpd 문서를 참조하십시오.

 

피어나 서버 중의 하나입니다. "XType"을 위의 표의 값으로 바꾸십시오.

 

로컬 하드웨어 클럭 장치를 추가하는 경우,

드라이버는 여기서 server 127.127.XX.0과 같은 지시문으로

지정됩니다. 여기서 127.127은 NTP에게 이것이 원격 네트워크 피어가

아니라 로컬 네트워크 피어임을 알려 주는 것이고, XX는 NTP 배포판에 설명된

클럭 유형입니다. 이 환경 설정 파일의 제한 지시문은 이 호스트가

지정된 두 IP 주소와만 대화를 하도록 지정합니다. 호스트는 그 외의

다른 주소는 신뢰하지 않으며, 다른 주소에 시간을 할애하지 않을 것입니다.

배포판에는 많은 제한 옵션에 대한 문서 자료가 포함되어 있습니다.

예를 들어 다음 코드 라인을 사용하면 이 호스트를 시간 서버로 설정할 수 있습니다.

    restrict default notrust nomodify

이 코드 라인은 요청을 받으면 시간 패킷을 보내지만 다른 피어에

동기화시키지는 않는다는 의미입니다.

 NTP의 통계 자료 및 파일 생성 기능을 이용하면 NTP 성능을 기록 처리할 수

있습니다. 예를 들어, /usr/adm/peerstats의 레코드의 형식은 다음과 같습니다.

 

MJD Second Peer IP Stat Offset Delay Dispersion

49815 60424.676 192.5.41.40 9614 -0.000040 0.00169 0.00793

 

UT 일이 시작된 이후 60424.676 초가 경과한 때인 Modified Julian Date 49815에

행해진 이 항목은 주소가 192.5.41.40인 시간 서버와 비교하여 클럭을

-0.000040 초 만큼 보정했음을 알려줍니다. 두 시스템 사이의 네트워크

시간 지연은 (실제로는 바로 옆 방에 있는 시스템인데도) 0.00169초로

계산되었고, 시간 지연 추정값 샘플의 분산은 0.00793 초였습니다.

Stat 필드에는 RFC-1305 문서에서 자세히 설명하는 것처럼 ntp 상태 플랙이

지정됩니다. 공개 NTP 릴리스의 scripts/stats 디렉터리에는 이러한 로그

파일을 요약하는 유틸리티들이 있습니다.

 

 

 

(b). server & fudge 설정

 

그곳에는 기본 설정에 따라 다음 두 코드 라인이 있습니다. 사용자의 설정 내용에 따라 그

내용을 수정하십시오.

 

     # server 127.127.XType.0 prefer          //server용

     # fudge 127.127.XType.0 stratum 0        // next stratum servern

 

세 가지 종류의 시간 서버

(ㄱ). peer host_address [ key # ] [ version # ] [ prefer ]

로컬 서버가 host_address로 지정된 원격 서버와 함께 대칭형 액티브 모드로 작동하게 지

정하는 것입니다. 즉, 로컬 서버를 원격 서버에 동기화시킬 수 있습니다.

 

(ㄴ). server host_address [ key # ] [ version # ] [ prefer ] [ mode # ] server

로컬 서버가 명령에 따라 이름이 지정된 원격 서버에 대해 "클라이언트" 모드로 작동하게

지정하는 것입니다. 이 모드에서는 로컬 서버를 원격 서버에 동기화시킬 수 있지만, 원격

서버는 절대로 로컬 서버에 동기화시킬 수 없습니다.

 

(ㄷ). broadcast host_address [ key # ] [ version # ] [ ttl # ]

로컬 서버가 "broadcast" 모드로 작동하게 지정하는 것입니다. "broadcast" 모드에서 로

컬 서버는 명령으로 이름이 지정된 브로드캐스트/멀티캐스트 주소의 클라이언트에게 주기

적으로 브로드캐스트 메시지를 보내게 됩니다.

 

key 이 주소로 보내진 모든 패킷에 지정된 키 번호를 사용하여 암호화된 인증 필드가 포

함되어 있음을 가리킵니다. 이 숫자의 범위는 부호가 붙지 않은 32 비트 정수의 범위입니

다. 달리 지정하지 않으면, 암호화 필드가 포함되지 않습니다. version 밖으로 보내는

NTP 패킷에 대해 사용할 버전 번호를 지정합니다. version 1, version 2, version3 중에

서 선택합니다. 기본 설정값은 version 3입니다. prefer 호스트를 우선 호스트로 표시합니

다. 이 호스트는 비교할 수 있는 다른 호스트를 통하여 동기화시킬 때 우선 처리됩니다.

전체 목록은 xntpd에 관한 매뉴얼 페이지를 참조하십시오.

 

필자는 로컬 클럭을 서버 클럭으로 사용하므로, Xtype=1입니다.

fudge 명령은 다음과 같이 특별한 방식으로 클럭을 참조하기 위해 사용할 수 있습니다.

fudge 127.127.t.u [ time1 secs ] [ time2 secs ]

[ stratum int ] [ refid int ] [ flag1 0|1 ]

[ flag2 0|1 ] [ flag3 0|1 ] [ flag4 0|1 ]

stratum: 0에서 15까지의 범위에 속하는 숫자이며 클럭에 비표준 작동 방식을 할당하는

데 사용됩니다. 달리 지정하지 않으면, 이 값은 0입니다. 프라이머리 서버는 대체로

stratum을 0보다 큰 값으로 표시합니다.

자세한 내용은 xntpd에 관한 매뉴얼을 참조하십시오.

 

 

     server 127.127.1.0 prefer

     fudge 127.127.1.0 stratum 0

 

 

 

(c). 다양한 옵션 설정 / 해제

 

enable auth|bclient|pll|monitor|stats [ ... ]

disable auth|bclient|pll|monitor|stats [ ... ]

 

신뢰할 수 있는 키와 식별 부호를 사용하여 환경 설정이 되지 않은 피어를 정확하게 인증

한 경우에만 서버가 그 피어와 동기화됩니다. 또한 모니터 기능도 사용하도록 설정합니다.

 

     enable auth monitor

 

 

 

(d). Drift File의 위치 지정

 

drift 파일의 위치를 지정합니다 이 파일에는 ppm(parts-per-million) 단위로 오프셋에 일

치하는 단일 부동 소수점 값이 들어 있습니다.

 

     driftfile /var/ntp/ntp.drift

 

 

 

(e). ntpstat 디렉토리 지정

 

ntpstats 디렉토리를 지정합니다.

 

     statdir /var/ntp/ntpstats

 

# cd /var/ntp/ntpstats

# ls

.....

loopstats.20070826   peerstats.20070709   peerstats.20071101

loopstats.20070828   peerstats.20070710   peerstats.20071102

loopstats.20070829   peerstats.20070711

loopstats.20070905   peerstats.20070714

......

 

# cat peerstats.20071102

......

54406 16854.142 0.000000 -28.4410 6

54406 16918.141 0.000000 -28.4410 6

54406 16982.138 0.000000 -28.4410 6

54406 17046.137 0.000000 -28.4410 6

 

 

 

(f). peerstats, loopstats, clockstats 설정

 

peerstats, loopstats, clockstats 등의 파일을 생성하고 파일을 사용할 있도록

합니다.

 

filegen name [ file filename ] [ type typename ] [ flag flagval ] [ link|nolink ]

             [ enable|disable ]

하루 동안 피어, 루프, 클럭 등의 stat 파일을 생성하고 그 파일을 사용할 수 있도록 설

정합니다.

 

유형과 관련된 다른 옵션들은 다음과 같습니다.

week,month,year,age ,none

 

     filegen peerstats file peerstats type day enable

     filegen loopstats file loopstats type day enable

     filegen clockstats file clockstats type day enable

 

 

 

(g). 인증 기법 지정

 

인증 기법을 사용하는 경우 이곳에서 지정하십시오

keys filename

인증 모드로 작동할 때 xntpd가 사용하는 암호화 키와 키 식별 부호가 들어 있는 파일의

이름을 지정합니다.

 

     keys /etc/inet/ntp.keys

     trustedkey 0

     requestkey 0

     controlkey 0

 

trustedkey # [ # ... ]

동기화에 적합한 인증 피어의 목적에 맞게 신뢰할 수 있는 암호화 키 식별자를 지정합니

다. 인증 절차를 사용하려면 로컬 서버와 원격 서버가 모두 이러한 목적으로 사용하도록

정의된 키와 키 식별자를 동일하게 공유해야 합니다. 하지만, 서버마다 다른 키를 사용할

수도 있습니다. 인수는 부호가 붙지 않은 32 비트 정수입니다. 하지만, key 0는 고정되어

있고 글로벌 영역에 알려져 있다는 점에 유의하십시오. 의미있는 인증을 실행해야 한다면,

0 키를 신뢰해서는 안됩니다.

 

controlkey #

ntpq(1M) 프로그램에서 사용할 키 식별자를 지정합니다. 이 프로그램은 xntpd 동작에 영

향을 주는 문제들을 진단하고 수리하는 데 도움이 됩니다. ntpq 프로그램과 xntpd의 동

작은 RFC 1305 규정의 내용과 일치합니다. 로컬 서버의 상태에 영향을 주는 원격 ntpq 프

로그램에서 보내는 요청은 인증되어야 합니다. 이렇게 하려면 원격 프로그램과 로컬 서버

가 모두 공통 키와 키 식별자를 공유해야 합니다. 이 명령의 인수는 부호가 붙지 않은 32

비트 정수입니다. 환경 설정 파일에 controlkey 명령이 포함되어 있지 않거나 키가 일치

하지 않은 경우, 이러한 요청은 무시됩니다.

 

authdelay seconds

로컬 컴퓨터의 NTP 인증 필드를 암호화하는 데 걸리는 시간을 알려줍니다. 이 값은 밖으

로 나가는 패킷에 대해 인증을 할 때 전송 타임스탬프를 교정하는 데 사용됩니다. 이 값

은 호스트 컴퓨터의 CPU 속도에 따라 다르지만 일반적으로 0.0001 초에서 0.003 초의 범

위에 있습니다.

 

액세스 제어 명령:

액세스를 제한하는 데 restrict를 사용하는 것 이외에는 지금은 사용하지 않습니다.

 

구문:

restrict address [ mask numeric_mask ] [ flag ] [ ... ]

이 환경 설정 파일의 제한 지시문은 이 호스트가 지정된 두 IP 주소와만 대화를 하도록

지정합니다. 호스트는 그 외의 다른 주소는 신뢰하지 않으며, 다른 주소에 시간을 할애

하지 않을 것입니다. 배포판에는 많은 제한 옵션에 대한 문서 자료가 포함되어 있습니다.

예를 들어, 다음 코드 라인을 사용하면 이 호스트를 시간 서버로 설정할 수 있습니다.

restrict default notrust nomodify

이 코드 라인은 요청을 받으면 시간 패킷을 보내지만 다른 피어에 동기화시키지는 않는다

는 의미입니다.

 

xntpd는 범용 주소-마스크 기준 제한 목록을 실행합니다.

자세한 내용은 xntpd에 관한 매뉴얼 페이지를 참조하십시오.

 

------------------- ntp.server 파일 해석 끝 -----------------------------

 

 

 

 

 

4. NTP Client Configuration

____________________________

 

# cd /etc/inet

# cp ntp.client ntp.conf

# /etc/init.d/xntpd stop

# /etc/init.d/xntpd start

 

 

 

 

 

5. NTP Practice

___________________

 

NTP Server : 172.16.8.254

NTP Client : 172.16.8.202

 

(NTP Server)

# cd /etc/inet

# cp ntp.server ntp.conf 

# vi ntp.conf

.....

server 210.98.16.100 prefer  (210.98.16.100 -> time.kriss.re.kr)

.....

# touch /var/ntp/ntp.drift

# /etc/init.d/xntpd stop

# /etc/init.d/xntpd start

 

TERM1)

# tail -f /var/adm/messages

TERM2)

# snoop -d hme0 | grep -i ntp

 

 

(NTP Client)

# cd /etc/inet

# cp ntp.client ntp.conf

# /etc/init.d/xntpd stop

# /etc/init.d/xntpd start

 

TERM1)

# tail -f /var/adm/messages

TERM2)

# snoop -d hme0 | grep -i ntp

 

(NTP Client) Time Changes

Manually set your NTP client systems time 30 seconds back. Do not

set your systems clock more than an one minute out because the

xntpd process requests manual intervention for large time changes.

 

# date              (current time :  21:20 15)

# date 11022120     (current time :  21:20 00)

....(1~2분후에)....

# date

# rsh 172.16.8.XXX date (NTP Server IP)

 

 

 

 

 

6. Reference

_____________________

 

[NTP Server Configuration File]

 

server 127.127.1.0 prefer     The IP address of the preferred NTP server. In this

                              case, the loopback address is used, indicating the

                              use of a local undisciplined clock. The server

                              keyword indicates an IP address of an NTP server

                              from which time will be received. If the system

                              happens to be a stratum-1, then you use X in the

                              127.127.X.0 syntax to identify a reference clock

                              source. If the server is a stratum-2 (or higher), this

                              entry would be an IP address of another NTP

                              server to contact for time information. The prefer

                              keyword means that if multiple systems of the

                              same strata are used to getting clock information,

                              a preferred server is the one that will always be

                              used when performing calculations.

 

fudge 127.127.1.0 stratum 0   The fudge entry is available to change (fudge) the

                                                             stratum that the server advertises.

 

broadcast 224.0.1.1 ttl 4             The address the server uses to advertise to the

                                                             network along with the time-to-live (TTL) value to

                                                             use in the IP datagrams.

 

enable auth monitor                   The configuration entry that enables

                                                             authentication and the monitoring facility.

 

 

driftfile /var/ntp/ntp.drift  The location of the drift file.

 

statsdir /var/ntp/ntpstats/   The location of NTP statistics.

 

keys /etc/inet/ntp.keys               The conventional name of the key file used for

                                                             authentication.

 

trustedkey 0                                 The encryption identifier. (Refer to RFC 1305 for

                                                             more information.)                   

 

controlkey 0                                 The key identifier. (Refer to RFC 1305 for more

                                                             information.)

 

 

 

 

 

6. 참고 사이트

 

[1] http://www.ntp.org

[2] http://www.kipt.co.kr/index.php?doc=bbs/gnuboard.php&bo_table=pds&page=1&wr_id=24

2008. 9. 4. 18:18

DHCP(Dynamic Host Configuration Protocol) Server

 

 

 

               DHCP(Dynamic Host Configuration Protocol) Server

 

 

 

 

- Private Addr, DHCP

- IPv6

IP 부족 현상에 대한 보상책

ㅁ 사설 IP(Private Addr.)

DHCP

IPv6

 

DHCP

IP 부족 현상으로 효율적인 IP 할당을 위해서 사용되었지만 현재는 IP의 효율적 관리를 위해서 주로 쓰인다.

 

 

1. DHCP Overview

___________________

 

DHCP enables you to provide network-related information to client systems through

a centrally located server system.

 

DHCP evolved from the bootstrap protocol(BOOTP). DHCP provides the following

enhanced functionality:

 

(1). Network Configuration for client        //information for client

- IP Address

- Boot Server IP Adress

- DNS Server, router, NTP Server's IP Address

 

(2). Lease Periods     // 사용 기간

(3). Routers can be configured to act as a BOOTP relay agent.

(4). Support is available for clients that need to boot over a network, effectively

     replacing the need for using the Reverse Address Resolution Protocol (RARP)

     and the bootparams file.

 

 

[참고] DHCP (Dynamic Host Configuration Protocol)

 

DHCP[디에이치씨피] 네트웍 관리자들이 조직 내의 네트웍 상에서 IP 주소를 중앙에서

관리하고 할당해줄 수 있도록 해주는 프로토콜이다. 인터넷의 TCP/IP 프로토콜에서는, 각

컴퓨터들이 고유한 IP 주소를 가져야만 인터넷에 접속할 수 있다. 조직에서 컴퓨터 사용

자들이 인터넷에 접속할 때, IP 주소는 각 컴퓨터에 반드시 할당되어야만 한다. DHCP를

사용하지 않는 경우에는, 각 컴퓨터마다 IP 주소가 수작업으로 입력되어야만 하며, 만약

컴퓨터가 네트웍의 다른 부분에 속한 장소로 이동되면 IP 주소를 새로이 입력해야 한다.

DHCP는 네트웍 관리자가 중앙에서 IP 주소를 관리하고 할당하며, 컴퓨터가 네트웍의 다른

장소에 접속되었을 때 자동으로 새로운 IP 주소를 보내줄 수 있게 해준다.

 

DHCP는 주어진 IP 주소가 일정한 시간동안만 그 컴퓨터에 유효하도록 하는 "임대" 개념을

사용한다. 임대시간은 사용자가 특정한 장소에서 얼마나 오랫동안 인터넷 접속이 필요할

것인지에 따라 달라질 수 있다. DHCP는 사용자들이 자주 바뀌는 학교와 같은 환경에서

특히 유용하다. DHCP는 사용 가능한 IP 주소의 개수보다 더 많은 컴퓨터가 있는 경우에도

IP 주소의 임대시간을 짧게 함으로써 네트웍을 동적으로 재구성할 수 있다.

 

DHCP는 영구적인 IP 주소를 필요로 하는 웹서버에 대해서는 정적인 주소를 제공한다.

 

DHCP는 네트웍 IP 관리 프로토콜인 BOOTP의 대안으로 사용된다. DHCP가 더욱 진보된 프로

토콜이지만, 두 개의 프로토콜 모두 일반적으로 사용된다. 어떤 조직에서는 두 개의 프로

토콜 모두를 사용하지만, 동일한 조직에서 그것을 언제, 어떻게 사용할지를 이해하는 것이

무엇보다 중요하다. 윈도우NT와 같은 몇몇 운영체계에는 DHCP 서버가 딸려 나온다. DHCP

또는 BOOTP 클라이언트는 네트웍이 구성될 수 있도록 각 컴퓨터에 위치하는 프로그램이다.

 

 

[참고] BOOTP (Bootstrap Protocol, 초기 적재 통신 규약)

 

BOOTP는 네트웍 사용자가 자동으로 구성되고(IP 주소를 받게), 사용자의 간여 없이도 부

트되는 운영체계를 가지고 있게 해주는 프로토콜이다. X 터미널 등과 같이 하드디스크를

갖지 않은 장치의 설정 정보를 자동적으로 할당, 관리하기 위해서 개발되었다. 네트웍 관

리자에 의해 관리되는 BOOTP 서버는, 일정 시간동안 IP 주소를 자동으로 할당한다.

 

BOOTP는 좀더 진보된 네트웍 관리 프로토콜인 DHCP의 기반이 된다. BOOTP는 공식적으로는

RFC 951에 설명되어 있다.

 

 

 

 

 

2. DHCP Process Principle

______________________________

 

 

 

(1). DHCP Server & DHCP Client Process

 

---------------------------------------------

    |                             |

DHCP Server                   DHCP Client

 

 

<DHCP Server>             <DHCP Client>

in.dhcpd(67)               dhcpagent(68)

     |       DHCPDISCOVER        |

     | <-----------------------  |

     |                           |

     |     <-ARP request->       |

     |                           |

     |       DHCPOFFER           |

     |  -----------------------> |

     |       DHCPREQUEST         |

     |  <----------------------- |

     |       DHCPACK             |

     |  -----------------------> |

     |                           |

 

[참고] VMWare DHCP Server 동작시 IP 할당

 

DHCP 클라이언트가 부팅할때 DHCP 서버와 연동하는 동작과정을 살펴보면 다음과 같다.

(a). DHCP 클라이언트는 부팅하면서 현재 네트워크 안에 DHCP 서버가 있는지를 찾기 위해

     DHCPDISCOVER 메시지를 같은 서브넷에 있는 모든 시스템으로 브로드캐스트한다.

(b). DHCP 클라이언트로 부터 메시지를 받은 서버에서는 ARP 브로드캐스팅을 통해서 클라

     이언트에 제공할 IP주소를 선택한 후 네트워크 서비스 정보를 담은 DHCPOFFER 메시지

     를 전송한다.

(c). 서버로 부터 DHCPOFFER 메시지를 받은 클라이언트는 메시지에 포함되어 있는 IP 주소

     와 서비스 정보를 이용하여 네트워크 설정을 한 후, DHCP 서버에 사용 의사를 알리는

     DHCPREQUEST 메시지를 보내게 된다.

(d). DHCPREQUEST 메시지를 수신한 서버는 DHCPACK 메시지를 통해 사용 허가를 해주게 되

     고, 클라이언트는 ping 명령어를 이용하여 현재 할당받은 IP 주소를 이미 사용하고

     있는 다른 시스템이 있는지 확인한 후에 네트워크 설정을 마무리하게 된다.

 

 

 

(2). DHCP Server & BOOTP Relay & DHCP Client

 

DHCP Server ------------ Router--------------------

                                  |            |

                             BOOTP Relay  DHCP Client

                             Server

 

 

<DHCP Server>         <BOOTP Relay>          <DHCP Client>

     |                      |     DHCPDISCOVER     |

     |                      | <------------------- |

     |    DHCPDISCOVER      |                      |

     | <------------------- |                      |

     |    DHCPOFFER         |                      |

     | -------------------> | -------------------> |

     |                      |     DHCPREQUEST      |

     | <------------------- | <------------------- |

     |    DHCPACK           |                      |

     | -------------------> | -------------------> |

     |                      |                      |

 

[참고] 일반 가정에서의 DHCP 서버가 존재하지 않은 이유

 

DHCP 서버에 BOOT Relay 서버가 존재하는 경우에 동작 방식도 없는 경우와 흡사하게 동작

한다. 중간에 BOOT Relay 서버가 DHCP 서버의 역할을 중계하게 된다.

 

 

 

 

 

3. DHCP Server/Client Function

__________________________________

 

(1). DHCP Client Function

 

- Sufficient information to properly configure the network interface

        - IP Address

        - Netmask

 

- Parameters needed by system-level and application-level software

        - Boot Server Information

        - Router Address

        - Configuration Server

 

 

(2). dhcpagent process

- Constructs and sends packets

- Listens for responses from servers

- Caches the configuration information received

- Releases or renews leases

- Configures the interfaces with sufficient information to enable

  communications with the network through the interface

 

 

(3). DHCP Server Function

 

- Corresponding Information Sending

- "2. DHCP Process Principle Reference"

 

 

 

 

 

4. DHCP Startup Script

___________________________

 

부팅시에 /etc/rd3.d/S34dhcp 시작스크립트에 의해서 in.dhcpd 데몬이 뜨게 된다. 이 경우

/etc/inet/dhcpsvc.conf 설정파일이 있어야만 in.dhcpd 데몬이 뜨게 된다.

 

- /etc/init.d/dhcp stop/start      (in.dhcpd)

- /etc/init.d/dhcpagent stop/start (dhcpagent)

 

 

 

 

 

5. DHCP Client Configuration

________________________________

 

 

# man ifconfig

.....

     dhcp  This option is an alias for option auto-dhcp

 

     auto-dhcp

           Use DHCP to automatically acquire an address for  this

           interface.  This  option  has  a completely equivalent

           alias called dhcp.

 

           primary

                 Defines the interface as the primary. The inter-

                 face  is  defined  as  the preferred one for the

                 delivery of client-wide configuration data. Only

                 one  interface  can  be the primary at any given

                 time.  If  another  interface  is   subsequently

                 selected  as the primary, it replaces the previ-

                 ous one. Nominating an interface as the  primary

                 one  will  not  have  much significance once the

                 client work station has booted, as many applica-

                 tions will already have started and been config-

                 ured with data read from  the  previous  primary

                 interface.

 

           drop  Remove the specified interface  from  DHCP  con-

                 trol.  Additionally,  set the IP address to zero

                 and mark the interface as "down".

 

           extend

                 Attempt to extend the lease on  the  interface's

                 IPv4 address. This is not required, as the agent

                 will automatically extend the lease well  before

                 it expires

 

           inform

                 Obtain  network  configuration  parameters  from

                 DHCP without obtaining a lease on an IP address.

                 This is useful in situations where an IP address

                 is obtained through mechanisms other than DHCP.

 

           ping  Check whether the interface given is under  DHCP

                 control,  which  means  that  the  interface  is

                 managed by the DHCP agent and is  working  prop-

                 erly.  An  exit  status of 0 means success. This

                 subcommand has no meaning when the named  inter-

                 face represents more than one interface.

 

           release

                 Relinquish the IPv4 address  on  the  interface,

                 and mark the interface as "down."

 

           start Start DHCP on the interface.

 

           status

                 Display the DHCP  configuration  status  of  the

                 interface.

 

DHCP 클라이언트를 설정하는 방법은 (a)ifconfig 명령어를 사용하여 현재 수행하는 방법

과 (b)/etc/dhcp.XXn 파일을 사용하여 부팅시에 적정되도록 할 수 있다. /etc/dhcp.XXn

파일의 내용은 필요가 없다. 파일의 이름만 존재하면 된다.

 

(1). DHCP 클라이언트 현재 설정

Current Setting

# ifconfig hme0 dhcp

 

 

(2). DHCP 클라이언트 부팅시에 적용 설정

Configuration at Boot

# touch /etc/dhcp.hme0 (/etc/hostname.hme0)

# reboot

 

[참고] ifconfig hme0 dhcp CMD

# ifconfig hme0 dhcp start

# ifconfig hme0 dhcp inform

# ifconfig hme0 dhcp extend

# ifconfig hme0 dhcp release (> ipconfig /renew, # ifconfig hme0 dhcp)

# ifconfig hme0 dhcp drop (/etc/dhcp/hme0.dhc)

# ifconfig hme0 dhcp status

 

(ifconfig hme0 dhcp start)

# ifconfig pcn0 dhcp

# ifconfig pcn0 dhcp start

 

(ifconfig hme0 dhcp inform)

Obtain  network  configuration  parameters  from

DHCP without obtaining a lease on an IP address.

This is useful in situations where an IP address

is obtained through mechanisms other than DHCP.

 

(ifconfig hme0 dhcp extend)

Attempt to extend the lease on  the  interface's

IPv4 address. This is not required, as the agent

will automatically extend the lease well  before

it expires

 

<DHCP Server>             <DHCP Client>

in.dhcpd(67)               dhcpagent(68)

     |                           |

     |    IP(Lease Time:5)     |

     | ----------------------->  | ---

     |                           |  A

     |                           |  |

     |         Extend            |  | 5

     | <-----------------------  |  |  ---

     |                           |  V   A

     |                           | ---  |

     |                           |      | 5

     |                           |      |

     |                           |      V

     |                           |     ---

     |                           |

 

(ifconfig hme0 dhcp release)

c:\> ipconfig /renew

# ifconfig pcn0 dhcp release

# ifconfig pcn0 dhcp start

 

(ifconfig hme0 dhcp drop)

# ifconfig pcn0 dhcp drop

   (현재 IP 설정) ------> /etc/dhcp/hme0.dhc (현재 IP 설정)

 

DHCP Client 부팅 -----> DHCP Server IP 정보 받지 않음

                        /etc/dhcp/hme0.dhc 파일의 설정을 통해 설정

 

(ifconfig hme0 dhcp status)

# ifconfig pcn0 dhcp status

 

 

 

 

 

6. DHCP Server

____________________

 

DHCP 서버가 제공해 주는 정보는 크게 2가지로 구분할 수 있다. (a)IP에 관련한 정보나

(b)시스템 레벨이나 프로그램 레벨에서 필요한 부가적인 인자 값들이다.

 

- IP에 관련한 설정 정보 (/var/dhcp/dhcp_network)

- 부가적인 설정 정보    (/var/dhcp/dhcptab)

 

 

(1). DHCP Server Database File

- dhcp_network(Network Number, IP)           // ip와 대역

- dhcptab(Macro, Symbol)                             //부가정보

 

 

 

(2). DHCP Configuration Tools

- dhcpconfig (CLI)

       Solaris 8 버전의 , Solaris 9 버전의 - 설정 방법 다름

- dhcpmgr (GUI)

- pntadm, dhtadm(CLI)

 

[참고] pntadm / dhtadm

pntadm (p:dhcp, nt:network)-> /var/dhcp/dhcp_network

dhtadm (dht:dhcptab       )-> /var/dhcp/dhcptab

 

 

[참고] DHCP Server Unconfiguration

# /etc/init.d/dhcp stop

# dhcpconfig -U -x -h (매뉴얼 페이지 참조, dhcpconfig(1))

 

 

[참고] 현재 설정 확인

# ls -ld /var/dhcp

[ ]  /var/dhcp 디렉토리가 존재하는가?

[ ]  dhcp_network, dhcptab 파일이 존재하는가?

 

 

 

(3). DHCP Server Setting

 

# dhcpmgr &

or

# /usr/sadm/admin/bin/dhcpmgr &

 

- Network Address Admin(pcn0: 172.16.8.1XX)

- Network Address Admin(pcn1: 192.168.10.1XX)

- Network Virtual Interface Add

      /etc/hosts

      /etc/hostname.hme0:1

      /etc/netmasks

 

 

(아이피 할당 )

 

IP 대역 : 172.16.8.XXX ~ 172.16.8.YYY

 

---------

XXX   YYY

---------

100 ~ 104

105 ~ 109

110 ~ 114

115 ~ 119

120 ~ 124

125 ~ 129

130 ~ 134

135 ~ 139

140 ~ 144

145 ~ 149

150 ~ 154

155 ~ 159

160 ~ 164

165 ~ 169

170 ~ 174

175 ~ 179

180 ~ 184

185 ~ 189

190 ~ 195

---------

 

 

DHCP 서버 설정

# dhcpmgr &

--------------------------------------------------------------------------------

서버 설정                                                                    [x] Conigure as DHCP server

 

DHCP Configuration Wizard

        Select data storage format                   [x] Text files

        Configure Data store                                 Path: /var/dhcp(기본값)

        Select hosts nameservice                             /etc/hosts

        Specify lease policy                                 Length of Lease [1] days(기본값)

        Specify DNS domain and servers        DNS Domain: [example.com]

        Specify network address and                  Network Address: [172.16.0.0] (기본값)

               subnetmask                                                   Subnet Mask: [255.255.0.0] (기본값)

        Specify network type and router              Network Type: Local-Area (기본값)

                                                                                   Routing: Use router: 172.16.0.1

        Specify NIS domain and servers        <Next>

        Specify NIS+ domain and servers              <Next>

 

Address Wizard

        Specify the number of IP addresses    Number of IP Addresses: [5]

                                                                                   Commnet: [DHCP Test]

        Specify the server and starting              Managed by Server: [solarisXXX]

               IP address                                                   Starting IP Address: [172.16.8.1XX]

                                                                                   [x] Generate Client Names

                                                                                           Root Name: solarisXXX

        Confirm the IP address list                  <Next>

        Enter client configuration                    <Next>

               information

        Select the lease type                                Lease Type: [x] Dynamic (기본값)

        Review                                                              <Finish>

--------------------------------------------------------------------------------

 

 

 

(4). DHCP Configuration Files

 

Compare to dhcpmgr DB &  /var/dhcp/DB

 

 

 

 

 

7. DHCP Server & Client Practice

___________________________________

 

 

[EX1] DHCP Server / Client Packet Capturing

(1). DHCP Server Configuration

(2). DHCP Client Configuration

 

(DHCP Server)

# /usr/sadm/admin/bin/dhcpmgr &

 

# snoop -d hme0 -o /test/dhcp.pkt

 

(DHCP Client)

# ifconfig hme0 dhcp

# ifconfig -a

 

(DHCP Server)

# snoop -i /tmp/dhcp.pkt | more

# snoop -i /tmp/dhcp.pkt -v > /tmp/dhcp.txt (패킷을 선택한다.)

# vi /tmp/dhcp.txt

 

 

DHCP Server / Client Packet Analyze

------------------------------------------------------------------

ETHER:  ----- Ether Header -----

ETHER:

ETHER:  Packet 133 arrived at 15:56:10.37

ETHER:  Packet size = 342 bytes

ETHER:  Destination = ff:ff:ff:ff:ff:ff, (broadcast)

ETHER:  Source      = 0:c:29:4e:dd:b7,

ETHER:  Ethertype = 0800 (IP)

ETHER:

IP:   ----- IP Header -----

IP:

IP:   Version = 4

IP:   Header length = 20 bytes

IP:   Type of service = 0x00

IP:         xxx. .... = 0 (precedence)

IP:         ...0 .... = normal delay

IP:         .... 0... = normal throughput

IP:         .... .0.. = normal reliability

IP:         .... ..0. = not ECN capable transport

IP:         .... ...0 = no ECN congestion experienced

IP:   Total length = 328 bytes

IP:   Identification = 6

IP:   Flags = 0x4

IP:         .1.. .... = do not fragment

IP:         ..0. .... = last fragment

IP:   Fragment offset = 0 bytes

IP:   Time to live = 255 seconds/hops

IP:   Protocol = 17 (UDP)

IP:   Header checksum = 7a9f

IP:   Source address = 0.0.0.0, OLD-BROADCAST

IP:   Destination address = 255.255.255.255, BROADCAST

IP:   No options

IP:

UDP:  ----- UDP Header -----

UDP:

UDP:  Source port = 68

UDP:  Destination port = 67 (BOOTPS)

UDP:  Length = 308

UDP:  Checksum = 4EE4

UDP:

DHCP: ----- Dynamic Host Configuration Protocol -----

DHCP:

DHCP: Hardware address type (htype) =  1 (Ethernet (10Mb))

DHCP: Hardware address length (hlen) = 6 octets

DHCP: Relay agent hops = 0

DHCP: Transaction ID = 0x3953c664

DHCP: Time since boot = 0 seconds

DHCP: Flags = 0x0000

DHCP: Client address (ciaddr) = 0.0.0.0

DHCP: Your client address (yiaddr) = 0.0.0.0

DHCP: Next server address (siaddr) = 0.0.0.0

DHCP: Relay agent address (giaddr) = 0.0.0.0

DHCP: Client hardware address (chaddr) = 00:0C:29:4E:DD:B7

DHCP:

DHCP: ----- (Options) field options -----

DHCP:

DHCP: Message type = DHCPDISCOVER

DHCP: Maximum DHCP Message Size = 1472 bytes

DHCP: IP Address Lease Time = -1 seconds

DHCP: Client Class Identifier = "SUNW.i86pc"

DHCP: Requested Options:

DHCP:    1 (Subnet Mask)

DHCP:    3 (Router)

DHCP:   12 (Client Hostname)

DHCP:   43 (Vendor Specific Options)

 

ETHER:  ----- Ether Header -----

ETHER:

ETHER:  Packet 148 arrived at 15:56:11.39

ETHER:  Packet size = 371 bytes

ETHER:  Destination = 0:c:29:4e:dd:b7,

ETHER:  Source      = 0:c:29:4a:b2:cd,

ETHER:  Ethertype = 0800 (IP)

ETHER:

IP:   ----- IP Header -----

IP:

IP:   Version = 4

IP:   Header length = 20 bytes

IP:   Type of service = 0x00

IP:         xxx. .... = 0 (precedence)

IP:         ...0 .... = normal delay

IP:         .... 0... = normal throughput

IP:         .... .0.. = normal reliability

IP:         .... ..0. = not ECN capable transport

IP:         .... ...0 = no ECN congestion experienced

IP:   Total length = 357 bytes

IP:   Identification = 18293

IP:   Flags = 0x4

IP:         .1.. .... = do not fragment

IP:         ..0. .... = last fragment

IP:   Fragment offset = 0 bytes

IP:   Time to live = 255 seconds/hops

IP:   Protocol = 17 (UDP)

IP:   Header checksum = 9c5a

IP:   Source address = 192.168.10.250, nic2

IP:   Destination address = 192.168.10.109, solaris254-109

IP:   No options

IP:

UDP:  ----- UDP Header -----

UDP:

UDP:  Source port = 67

UDP:  Destination port = 68 (BOOTPC)

UDP:  Length = 337

UDP:  Checksum = 5EE8

UDP:

DHCP: ----- Dynamic Host Configuration Protocol -----

DHCP:

DHCP: Hardware address type (htype) =  1 (Ethernet (10Mb))

DHCP: Hardware address length (hlen) = 6 octets

DHCP: Relay agent hops = 0

DHCP: Transaction ID = 0x3953c664

DHCP: Time since boot = 0 seconds

DHCP: Flags = 0x0000

DHCP: Client address (ciaddr) = 0.0.0.0

DHCP: Your client address (yiaddr) = 192.168.10.109

DHCP: Next server address (siaddr) = 0.0.0.0

DHCP: Relay agent address (giaddr) = 0.0.0.0

DHCP: Client hardware address (chaddr) = 00:0C:29:4E:DD:B7

DHCP:

DHCP: ----- (Options) field options -----

DHCP:

DHCP: Message type = DHCPOFFER

DHCP: DHCP Server Identifier = 192.168.10.250

DHCP: UTC Time Offset = 32400 seconds

DHCP: RFC868 Time Servers at = 172.16.8.254

DHCP: IP Address Lease Time = 86400 seconds

DHCP: DNS Domain Name = example.com

DHCP: DNS Servers at = 172.16.8.254

DHCP: DNS Servers at = 172.16.8.252

DHCP: DNS Servers at = 168.126.63.1

DHCP: Broadcast Address = 192.168.10.255

DHCP: Router at = 192.168.10.2

DHCP: Subnet Mask = 255.255.255.0

DHCP: Client Hostname = solaris254-109

 

ETHER:  ----- Ether Header -----

ETHER:

ETHER:  Packet 163 arrived at 15:56:13.37

ETHER:  Packet size = 342 bytes

ETHER:  Destination = ff:ff:ff:ff:ff:ff, (broadcast)

ETHER:  Source      = 0:c:29:4e:dd:b7,

ETHER:  Ethertype = 0800 (IP)

ETHER:

IP:   ----- IP Header -----

IP:

IP:   Version = 4

IP:   Header length = 20 bytes

IP:   Type of service = 0x00

IP:         xxx. .... = 0 (precedence)

IP:         ...0 .... = normal delay

IP:         .... 0... = normal throughput

IP:         .... .0.. = normal reliability

IP:         .... ..0. = not ECN capable transport

IP:         .... ...0 = no ECN congestion experienced

IP:   Total length = 328 bytes

IP:   Identification = 7

IP:   Flags = 0x4

IP:         .1.. .... = do not fragment

IP:         ..0. .... = last fragment

IP:   Fragment offset = 0 bytes

IP:   Time to live = 255 seconds/hops

IP:   Protocol = 17 (UDP)

IP:   Header checksum = 7a9e

IP:   Source address = 0.0.0.0, OLD-BROADCAST

IP:   Destination address = 255.255.255.255, BROADCAST

IP:   No options

IP:

UDP:  ----- UDP Header -----

UDP:

UDP:  Source port = 68

UDP:  Destination port = 67 (BOOTPS)

UDP:  Length = 308

UDP:  Checksum = 20EF

UDP:

DHCP: ----- Dynamic Host Configuration Protocol -----

DHCP:

DHCP: Hardware address type (htype) =  1 (Ethernet (10Mb))

DHCP: Hardware address length (hlen) = 6 octets

DHCP: Relay agent hops = 0

DHCP: Transaction ID = 0x9aa14ebb

DHCP: Time since boot = 0 seconds

DHCP: Flags = 0x0000

DHCP: Client address (ciaddr) = 0.0.0.0

DHCP: Your client address (yiaddr) = 0.0.0.0

DHCP: Next server address (siaddr) = 0.0.0.0

DHCP: Relay agent address (giaddr) = 0.0.0.0

DHCP: Client hardware address (chaddr) = 00:0C:29:4E:DD:B7

DHCP:

DHCP: ----- (Options) field options -----

DHCP:

DHCP: Message type = DHCPREQUEST

DHCP: IP Address Lease Time = 86400 seconds

DHCP: Maximum DHCP Message Size = 1472 bytes

DHCP: Requested IP Address = 192.168.10.109

DHCP: DHCP Server Identifier = 192.168.10.250

DHCP: Client Class Identifier = "SUNW.i86pc"

DHCP: Requested Options:

DHCP:    1 (Subnet Mask)

DHCP:    3 (Router)

DHCP:   12 (Client Hostname)

DHCP:   43 (Vendor Specific Options)

 

ETHER:  ----- Ether Header -----

ETHER:

ETHER:  Packet 165 arrived at 15:56:13.38

ETHER:  Packet size = 371 bytes

ETHER:  Destination = 0:c:29:4e:dd:b7,

ETHER:  Source      = 0:c:29:4a:b2:cd,

ETHER:  Ethertype = 0800 (IP)

ETHER:

IP:   ----- IP Header -----

IP:

IP:   Version = 4

IP:   Header length = 20 bytes

IP:   Type of service = 0x00

IP:         xxx. .... = 0 (precedence)

IP:         ...0 .... = normal delay

IP:         .... 0... = normal throughput

IP:         .... .0.. = normal reliability

IP:         .... ..0. = not ECN capable transport

IP:         .... ...0 = no ECN congestion experienced

IP:   Total length = 357 bytes

IP:   Identification = 20283

IP:   Flags = 0x4

IP:         .1.. .... = do not fragment

IP:         ..0. .... = last fragment

IP:   Fragment offset = 0 bytes

IP:   Time to live = 255 seconds/hops

IP:   Protocol = 17 (UDP)

IP:   Header checksum = 9494

IP:   Source address = 192.168.10.250, nic2

IP:   Destination address = 192.168.10.109, solaris254-109

IP:   No options

IP:

UDP:  ----- UDP Header -----

UDP:

UDP:  Source port = 67

UDP:  Destination port = 68 (BOOTPC)

UDP:  Length = 337

UDP:  Checksum = 7243

UDP:

DHCP: ----- Dynamic Host Configuration Protocol -----

DHCP:

DHCP: Hardware address type (htype) =  1 (Ethernet (10Mb))

DHCP: Hardware address length (hlen) = 6 octets

DHCP: Relay agent hops = 0

DHCP: Transaction ID = 0x9aa14ebb

DHCP: Time since boot = 0 seconds

DHCP: Flags = 0x0000

DHCP: Client address (ciaddr) = 0.0.0.0

DHCP: Your client address (yiaddr) = 192.168.10.109

DHCP: Next server address (siaddr) = 0.0.0.0

DHCP: Relay agent address (giaddr) = 0.0.0.0

DHCP: Client hardware address (chaddr) = 00:0C:29:4E:DD:B7

DHCP:

DHCP: ----- (Options) field options -----

DHCP:

DHCP: Message type = DHCPACK

DHCP: DHCP Server Identifier = 192.168.10.250

DHCP: UTC Time Offset = 32400 seconds

DHCP: RFC868 Time Servers at = 172.16.8.254

DHCP: IP Address Lease Time = 86400 seconds

DHCP: DNS Domain Name = example.com

DHCP: DNS Servers at = 172.16.8.254

DHCP: DNS Servers at = 172.16.8.252

DHCP: DNS Servers at = 168.126.63.1

DHCP: Broadcast Address = 192.168.10.255

DHCP: Router at = 192.168.10.2

DHCP: Subnet Mask = 255.255.255.0

DHCP: Client Hostname = solaris254-109

----------------------------------------------------------------   

 

 

 

 

 

 

[EX2] NIC 추가

 

새로운 NIC를 추가하지 않고 가상 NIC를 구성하여 192.168.8.XXX으로 추가하여 작업 하는

것으로 가정한다.(부팅시의 작업에 대해서는 정의하지 않고 현재 작업으로만 설정한다.)

 

(1). Virtual NIC 추가

# ifconfig -a          

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 172.16.8.254 netmask ffff0000 broadcast 172.16.255.255

        ether 0:c:29:18:75:5e

 

# ifconfig pcn0:1 plumb up

# ifconfig pcn0:1 192.168.8.254 netmask 255.255.255.0 broadcast +

 

 

(2). DHCP Manager 설정

# /usr/sadm/admin/bin/dhcpmgr &

 

(a). EDIT

(b). Network Wizard

     - Network Address : 192.168.8.0

     - Netmask         : 255.255.255.0

    

     - Network Type    : LAN

     - Routing         : Use router (192.168.8.XXX)

 

     - NIC Domain      : Next(Skip)

     - NIC+ Domain     : Next(Skip)

 

     - Verification    : Finish

(c). Address Wizard

     - Number of IP Addresses : 10

    

     - Starting IP Address    : 192.168.8.100

     - Generate Client Hostnames : Check

     - Next > Next > Next > Finish

 

 

 

 

 

8. pntadm, dhtadm 명령어를 사용한 DHCP 서버 관리

_________________________________________________

 

pntadm (p:dhcp, nt:network)-> /var/dhcp/dhcp_network

dhtadm (dht:dhcptab       )-> /var/dhcp/dhcptab

 

서버의 설정이 있다면 삭제하고 다시 설정 해야 한다.

 

# dhcpconfig -U -x -h

 

2008. 9. 2. 18:55

DNS Server Management

 

 

 

                DNS Server Management

 

 

 

 

 

[참고] 실무에서 많이 사용되고 있는 서비스

-> DNS, FTP, MAIL, WEB(WAS), DB Server

 

 

 

1. DNS 서버 설정 파일들

 

/etc/named.conf                DNS Configuration File

 

/var/named/exampleXXX.zone     DNS Forward Lookup Zone File

/var/named/exampleXXX.rev      DNS Reverse Loookup Zone File

/var/named/localhost.rev       DNS Localhost Reverse Lookup Zone File

/var/named/named.root          DNS Root Domain Lookup File

 

/etc/nsswitch.conf             Name Service Switching Configuration File

/etc/resolv.conf               DNS Client Resolver File     

 

 

 

(1). /etc/named.conf 파일 해석

 

/etc/named.conf 파일을 in.named 데몬이 읽어 들이는 DNS 서버의 주 설정 파일이다.

 

BIND 8.X 이후 버전에서는 이전의 버전에 비해 새로운 설정 파일을 사용한다.

■ 이전 설정 파일  : /etc/named.boot (BIND 4.x)

■ 새로운 설정 파일: /etc/named.conf (BIND 8.x, BIND 9.x)

 

BIND 4.9.x 버전의 /etc/named.boot 파일을 /etc/named.conf 파일로 변환하기 위해서는

/usr/sbin/named-bootconf 스크립트를 사용하면 된다.

 

/etc/named.conf 파일에서 사용되는 것은 다음과 같다.

- Root Server가 등록되어진 파일 위치 지정

- Primary / Secondary / Caching-Only Server 지정 및 DB 파일 지정

- DNS 서버의 zones of Authority 지정

- 서버용 파일들의 위치 지정

- 도메인에 대한 보안 설정

- 로그 기록 정의 지정

- zone 옵션 지정

 

 

# cat /etc/named.conf

-----------------------------------------------------------------------

options {

    directory "/var/named";

    allow-transfer { 172.16.8.154; 172.16.7.154; };//마스터와 슬레이브와의 관계

    allow-query    { 172.16.8.0/16; };//나에게 쿼리를 날릴 수 있는 대역 지정

};

 

acl "nets" {

    { 172.16.0.0/16; 172.15.0.0/16; };

};

 

zone "." IN {

    type hint;

    file "named.root";

};

 

zone "localhost" IN {

    type master;

    file "localhost.zone";

};

 

zone "0.0.127.in-addr.arpa" IN {

    type master;

    file "localhost.rev";

};

 

zone "example.com" IN {

    type master;

    file "example.zone";

    allow-transfer { 172.16.8.154; };

    allow-query    { "nets"; };

};

 

zone "8.16.172.in-addr.arpa" IN {

    type master;

    file "example.rev";

};

 

zone "daum.net" IN {

    type master;

    file "db1/daum.zone";

};

 

zone "7.16.172.in-addr.arpa" IN {

    type master;

    file "db/daum.rev";

};

zone "daum.net" IN {

    type slave;

masters { 172.16.8.254;};

    file "db1/daum.zone";

};

 

-----------------------------------------------------------------------

 

zone block 에 정의된 것을 순서대로 나열하면 다음과 같다.

- Hint Server(캐쉬 네임서버 지정)

- Reverse Localhost(로컬네트워크 리버스 도메인 지정)

- Forward Primary Name Server(네임서버가 위치하는 곳의 포워드 도메인 지정)

- Reverse Primary Name Server(네임서버가 위치하는 곳의 리버스 도메인 지정)

 

 

 

(1-1). 각 도메인 설정 파일들의 위치 지정

 

-----------------------------------------------------------------------

options {

    directory "/var/named";

};

-----------------------------------------------------------------------

 

각 도메인의 설정파일들이 위치할 디렉토리를 정의한다. 보통 /var/named 디렉토리를 많이

지정한다. 하지만 보안상의 이유로 기본 위치를 지정하지 않고 /named와 같이 다른 디렉토

리를 지정하는 경우도 많다. 이 경우의 대부분은 chroot 환경을 구성하는 경우이다.

 

이 파일의 전반적인 부분에서 "file" 다음에 나오는 모든 파일은 /var/named 디렉토리 하

위에 존재하게 된다. 경우에 따라서 다음과 같이 지정하는 경우도 존재한다.

 

zone "example254.com" IN {

           type master;

           file "zone1/example254.zone";

};

 

위와 같은 경우 포워드 존 파일의 위치는 /var/named/zone1/example254.zone 파일이 된다.

여러개의 도메인을 관리하는 도메인 위임 서버(웹 호스팅 업체)에서는 위와 같은 경우의

선언이 흔하게 된다.

 

 

[참고] options statemnet, directory element

 

     options

           Controls global server configuration options and  sets

           defaults for other statements.

 

     directory

           The working directory of the server.  Any non-absolute

           pathnames  in  the configuration file will be taken as

           relative to this directory.  The default location  for

           most  server  output files, for example, named.run, is

           this  directory.  If a directory is not specified, the

           working  directory defaults to ".", the directory from

           which the server was started.  The directory specified

           should be an absolute path.

 

 

 

(1-2). ACL 설정

 

-----------------------------------------------------------------------

acl "nets" {

    { 172.16.0.0/16; 172.15.0.0/16; };

};

-----------------------------------------------------------------------

 

allow-transfer, allow-query 같은 지시자를 사용해서 설정할때 사용하기 위한 ACL(Access

Control List) 설정할 사용한다.

 

 

[참고] acl statement allow-transfer element

 

     acl   Defines a named IP address matching list,  for  access

           control and other uses.

 

           allow-transfer

                 Specifies which hosts  are  allowed  to  receive

                 zone  transfers from the server.  allow-transfer

                 may also be specified in the zone statement,  in

                 which  case  it  overrides  the  options  allow-

                 transfer  statement.   If  not  specified,   the

                 default is to allow transfers from all hosts.

 

 

 

(1-3). 캐쉬 네임서버와 로컬네트워크 설정

 

-----------------------------------------------------------------------

 

zone "." IN {

    type hint;

    file "named.root";

};

 

zone "0.0.127.in-addr.arpa" IN {

    type master;

    file "localhost.rev";

};

 

-----------------------------------------------------------------------

 

캐쉬 네임 서버와 로컬 네트워크 설정은 반드시 있어야 하는 부분이다. 캐쉬 네임서버는

자신의 DB 정보(Forward Zone File, Reverse Zone File)이 없는 경우에 참고할 Root Name

Server의 위치를 지정하거나 로컬호스트에 대한 지정을 하는 부분이다.

 

[참고] zone statement, hint / master elements

 

     zone  Defines a zone.

 

     hint  The initial set of  root  name  servers  is  specified

           using  a hint zone. When the server starts up, it uses

           the root hints to find a root name server and get  the

           most recent list of root name servers.

 

   master  The server has a master copy of the data for the  zone

           and  will be able to provide authoritative answers for

           it.

 

 

 

(1-4). 포워드 도메인 / 리버스 도메인 파일 설정

 

Forward / Reverse Lookup Zone Files 설정을 한다. 아래 예제는 example.com 도메인에 대

해서 Master DNS 서버로 동작하고 Forward Lookup Zone 파일은 /var/named/example.zone

파일임을 나타낸다. 또한 "nets" 네트워크에 대해서만 Zone 파일들이 전송할수 있도록 한

정이 되어 있다.(Master Server에서 Slave Server로)

 

-----------------------------------------------------------------------

zone "example.com" IN {

    type master;

    file "example.zone";

    allow-transfer { "nets"; };

    allow-query { "nets"; };

};

 

zone "8.168.192.in-addr.arpa" IN {

    type master;

    file "example.rev";

};

-----------------------------------------------------------------------

 

 

 

(2). /var/named/named.root 파일 해석

 

named.root 파일은 ftp.internic.net 이나 rs.internic.net 사이트에서 FTP 접속하여

을 수 있다. 접속하여 파일을 받을수 있는 디렉토리는 /domain 디렉토리에 존재한다.

 

다음은 ftp.internic.net 사이트에서 받은 named.root 파일의 내용이다.

 

# cat /var/named/named.root

-----------------------------------------------------------------------

.                        3600000  IN  NS    A.ROOT-SERVERS.NET.

A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4

.                        3600000      NS    B.ROOT-SERVERS.NET.

B.ROOT-SERVERS.NET.      3600000      A     192.228.79.201

.                        3600000      NS    C.ROOT-SERVERS.NET.

C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12

.                        3600000      NS    D.ROOT-SERVERS.NET.

D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90

.                        3600000      NS    E.ROOT-SERVERS.NET.

E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10

.                        3600000      NS    F.ROOT-SERVERS.NET.

F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241

.                        3600000      NS    G.ROOT-SERVERS.NET.

G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4

.                        3600000      NS    H.ROOT-SERVERS.NET.

H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53

.                        3600000      NS    I.ROOT-SERVERS.NET.

I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17

.                        3600000      NS    J.ROOT-SERVERS.NET.

J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30

.                        3600000      NS    K.ROOT-SERVERS.NET.

K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129

.                        3600000      NS    L.ROOT-SERVERS.NET.

L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12

.                        3600000      NS    M.ROOT-SERVERS.NET.

M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33

-----------------------------------------------------------------------

 

 

하지만 수업을 위해서 변경이 된 파일을 사용할 것이다. 다음은 변경된 파일이다.

 

# cat /var/named/named.root

.                       86400     IN    NS     ns.example.com.

ns.example.com.         86400     IN     A     172.16.8.254

 

 

 

(3). /var/named/exampleXXX.zone 파일 해석

 

Forward-Domain 파일안에는 호스트 이름을 IP에 맵핑시키는 정보가 주로 설정된다. 이 정

보를 설정하기 위해서는 A Record를 사용한다. 이 외에도 SOA, NS, MX, CNAME 등의 Record

를 지정할 수 있다.

 

다음은 /var/named/exampleXXX.zone 파일을 예제이다.

 

# cat /var/named/exampleXXX.zone

-----------------------------------------------------------------------

$TTL 4

$ORIGIN example.com.   //선언이안되어있다면 /etc/named.conf example.com 이 오리지날

@  IN SOA ns.example.com. root.example.com. (

2007051801 ; serial number

3M         ; refresh time

1M         ; retry time

1W         ; expiry day

1D         ; time to live

)

 

example.com.        IN  NS    ns.example.com.

ns.example.com.     IN  A     172.16.8.254

example.com.        IN  NS    ns2.example.com.

ns2.example.com.    IN  A     172.16.8.154

 

;================================================

; Basic Network

;================================================

www                 IN  A     172.16.8.254

www                 IN  A     172.16.8.253

www                 IN  A     172.16.8.252

 

example.com.        IN  MX 10 mail.example.com.

mail                IN  A     172.16.8.254

example.com.        IN  MX 20 mailhost.example.com.

mailhost            IN  A     172.16.8.254

 

ftp                 IN  A     172.16.8.254

 

cname1              IN  A     172.16.8.253

cname2              IN  CNAME cname1

-----------------------------------------------------------------------

 

 

파일을 해석할 때 필요한 정보들에 대해 자세히 알아 보자.

 

(3-1). DNS Zone Files Entry Format

 

(형식)

[Domain]   [TTL]  CLASS  RecordType  Data

 

* [Domain] 부분이 생략되면 오리지널 도메인이 된다. 오리지널 도메인을 찾는 순서는 다

  음과 같다.

  - zone 파일내의 $ORIGIN 값에 지정된 것

  - /etc/named.conf 파일의 포워드 존의 도메인

 

* [TTL] 부분이 생략된면 $TTL 에 의해 지정된 값이 된다. TTL(Time To Live)가 지정되는

  순서는 다음과 같다.

  - 각 엔트리의 TTL 값에 지정된 것

  - $TTL로 지정된 값

  - SOA 지시자의 TTL 필드의 값

 

* CLASS는 현재 다른 것이 없고 IN(Internet)만 존재한다.

* RecoredType에 따라서 첫번째 필드와 마지막 필드가 결정된다.

 

[EX] 다양한 RecordType의 예

example.com.       IN SOA   ns.example.com. root.example.com (Number .....)

                     SOA domain

example.com.       IN NS    ns.example.com.

                     NS - nameserver

ns.example.com.    IN A     172.16.8.254

                     A - address

www.example.com.   IN A     172.16.8.254   

example.com.       IN MX 10 mail.example.com.

172.16.8.254       IN PTR   ns.example.com.

 

[EX] RecordType TEST

# nslookup -q=NS example.com

# nslookup -q=A ns.example.com

# nslookup -q=MX example.com

# nslookup -q=PTR 172.16.8.254

 

 

(3-2). 주석처리(Comment)

- ;       (Window 주석처리)

- #       (Unix 주석처리)

- /* */   (C 주석처리)

- //      (C++ 주석처리)

 

 

 

(3-3). SOA(Start Of Authority) Record

 

(예) SOA Record Type

@  IN SOA ns.example.com. root.example.com. (

2007051801 ; serial number

3H         ; refresh time

1H         ; retry time

1W         ; expiry day

1D         ; time to live

)

 

====== Master ========           ======= Slave ==========

in.named(53)                       in.named(53)

/etc/named.conf                    /etc/named.conf

/var/named/DB                      /var/named/copy DB

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

 

(a). Serial Number

 

    exampleXXX.zone      ---->       exampleXXX.zone

      Serial : 1                        Serial : 1

      Modify

      Serial : 2           >            Serial : ?

      (권장) Serial : 2006122000

 

(b). Refresh Time                     // 동기화타임

    Mater Server        ----->       Slave Server

                       3 hours

      (권장) 12시간, 24시간

 

(c). Retry Time                              // 재시도 타임

    Master Server       --X-->       Slave Server

                       3 hours       Fail

                        ----->

                       1 hours

      (권장) 1시간, 3시간

 

(d). Expire Date                      // 마스터가 죽었을 때 대체 복구 시간

    Master Server                    Slave Server

                        ------>

      Fail              ---X-->

                                      Data(7 Days)

      (권장) 7

 

(e). TTL(Time To Live)

    Server              ------>      Client

      (권장) 1

 

 

 

(3-4). 여러가지 레코드 종류(Record Types)

 

(a). NS Record (Name Server)

example.com.     IN   NS   ns.example.com.

domain                    full domain (nameserver)

ns.example.com.  IN   A    172.16.8.254

nameserver                    ip

 

(b). A Record (Address)

www.example.com. IN   A   172.16.8.254

 

(c). MX Record (Mail Exchange)

example.com.     IN   MX  10  mail1.example.com.

domain                        full domain

mail1            IN   A       172.16.8.254

name                          ip

example.com.     IN   MX  20  mail2.example.com.

mail2            IN   A       172.16.10.254

 

[참고] SPAM 메일서버, 일반 메일 서버 등록 방식

 

(d). CNAME Record (Canonical Name)

www1             IN   A       172.16.8.254

www2             IN   A       172.16.8.254

or

www1             IN   A       172.16.8.254

www2             IN  CNAME    www1

 

(e). PTR Record (Pointer)

254              IN   PTR      www.example.com.

 

 

 

(4) /var/named/exampleXXX.rev 파일 해석

 

Reverse Domain 파일은 주로 IP 주소에 Domain Name 맵핑된 정보가 주로 설정된다.

정을 하기 위해서는 PTR Record를 사용한다. Reverse Domain 파일안에 반드시 등록 되어 있

어야 하는 정의는 자신의 도메인안에 존재하는 DNS 서버에 대한 Reverse Domain이다.

 

# cat /var/named/exampleXXX.rev

-----------------------------------------------------------------------

$TTL 4

$ORIGIN 8.16.172.IN-ADDR.ARPA.

@ 1D IN SOA ns.example.com. root.example.com. (

2007051800 ; serial number

3M         ; refresh time

1M         ; retry time

1W         ; expiry day

1D         ; minimum time

)

 

8.16.172.IN-ADDR.ARPA.  IN  NS    ns.example.com.

254                     IN  PTR   ns.example.com.

-----------------------------------------------------------------------

 

[참고] 리버스 존 파일안에 반드시 정의 되어야 하는 설정

DNS Client                 DNS Server

          --------------->

          <---------------

          --------------->

          <---------------

 

# nslookup www.itbank.co.kr

.....

59.5.100.166 -> 168.126.63.1 DNS C 1.63.126.168.in-addr.arpa. Internet PTR ?

168.126.63.1 -> 59.5.100.166 DNS R 1.63.126.168.in-addr.arpa. Internet PTR kns.kornet.net.

59.5.100.166 -> 168.126.63.1 DNS C www.itbank.co.kr. Internet Addr ?

168.126.63.1 -> 59.5.100.166 DNS R www.itbank.co.kr. Internet Addr 58.185.71.171

.....

 

 

 

(4-1). PTR Record

 

PTR Record Type(Pointer)

254              IN   PTR      www.example.com.

 

[EX] Recored Type 필드

8.16.172.IN-ADDR.ARPA.  IN  NS    ns.example.com.

254                     IN  PTR   ns.example.com.

200                     IN  PTR   solaris200.example.com.

201                     IN  PTR   solaris201.example.com.

202                     IN  PTR   solaris202.example.com.

 

 

[EX] PTR / A Record Type 실습

 

ftp.example.com -> 172.16.8.200

 

# vi /var/named/example254.zone

.....

ftp                     IN  A     172.16.8.200

.....

# vi /var/named/example254.rev

.....

200                     IN  PTR   ftp.example.com.

.....

 

 

 

(5) /var/named/localhost.rev 해석

 

Reverse Loopback Domain 파일은 Reverse Loopback Domain 주소에 대해 Domain Name으로

변환하는 역할을 갖는다. 모든 도메인 서버는 자신의 주소를 master DNS Server 설정이

되어야 한다.

 

형식은 위의 파일과 같다. 해석하는 방법은 같다.

 

# cat /var/named/localhost.rev

-----------------------------------------------------------------------

$TTL 4

@ 1D IN SOA ns.example.com. root.example.com. (

2007051800 ; serial number

3M         ; refresh time

1M         ; retry time

1W         ; expiry day

1D         ; minimum time

)

 

0.0.127.IN-ADDR.ARPA. IN  NS    ns.example.com.

1                     IN  PTR   ns.example.com.

-----------------------------------------------------------------------

 

 

(6). /etc/nsswitch.conf 파일 해석

 

/etc/nsswitch.conf 파일은 이름서비스를 제공하는 서버들의 정보를 얻어 올수 있는 순서

를 정하는 중요한 파일이다.

 

# cat /etc/nsswitch.conf

......

# You must also set up the /etc/resolv.conf file for DNS name

# server lookup.  See resolv.conf(4).

hosts:      files dns

......

 

 

 

(7) /etc/resolv.conf 파일 해석

 

# cat /etc/resolv.conf

domain example.com

search example.com

nameserver 172.16.8.XXX

nameserver 172.16.8.254

 

/etc/resolve.conf 파일안에 정의 될수있는 statements

 

* domain      - 자신의 lcoal domain을 적어 주면된다. domain이 설정되지 않아도 운영

                하는데 아무런 지장이 없다.

                (예) domain example.com

 

* search      - search에 의해 지정된 되메인 부분은 생략할 수 있도록 하는 것이다. 만

                약 "search example.com"로 지정되어 있다면 example.com의 서브 도메인

                들은 그냥 호스트이름만으로도 찾을 수 있게 된다.

                예를 들어 www.example.com를 찾을려고 한다면 www 만으로도 사용이 가능

                하다.

                (예) search example.com

                (사용예) # ping www

                         # nslookup www

 

* nameserver  - DNS 서버를 지칭한다. 일반적으로 3개까지 지정할수 있으면 그 이상 정의

                된것은 인식이 되지 않는다. 회사내에서는 1차 DNS 서버와 2차 DNS 서버

                를 정의하면 된다.

                (예)     nameserver 168.126.63.1

                                      nameserver 168.126.63.2

                                      nameserver 168.126.63.3

 

 

[EX] /etc/resolv.conf 해석 순서 확인

 

# cat /etc/resolv.conf

nameserver 172.16.8.XXX

 

 

http://www.daum.net -> /etc/hosts -> DNS(172.16.8.XXX) -> .(Nameless Root)

 

 

# nslookup www.daum.net      

Server:  ns.solarisXXX.example.com

Address:  172.16.8.XXX

 

*** ns.solarisXXX.example.com can't find www.daum.net: Server failed  <----- 에러 메세지 확인

 

# vi /etc/resolv.conf

nameserver 168.126.63.1   <----- 정보 라인 추가

nameserver 172.16.8.XXX

 

# nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.213, 211.115.77.212, 211.115.115.212, 211.32.117.30

          211.115.115.211, 222.231.51.78, 211.115.77.214, 222.231.51.40

Aliases:  www.daum.net

 

# vi /etc/resolv.conf

nameserver 172.16.8.XXX   <----+---- 정의 순서 교체

nameserver 168.126.63.1   <----+

 

# pkill -9 in.named

# pgrep -lf in.named

(in.named 데몬 종료 여부 확인)

 

# nslookup www.daum.net

( 15초정도의 Time Interval 걸린다.)

*** Can't find server name for address 172.16.8.20X: No response from server

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.115.212, 211.32.117.30, 222.231.51.77, 211.115.77.213

          211.115.77.214, 211.115.77.211, 222.231.51.78, 222.231.51.40

Aliases:  www.daum.net

 

# in.named

# nslookup www.daum.net

-> 정보 요청이 되지 않는다.

 

 

 

 

 

 

               DNS Server Administrator Role

 

 

 

 

DNS Server Admin. Role List

도메인 등록 (Domain Insert)

서브 도메인 위임(Sub Domain Configuration = Domain Delegation)

마스터 / 슬레이브 DNS 서버 (Master Server, Slave Server)

캐싱 / 포워딩 DNS 서버 (Caching Olny Server, Forwarding Server)

DNS 부하 분산 (DNS Load Balancing = Web Load Balancing )

동적 업데이트 설정(Dynamic Updates)

보안 설정 (Security / ACL(Access Control List))

 

 

 

(1). 도메인 등록(Domain Insert)

 

DNS 서버 관리자에게 다음과 같은 도메인에 대한 IP 설정 요청이 들어 왔다고 해보자.

 

도메인에 IP 주소 등록 요청 예

- 172.16.8.254   ===>   www.solaris254.example.com

- 172.16.8.254   ===>   mail.solaris254.example.com

- 172.16.8.254   ===>   ftp.solaris254.example.com

 

Forward Domain 파일에 등록

Forward Zone File (example254.zone)

 

# vi /var/named/example254.zone

.....

www          IN   A      172.16.8.254

             IN   MX 10  mail

mail         IN   A      172.16.8.254

ftp          IN   A      172.16.8.254

.....

 

# vi /var/named/example254.rev

254          IN   PTR     www.solaris254.example.com.

254          IN   PTR     ftp.solaris254.example.com.  (X)

254          IN   PTR     mail.solaris254.example.com. (X)

//중복 정보 x

 

(EX1) 도메인 등록

 

■ 도메인에 IP 주소 등록 요청 예

- 172.16.8.XXX   ===>   cafe.solarisXXX.example.com

 

# cd /var/named

# vi exampleXXX.zone

......

;================================

; Domain Configuration for Test

;================================

[수정전]

test         IN   A   172.16.8.XXX

[수정후]

test         IN   A   172.16.8.XXX

cafe         IN   A   172.16.8.XXX    <----- 라인 추가

......

 

# pkill -1 in.named

# nslookup cafe.solarisXXX.example.com

(출력 정보 확인)

 

 

 

 

 

Client -------> DNS(192.168.10.XXX)

(Windows XP)   /var/named/exampleXXX.zone

                www     IN  A  192.168.10.XXX

       -----------------------------------------> Apache(192.168.10.XXX)

                                                  httpd(80, httpd.conf)

http://www.solarisXXX.example.com

 

 

■ Apache 설정

(주 설정 파일 설정)

# cd /etc/apache

# cp httpd.conf-example httpd.conf

 

(index.html 파일 생성)

# cd /var/apache/htdocs

# cp /etc/passwd index.html

 

(Apache 서버 기동)

# /etc/init.d/apache restart

# pgrep -lf httpd

-> 떠 있는 httpd 데몬들 확인

 

(DNS 설정 변경)

# cd /var/named

# vi exampleXXX.zone

[수정전]

;www          IN   A       172.16.8.XXX

www           IN   A       192.168.10.1

www           IN   A       192.168.10.2

www           IN   A       192.168.10.3

[수정후]

www           IN   A       192.168.10.XXX    <----- 라인 추가

;www          IN   A       172.16.8.XXX     

;www          IN   A       192.168.10.1      <----- 주석 처리

;www          IN   A       192.168.10.2      <----- 주석 처리

;www          IN   A       192.168.10.3      <----- 주석 처리

 

# pkill -1 in.named

# nslookup www.solarisXXX.example.com

 

(Window Server에서 확인)

네트워크 환경 > 로컬영역 연결 > 속성 > TCP/IP > DNS 서버 정보(192.168.10.XXX)

 

웹브라우저 에서 확인

http://www.solarisXXX.example.com

 

=> DNS 서버 정보 복원(Windows 서버)

 

 

 

(EX2) 부하분산(Load Balancing)

 

웹 부하 분산을 시킬때 DNS 서버를 사용할 수도 있다. 하지만 이것은 정확한 부하 분산이

라고 말할수는 없다. 이런경우 L4 스위치를 사용하는 경우와는 조금의 차이점이 존재한다.

 

         예: www.daum.net

        +----- www(IP1)      +---- NAS

        |                    |

[L4]----+----- www(IP2) -----+---- DB

        |

        +----- www(IP3)

 

     [그림] L4 스위치를 사용한 웹 부하 분산의 예

 

 

        +----- www(IP1)      +---- NAS

        |                    |

[DNS]---+----- www(IP2) -----+---- DB

        |

        +----- www(IP3)

 

     [그림] DNS 서버를 이용한 웹 부하 분산의 예

 

[참고] NAS?

/root/docs/Reference/DAS_NAS_SAN.txt

 

 

[EX] Windows 서버에서의 테스트

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.213, 211.115.77.211, 211.32.117.30, 211.115.115.212

          211.115.77.214, 222.231.51.78, 222.231.51.77, 211.115.115.211

Aliases:  www.daum.net

 

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.211, 211.115.115.212, 222.231.51.77, 211.115.115.211

          211.32.117.30, 211.115.77.213, 211.115.77.212, 222.231.51.40

Aliases:  www.daum.net

 

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.213, 211.115.77.211, 211.32.117.30, 211.115.115.212

          211.115.77.214, 222.231.51.78, 222.231.51.77, 211.115.115.211

Aliases:  www.daum.net

 

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.212, 222.231.51.40, 211.115.77.211, 222.231.51.78

          211.115.77.214, 211.32.117.30, 211.115.77.213, 211.115.115.212

Aliases:  www.daum.net

 

 

Forward Zone File (exampleXXX.zone)

# vi /var/named/exampleXXX.zone

.....

[수정전]

www           IN   A       192.168.10.XXX

;www          IN   A       172.16.8.XXX     

;www          IN   A       192.168.10.1 

;www          IN   A       192.168.10.2 

;www          IN   A       192.168.10.3 

[수정후]

;www          IN   A       192.168.10.XXX     <----- 주석 처리

;www          IN   A       172.16.8.XXX 

www           IN   A       192.168.10.1       <----- 주석 제거

www           IN   A       192.168.10.2       <----- 주석 제거

www           IN   A       192.168.10.3       <----- 주석 제거

.....

 

# pkill -1 in.named

# nslookup www.solarisXXX.example.com

(정보 확인 1초후에 다시 시도)

# nslookup www.solarisXXX.example.com

(정보 확인 및 1초후에 다시 시도)

# nslookup www.solarisXXX.example.com

(정보 확인 및 1초후에 다시 시도)

# nslookup www.solarisXXX.example.com

(정보 확인 및 1초후에 다시 시도)

 

 

 

(2). 도메인 위임(Domain Delegation)

 

도메인 위임은 일반적으로 웹호스팅 업체(예:가비아)에서 일반적으로 많이 사용하고 있다.

 

[참고] domain 할당 받는 방법(예: 가비아)

 

+---------------------- example.com ------------------------+

|* DNS(ns.example.com)                                      |

|                                                           |

|   +----- solarisXXX.example.com ------+                   |

|   | * DNS(ns.solarisXXX.example.com)  |                   |

|   |                                   |                   |

|   |                                   |                   |

|   +-----------------------------------+                   |

|                                                           |

+-----------------------------------------------------------+

 

DNS(ns.example.com)

# vi /var/named/example254.zone

.....

solaris200.example.com.       IN  NS  ns.solaris200.example.com.

ns.solaris200.example.com.    IN  A   172.16.8.200

.....

or

solaris200                    IN  NS  ns.solaris200

ns.solaris200                 IN  A   172.16.8.200

.....

 

# vi /var/named/example254.rev

.....

200                           IN  PTR  ns.solaris200.example.com.

 

 

[EX] Hint Domain Administration

+----------------- . (Nameless Root Domain)-----------------+

|* DNS(A.ROOT-SERVERS.NET)                                  |

|                                                           |

|   +----------- .com ------------------+                   |

|   | * DNS(ns.com)                     |                   |

|   |                                   |                   |

|   |                                   |                   |

|   +-----------------------------------+                   |

|                                                           |

+-----------------------------------------------------------+

 

# vi /var/named/example254.zone

....

com.                          IN  NS  ns.com.

ns.com.                       IN  A   172.16.8.200

....

 

 

 

(3). 마스터 / 슬레이브 DNS 서버 구성

 

Master Server / Slave Server

 

====== Master Server =======    ======== Slave Server ========

    in.named(53)                    in.named(53)

    /etc/named.conf                 /etc/named.conf

      - Forward Zone File(M)           - Forward Zone File(S)

      - Reverse Zone File(M)           - Reverse Zone File(S)

      - Localhost Zone File(M)         - Localhost Zone File(M)

      - Zone File for Hint             - Zone File for Hint

    /var/named/Zone File            /var/named/Copy Zone File

      - Forward Zone File              - Copy Forward Zone File

      - Reverse Zone File              - Copy Reverse Zone File

      - Localhost Zone File            - Localhost Zone File

      - Zone File for Hint             - Zone File for Hint

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

 

             [그림] Master/Slave DNS Server

 

 

(전제 조건)

- Master DNS 서버의 도메인을 따른다.

        solaris201(Master DNS Server) - solaris201.example.com => solaris201.example.com

        solaris202(Slave DNS Server)  - solaris202.example.com => solaris201.example.com

- 자리 배치에 따른 서버 결정

        왼: Master, 오: Slave, 앞: Master, 뒤: Slave

 

(자리 배치도)

--------------------------------------------------------

                solarisXXX(172.16.8.XXX)

--------------------------------------------------------

200 201 202            203 204 205

 

206 207 208            209 210 211

 

212 213 214            215 216 217

 

218 219 220            221 222 223

 

224 225 226            227 228 229

--------------------------------------------------------

 

 

 

(3-1). Master DNS Server 서버쪽 설정

 

# vi /var/named/example254.zone

......

example.com.     IN   NS   ns1.example.com.

example.com.     IN   NS   ns2.example.com.

ns1              IN   A    172.16.8.254

ns2              IN   A    172.16.8.253

......

 

# vi /var/named/example254.rev

......

                 IN   NS   ns1.example.com.

                 IN   NS   ns2.example.com.

254              IN   PTR  ns1.example.com.

253              IN   PTR  ns2.example.com.

......

 

 

 

(3-2). Slave DNS Server 서버쪽 설정

 

# vi /etc/named.conf

......

     zone "example.com" in {

          type slave;

          file "example254.zone";

          masters { 172.16.8.254; };    <----- 172.16.8.254: Master DNS IP

     };

 

     zone "8.16.172.in-addr.arpa" in {

          type slave;

          file "example254.rev";

          masters { 172.16.8.254; };    <----- 172.16.8.254: Master DNS IP

     };

......

 

# cd /var/named

# ls

localhost.rev  named.root

 

 

 

[실습] DNS Master / Slave Server Configuration

 

(실습시나리오)

Domain : solaris201.example.com(Master DNS Server 도메인)

DNS1   : ns.solaris201.example.com  (solaris201)

            ^^^^^^^^^^^^^^^^^^^^^^

DNS2   : ns2.solaris201.example.com (solaris202)

             ^^^^^^^^^^^^^^^^^^^^^^

 

+---------------------- example.com ------------------------+

|* DNS(ns.example.com)                                      |

|                                                           |

|   +----- solarisXXX.example.com ------+                   |

|   | * DNS-ns.solarisXXX.example.com   |                   |

|   | *    -ns2.solarisXXX.example.com  |                   |

|   |                                   |                   |

|   +-----------------------------------+                   |

|                                                           |

+-----------------------------------------------------------+

 

 

(At Master DNS Server)

- Forward Zone File 편집

- Reverse Zone File 편집

 

(a). Forward Zone File 편집

# vi /var/named/example201.zone

.....

;

; DNS Server(Primary)

;

solaris201.example.com.  IN   NS      ns.solaris201.example.com.

solaris201.example.com.  IN   NS      ns2.solaris201.example.com.  <----- 라인 추가

ns                       IN   A       172.16.8.201

ns2                      IN   A       172.16.8.202                 <----- 라인 추가

.....

 

(b). Reverse Zone File 편집

# vi /var/named/example201.rev

......

8.16.172.IN-ADDR.ARPA. IN   NS      ns.solaris201.example.com.

8.16.172.IN-ADDR.ARPA. IN   NS      ns2.solaris201.example.com.    <----- 라인 추가

201                    IN   PTR     ns.solaris201.example.com.

202                    IN   PTR     ns2.solaris201.example.com.    <----- 라인 추가

......

 

# pkill -1 in.named

# tail -f /var/adm/messages

 

 

 

(At Slave DNS Server)

- /etc/named.conf 설정

- /var/named 파일 정리

 

(a). /etc/named.conf 파일 편집

# vi /etc/named.conf

.....

zone "solaris201.example.com" in {       <----- 정보 수정(solaris202 -> solaris201)

         type slave;                     <----- 정보 수정(master -> slave)

         masters { 172.16.8.201; };      <----- 라인 추가

         file "example201_backup.zone";  <----- 정보 수정

                                         (example202.zone -> example201_backup.zone)

};

 

zone "8.16.172.in-addr.arpa" in {

         type slave;                     <----- 정보 수정(master -> slave)

         masters { 172.16.8.201; };      <----- 라인 추가

         file "example201_backup.rev";   <----- 정보 수정

                                         (example202.rev -> example201_backup.rev)

};

.....

 

(b). /var/named 파일 정리

# cd /var/named

# rm example202.zone example202.rev

 

# tail -f /var/adm/messages

# pkill -1 in.named

# cd /var/named

# ls

(새로 생성된 Zone File 확인)

 

 

 

[Check Point] Slave Server

-> /var/named/(Zone File) 생성 확인

-> /var/adm/messages 로그 기록 정보 확인

 

 

 

(Master / Slave Zone Data Update 설정 테스트)

(At Master DNS Server)

# cd /var/named

# vi example201.zone

......

;--------------------------------

; Configuration for Test Domain

;--------------------------------

[수정전]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

[수정후]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

test1         IN   A       172.16.8.254     <----- 라인 추가

......

 

# pkill -1 in.named

# nslookup test1.solaris201.example.com

-> 출력 화면 확인

 

 

(At Slave DNS Server)

# cd /var/named

# grep test example201_backup.zone

test    4       IN      A       172.16.8.201

 

# pkill -1 in.named

# grep test example201_backup.zone

test    4       IN      A       172.16.8.201

 

 

(At Master DNS Server)

# vi example201.zone

......

20060930    ; serial number  (serial number 값을 높였다.)

......

;

; Configuration for Test Domain

;

[수정전]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

test1         IN   A       172.16.8.254

[수정후]

test          IN   A       172.16.8.201

cafe          IN   A       172.16.8.254

test1         IN   A       172.16.8.254

test2         IN   A       172.16.8.254      <----- 라인 추가

......

# pkill -1 in.named

 

 

(At Slave DNS Server)

# pkill -1 in.named

 

# grep test example201_backup.zone

test    4       IN      A       172.16.8.201

test1   4       IN      A       172.16.8.254

test2   4       IN      A       172.16.8.254

 

 

 

(4). Caching-Only DNS Server / Forwarding DNS Server 구성

 

(4-1). Caching Only Server 설정

 

====== Caching Only Server ======= 

    in.named(53)                  

    /etc/named.conf              

      - Localhost Zone File(M)

      - Zone File for Hint  

    /var/named/Zone File   

      - Localhost Zone File

      - Zone File for Hint

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

 

[그림] Caching Only DNS Server

 

 

 

(4-2). Forwarding DNS Server 구성

 

====== Forwarding Server =======    ======== DNS Server ========

    in.named(53)                    in.named(53)

    /etc/named.conf                 /etc/named.conf

                                                   - Forward Zone File

                                       - Reverse Zone File

                                       - Localhost Zone File

                                       - Zone File for Hint

                                    /var/named

                                                   - Forward Zone File

                                       - Reverse Zone File

                                       - Localhost Zone File

                                       - Zone File for Hint

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

 

              [그림] Forwarding DNS Server

 

 

Forwarding Server 설정

 

# vi /etc/named.conf

.....

options {

        directory "/var/named";

        forwarders { 172.16.10.254; };

        forward only;

};

.....

 

 

 

(5). Dynamic Updates 기능 설정

 

DNS 서버에서 동적 업데이트(Dynamic Updates) 기능은 DHCP 서버로 부터 호스트에 대한

정보를 동적으로 업데이트하는 기능이다. 이 기능을 통해 DHCP 서버로 부터 동적으로 할

당받은 클라이언트들이 관리자의 특별한 설정 없이도 서버 시스템에 접근하거나 서비스를

받을수 있다. Dynamic Update 기능을 설정하기 위해서는 DNS Master Server의 설정을 다음

과 같이 해야 한다.

 

Dynamic Update 는 해당 도메인의 Authority 를 갖는 네임서버를 통해  Zone 파일을 수정

치 않고도 레코드를 동적으로 원격 갱신할 수 있도록 한다. 도메인 관리를 자동화 하거나,

사용자 별로 접속 도메인을 실시간 변경하여 제공하거나, DHCP에서의 주소-IP 매칭등과

같이 실시간적으로 레코드가 변경, 갱신 될 필요가 있는 서비스에 특히 유용할 수 있다.

 

Dynamic Update 는 BIND 8 부터 지원이 되며 BIND 9 에서의 변화는 dnssec-key 를 이용한

인증부분의 강화되었다.

 

 

■ Master DNS 서버 설정

 

# vi /etc/named.conf

 

     zone "example.com" in {

          type master;

          file "example254.zone";

          allow-update { 127.0.0.1; 172.16.8.254; };

     };

     zone "8.16.172.in-addr.arpa" in {

          type master;

          file "example254.rev";

          allow-update { 127.0.0.1; 172.16.8.254; };

     };

 

# pkill -1 in.named

 

 

 

(6). DNS 보안 설정

 

DNS 서버의 설정은 인증되지 않은 클라이언트에게도 정보가 노출될수 있다. BIND 8.X 버전

부터 /etc/named.conf 파일에 allow-query, allow-transfer 키워드를 통해 보안 설정을 할

수 있다.

 

allow-query 키워드는 DNS 쿼리를 요청할 수 있는 지역을 IP에 기반해서 설정 할 수 있다.

일반적으로 DNS Server와 DNS Client의 관계를 보안적으로 구성할 수 있다. 일반적으로 회

사내에 존재하는 DNS 서버에 DNS 서버에 쿼리를 요청할 수 있는 클라이언트 대역을 회사내

로 한정하여 설정하는 것을 권장한다.

 

allow-transfer 키워드는 DNS 존 파일을 전송받을수 있는 지역을 선택할수 있다.

DNS Master Server와 DNS Slave Server의 관계를 보안적으로 구성할 수 있다. 일반적으로

회사내에 존재하는 DNS Master Server에서 allow-transfer를 통해 존 파일을 전송할 수 있

는 DNS Slave Server의 IP를 지정할 것을 권장한다.

 

■ Security / ACL(Access Control List)

- 데이터 암호화(Data Encryption)

- chroot 환경 설정

- 프로그램 업데이트, 프로그램 패치

- Master => Slave(Zone 파일들이 전달될수 있는 영역 지정)

- Server => Client(Zone File에 대한 Query 영역 지정)

 

(At Master DNS System)

# vi /etc/named.conf

.....

options {

    allow-query { 172.16.0.0/16; 172.17.0.0/16; 192.168.8.0/24 };

    .....

};

.....

zone "example.com" in {

        type master;

        file "exmaple254.zone;

        allow-transfer { 172.16.8.253; 192.168.8.252; };

        allow-query { 172.16.0.0/16; 172.15.0.0/16; };

}

.....

 

 

 

(7). ndc 명령어

 

ndc 명령어를 사용하여 DNS Server의 설정을 변경할 수 있고 in.named 데몬을 제어 할 수

있다. 기본의 방식은 in.named 데몬에 대해 SIGHUP, SIGIINT 등과 같은 시그널을 사용해서

제어 했지만 ndc 명령어를 사용하면 좀 더 세세한 정보와 제어가 가능하다. ndc 명령어는

대화형 모드와 비 대화형 모드의 실행이 가능하다. BIND 9.X 버전에서는 rndc 명령어로 변

경이 되었다.

 

# ndc

Type   help  -or-   /h   if you need help.

ndc> /h

        /h(elp)                 this text

        /e(xit)                 leave this program

        /t(race)                toggle tracing (protocol and system events)

        /d(ebug)                toggle debugging (internal program events)

        /q(uiet)                toggle quietude (prompts and results)

        /s(ilent)               toggle silence (suppresses nonfatal errors)

 

ndc> help

(builtin) start - start the server

(builtin) restart - stop server if any, start a new one

getpid

status

stop

exec

reload [zone] ...

reconfig [-noexpired] (just sees new/gone zones)

dumpdb

stats [clear]

trace [level]

notrace

querylog

qrylog

help

quit

args

 

ndc> restart

new pid is 1197

/e                           <----- '/e' 입력

 

# ndc

ndc> status

in.named BIND 8.3.3 Thu Jun 16 08:11:42 PDT 2005  Generic Patch-5.9-June 2005

config (/etc/named.conf) last loaded at age: Thu Oct 18 00:11:35 2007

number of zones allocated: 64

debug level: 0

xfers running: 0

xfers deferred: 0

soa queries in progress: 0

query logging is OFF

server is initialising itself

 

ndc> dumpdb

Database dump initiated.

 

ndc> /e                           <----- '/e' 입력

 

# cd /var/named

# ls -l named_dump.db

-rw-r--r--   1 root     root        2.5K Oct 18 01:45 named_dump.db

 

 

[참고] ndc 명령어 사용을 다른 예

 

ndc> /t

tracing now on

 

ndc> restart

ndc: [command 'exec']

ndc: [220 BIND 8.3.3]

ndc: [250 Restart initiated.]

ndc: [command 'getpid']

ndc: [220 BIND 8.3.3]

ndc: [250 my pid is <1210>]

pid 1210 is running

new pid is 1210

/e                           <----- '/e' 입력

 

 

# ndc

ndc> /t        //trace mode

tracing now on

 

ndc> /d        //usr1 signal

debugging now on

 

ndc> restart

ndc: [command 'exec']

ndc: [isc/ctl_clnt::new_state: initializing -> connecting]

ndc: [isc/ctl_clnt::new_state: connecting -> connected]

ndc: [isc/ctl_clnt::readable: read 16, used 16]

ndc: [220 BIND 8.3.3]

ndc: [isc/ctl_clnt::readable: read 24, used 24]

ndc: [250 Restart initiated.]

ndc: [isc/ctl_clnt::new_state: connected -> destroyed]

ndc: [command 'getpid']

ndc: [isc/ctl_clnt::new_state: initializing -> connecting]

ndc: [isc/ctl_clnt::new_state: connecting -> connected]

ndc: [isc/ctl_clnt::readable: read 16, used 16]

ndc: [220 BIND 8.3.3]

ndc: [isc/ctl_clnt::readable: read 22, used 22]

ndc: [250 my pid is <1217>]

ndc: [isc/ctl_clnt::new_state: connected -> destroyed]

pid 1217 is running

new pid is 1217

/e                           <----- '/e' 입력

 

 

 

[참고] ndc 명령어(Non-Interractive Mode) 실행

# ndc getpid      in.named 데몬의 PID 번호 보여주기

# ndc status      in.named 상태 보기

# ndc reload      /etc/named.conf & Zone 파일 다시 읽기

# ndc stats       통계 남기기

# ndc querylog    /var/adm/messages 파일에 로그 남기기

 

 


2008. 9. 2. 18:42

nslookup CMD

 

 

 

                  nslookup CMD

 

 

 

 

 

 

1. nslookup CMD

_____________________

 

query name servers interactively

 

     Nslookup is a program to query Internet domain name servers.

     Nslookup has two modes: interactive and non-interactive.

     Interactive mode allows the user to query name servers for

     information about various hosts and domains or to print a

     list of hosts in a domain. Non-interactive mode is used to

     print just the name and requested information for a host or

     domain.

 

     Interactive mode is entered in the following cases:

 

     1. when no arguments are given (the default name server will

        be used)

 

     2. when the first argument is a hyphen (-) and the second

        argument is the host name or Internet address of a name

        server.

 

     Non-interactive mode is used when the name or Internet

     address of the host to be looked up is given as the first

     argument. The optional second argument specifies the host

     name or address of a name server.

 

     Options can also be specified on the command line if they

     precede the arguments and are prefixed with a hyphen. For

     example, to change the default query type to host

     information, and the initial timeout to 10 seconds, type:

 

 

 

 

 

2. Name Service Lookup CMD(s)

__________________________________

 

- dig

- host

- nslookup

 

 

 

(1). dig CMD

 

     dig (domain information groper) is a flexible tool for

     interrogating DNS name servers. It performs DNS lookups and

     displays the answers that are returned from the name

     server(s) that were queried. Most DNS administrators use dig

     to troubleshoot DNS problems because of its flexibility,

     ease of use and clarity of output. Other lookup tools tend

     to have less functionality than dig.

 

     Although dig is normally used with command-line arguments,

     it also has a batch mode of operation for reading lookup

     requests from a file. A brief summary of its command-line

     arguments and options is printed when the -h option is

     given. Unlike earlier versions, the BIND9 implementation of

     dig allows multiple lookups to be issued from the command

     line.

 

     Unless it is told to query a specific name server, dig will

     try each of the servers listed in /etc/resolv.conf.

 

     When no command line arguments or options are given, will

     perform an NS query for "." (the root).

 

     It is possible to set per-user defaults for dig via

     ${HOME}/.digrc. This file is read and any options in it are

     applied before the command line arguments.

 

 

# dig www.daum.net

 

; <<>> DiG 8.3 <<>> www.daum.net

;; res options: init recurs defnam dnsrch

;; got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2

;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 9, ADDITIONAL: 9

;; QUERY SECTION:

;;      www.daum.net, type = A, class = IN

 

;; ANSWER SECTION:

www.daum.net.           3h47m46s IN CNAME  daumtop.daum.akadns.net.

daumtop.daum.akadns.net.  2m58s IN A  211.115.77.211

daumtop.daum.akadns.net.  2m58s IN A  211.115.77.212

daumtop.daum.akadns.net.  2m58s IN A  211.115.77.214

daumtop.daum.akadns.net.  2m58s IN A  211.32.117.30

daumtop.daum.akadns.net.  2m58s IN A  211.115.77.213

daumtop.daum.akadns.net.  2m58s IN A  222.231.51.40

daumtop.daum.akadns.net.  2m58s IN A  211.115.115.211

daumtop.daum.akadns.net.  2m58s IN A  222.231.51.78

 

;; AUTHORITY SECTION:

akadns.net.             21h47m45s IN NS  eur1.akadns.net.

akadns.net.             21h47m45s IN NS  za.akadns.org.

akadns.net.             21h47m45s IN NS  zd.akadns.org.

akadns.net.             21h47m45s IN NS  use4.akadns.net.

akadns.net.             21h47m45s IN NS  zc.akadns.org.

akadns.net.             21h47m45s IN NS  usw2.akadns.net.

akadns.net.             21h47m45s IN NS  asia9.akadns.net.

akadns.net.             21h47m45s IN NS  use3.akadns.net.

akadns.net.             21h47m45s IN NS  zb.akadns.org.

 

;; ADDITIONAL SECTION:

asia9.akadns.net.       1d23h48m18s IN A  220.73.220.4

eur1.akadns.net.        1d23h57m54s IN A  213.254.204.197

use3.akadns.net.        1d23h34m19s IN A  204.2.178.133

use4.akadns.net.        1h42m11s    IN A  208.44.108.137

usw2.akadns.net.        1d49m46s    IN A  63.209.3.132

za.akadns.org.          21h47m45s   IN A  195.219.3.169

zb.akadns.org.          21h47m45s   IN A  206.132.100.105

zc.akadns.org.          21h47m45s   IN A  124.211.40.4

zd.akadns.org.          21h47m45s   IN A  63.209.3.132

 

;; Total query time: 14 msec

;; FROM: solaris254 to SERVER: default -- 168.126.63.1

;; WHEN: Wed Mar  5 13:43:52 2008

;; MSG SIZE  sent: 30  rcvd: 510

 

[참고] /root/SERVER/DNS/Reference/dig_활용방법_가이드.pdf

 

 

 

 

 

 

(2). host

 

     host is a simple utility for performing DNS lookups. It is

     normally used to convert names to IP addresses and vice

     versa. When no arguments or options are given, host prints a

     short summary of its command line arguments and options.

 

     name is the domain name that is to be looked up. It can also

     be a dotted-decimal IPv4 address or a colon-delimited IPv6

     address, in which case host will by default perform a

     reverse lookup for that address.  server is an optional

     argument which is either the name or IP address of the name

     server that host should query instead of the server or

     servers listed in /etc/resolv.conf.

 

 

# host www.daum.net

 

 

 

(3). nslookup

 

자세한 내용은 "4. nslookup 사용법"를 참고한다.

 

# nslookup www.daum.net

 

 

 

 

 

3. Debugging for DNS

______________________

 

DNS 서버 설정이 이상이 있는 경우 디버깅하는 방법은 (a)nslookup 명령어를 사용하는 방

법, (b) /var/adm/messages 파일을 활용하는 방법, (c)signal을 사용하는 방법등이 있다.

 

■ nslookup 명령어를 사용하는 경우

■ /var/adm/messages & SIGHUP 사용하는 경우

■ 시그널 (SIGINT, SIGUSR1) 사용하는 경우

 

 

 

[EX1] nslookup 명령어를 사용하는 방법

# nslookup

> server 172.16.8.XXX            (자신의 DNS 서버 지정)

 

> set q=NS

> solarisXXX.example.com         (자신의 도메인 지정)

 

> set q=MX

> solarisXXX.example.com         (자신의 메일 서버 도메인 지정)

 

> set q=A

> www.solarisXXX.example.com     (자신의 웹서버 도메인 지정)

 

 

[EX2] /var/adm/messages 파일과 signal(SIGHUP) 사용하는 경우

<TERM1> 관리자 윈도우 1

# tail -f /var/adm/messages (# mlog)

..... (중략) .....

Jul  1 16:26:37 solaris254 named[189]: [ID 295310 daemon.notice] reloading nameserver

Jul  1 16:26:37 solaris254 named[189]: [ID 295310 daemon.notice] Ready to answer queries.

 

<TERM2> 관리자 윈도우 2

# pkill -HUP in.named

 

 

[EX3] 다른 시그널을 사용하는 경우

# pkill -INT in.named

# cat /var/named/named_dump.db

.... (내용 생략).....

 

# pkill -USR1 in.named (Debug Mode ON)

# cat /var/named/named.run

-----------------------------------------------------------------------

Debug level 1

Version = in.named BIND 8.3.3 Thu Jun 16 08:11:42 PDT 2005

        Generic Patch-5.9-June 2005

conffile = /etc/named.conf

datagram from [172.16.8.203].32967, fd 23, len 17

req: nlookup() id 11692 type=2 class=1

req: missed '' as '' (cname=0)

ns_req: answer -> [172.16.8.203].32967 fd=23 id=11692 size=60 rc=0

prime_cache: priming = 0, root = 0

-----------------------------------------------------------------------

 

# pkill -USR2 in.named (Debug Mode OFF)

 

 

 

 

4. nslookup 사용법

____________________

 

(1). How to using the nslookup CMDs

 

- Non-interractive Mode( 대화형 모드 실행)

- Interractive Mode(대화형 모드 실행)

 

EX) Interractive/Non-interractive Mode

# nslookup  www.daum.net

# nslookup

> www.daum.net

 

 

 

(2). nslookup CMD EXAMPLE

 

(2-1). 대화형 모드(Non-interractive Mode) 실행

# nslookup -query=NS solarisXXX.example.com

# nslookup -q=A ns.solarisXXX.example.com

# nslookup -q=MX solarisXXX.example.com

# nslookup -q=PTR 172.16.8.XXX

 

 

 

(2-2). 대화형 모드(Interractive Mode) 실행

 

# nslookup

> test.solarisXXX.example.com

> 172.16.8.XXX

> ls solarisXXX.example.com

 

(1st Style)

> ls -a www.solarisXXX.example.com  (a: alias)

> ls -d solarisXXX.example.com      (d: detail)

 

> ls -t MX solarisXXX.example.com

> ls -t A www.solarisXXX.example.com

> ls -t PTR 172.16.8.XXX

> ls -t NS solarisXXX.example.com

 

(2nd Style)

> set type=MX

> solaris254.example.com

> set type=A

> www.solaris254.example.com

> set type=PTR

> 172.16.8.254

> set type=NS

> solaris254.example.com

 

(3rd Style)

> set q=NS        (Name Server)

> solarisXXX.example.com

 

> set q=MX        (Mail Exchange)

> solarisXXX.example.com

 

> set q=A         (Address)

> www.solarisXXX.example.com

 

> set q=PTR       (Address Pointer)

> 172.16.8.XXX

 

> server 168.126.63.1

 

> set q=NS

> kornet.net      //도메인 네임

 

> set q=MX 

> kornet.net      //도에인 네임

 

> set q=A   //adress

> www.kornet.net

 

> set q=PTR

> 211.216.50.150

 

> exit

 

 

 

2008. 9. 2. 18:17

DNS Server(Domain Name System)

 

 

 

                       DNS Server(Domain Name System)

 

 

 

 

 

 

0. DNS 관련 용어(Terms)

_______________________

 

 

DNS 서버에 대한 자세한 정보를 논하기 전에 DNS 서버에서 사용하는 도메인에 대한 명확한

용어의 개념을 알아 보자.

 

 

URL : "http://www.itbank.com"

 

       www            : Hostname

       itbank.com     : Domainname

       www.itbank.com : FQDN(Fully Qualified Domain Name)

 

 

+------------ itbank.com ------------+

| [DNS Server]                       |

| IP1 --> www        X (www)         |

| IP2 --> mail                       |

| IP3 --> ftp        X (mail)        |

|                                    |

|                    X (ftp)         |

|                                    |

+------------------------------------+

 

[참고] 일반적인 Domainname : www.itbank.com

 

 

 

(1). Host Name?

 

인터넷에서 호스트는, 인터넷을 통해 다른 컴퓨터들과 쌍방향 통신이 가능한 컴퓨터를 말

한다. 호스트는 특정한 호스트번호를 갖는데, 이는 네트웍 번호와 합해져서, 고유의 IP

주소를 이루게된다. 인터넷 서비스 제공업체를 통한 PPP 사용자의 경우에는, 접속되어있

는 동안에만 고유한 IP 주소를 갖게되며, 그 시간동안은 해당 사용자의 컴퓨터도 하나의

호스트가 되는 것이다. 이러한 맥락에서 보면, 호스트란 네트웍의 하나의 노드라고 볼 수

도 있다.

 

 

 

(2). Domain Name?

 

인터넷에 연결된 다른 컴퓨터와 통신을 하기 위해서는 컴퓨터가 인터넷에 연결되어 있어

야 하고 컴퓨터의 주소를 알고 있어야 한다. 컴퓨터의 주소는 숫자로 표현된 주소와 영문

자로 표현된 주소의 2가지가 있다.

 

203.247.51.32 (IP주소)

 

숫자로 표현된 주소는 왼쪽 그림과 같이 점으로 구분되어 4단계로 표시되는데, 점으로 구

분된 각 숫자에는 0 ∼ 255 까지의 숫자를 사용할 수 있으며, 전세계적으로 중복되지 않

도록 사용해야 한다. 숫자로 표현된 이러한 주소를 인터넷 공인 IP 주소라고 한다.

 

그러나 인터넷 사용자들이 다른 컴퓨터와의 통신을 위해 숫자로 표현된 주소를 사용하게

되면, 주소를 이해하거나 기억하기 어렵다는 단점이 있다. 따라서 숫자로 표현된 주소대

신에 영문자로 표현된 주소를 사용할 수 있도록 하였는데, 영문자로 표현된 주소는 우리

가 실생활에서 사용하는 영문단어로 구성되어 인터넷 사용자들이 쉽게 기억할 수 있고 편

리하게 다른 컴퓨터와 통신할 수 있다.

 

 

itwill.co.kr (도메인주소)

1단계: kr

2단계: co

3단계: itwill

 

영문자로 표현된 주소는 왼쪽 그림과 같이 점으로 구분되어 여러 단계로 구성된다. 각 단

계는 오른쪽 맨 마지막에서부터 1단계, 2단계, 3단계 등으로 불리며, 전세계적으로 중복

되지 않는 고유한 이름이 부여된다. 이를 인터넷 도메인이라고 하는데, 인터넷 도메인 이

름은 인터넷에 연결된 전세계의 어떠한 컴퓨터와도 통신을 가능하게 해준다. 

 

[인터넷 도메인 이름의 부여 원칙]

 

* 영문자 A~z, 숫자 0~9 또는 하이픈(-)의 조합으로만 표현되며, 영문자의 대, 소문자는

  구별하지 않고 같은 것으로 간주한다.

* 첫 글자는 영문자로 시작하여야 하며, 하이픈으로 끝날수 없다 (우리나라에서는 1999년

  6월 30일부터 숫자로 시작되는 도메인 이름도 허용되었다).

* 길이는 각 단계별로 최소 2자에서 최대 63자까지 가능하다.

* 컴마(,), 언더바(_) 등의 기호는 사용할 수 없다.

* 전세계적으로 중복되지 않도록 고유해야 한다 (이미 사용되고 있는 도메인 이름은 쓸

  수 없다).

 

 

 

(3). FQDN(Fully Qualified Domain Name)?

 

FQDN[에프큐디엔]은 시스템을 지칭하는 완전한 이름으로서, 호스트 이름과 그것의 도메인

이름으로 구성된다. 예를 들어, "www"가 호스트 이름이고, "terms.co.kr"이 도메인 이름

이라면, FQDN은 "www.terms.co.kr"가 된다. FQDN은 인터넷상의 특정 호스트를 지칭하기

위한 고유한 인터넷 주소를 가져야한다. 인터넷상에 있지 않지만, 전자우편 주소를 위한

이름공간을 공유하는 일부 호스트를 위해서도, 동일한 이름 구조가 사용된다. FQDN을 가

지고 있지 않은 호스트는 뱅 경로를 사용하여 지칭되어야한다.

 

모든 인터넷 컴퓨터들과 대부분의 UUCP 사이트들은 1980년부터 작성된 막후의 많은 량의

소프트웨어 덕분에 이제 FQDN을 해석할 수 있다.

 

 

 

(4). Internet?

 

인터넷은 전세계적인 컴퓨터 네트웍 시스템으로서, 사용자가 어떤 컴퓨터에 있든지 간에

그가 사용권한을 가지고 있다면 그 어떤 다른 컴퓨터에도 접속해서 정보를 얻을 수 있는

"네트웍의 네트웍"이다. 인터넷은 1969년에 미국 정부의 ARPA (Advanced Research

Projects Agency)에 의해 태동되었으며, 처음에는 ARPANet으로 알려졌었다. 인터넷의 원

래 목표는 한 대학에 있는 연구용 컴퓨터의 사용자가 다른 대학에 있는 연구용 컴퓨터의

사용자와 "대화할 수 있는" 네트웍을 만드는 것이었다. ARPANet 설계의 부산물 중 하나

는, 메시지가 한 방향 이상으로 나뉘어 전달되거나 또는 다른 길로 전달될 수 있기 때문

에, 적의 군사공격이나 기타 다른 재해로 인해 네트웍의 일부가 파괴된 경우에도 제 기능

을 발휘할 수 있다는 것이다.

 

오늘날 인터넷은 전세계의 수 십억 인구가 액세스할 수 있는 대중 전체를 위한, 협동적이

며, 스스로 유지되는 자립 설비이다. 인터넷은 물리적으로 기존의 공중 전화망의 전체 자

원의 일부를 활용하고 있으며, 기술적으로는 TCP/IP라고 불리는 일련의 프로토콜들을 사

용함으로써 다른 것들과 구별된다. 인터넷 기술에 있어 최근에 나타난 2개의 변화는, 인

트라넷과 엑스트라넷이며, 이들 역시 TCP/IP 프로토콜을 사용한다.

 

많은 인터넷 사용자들을 위하여, 전자우편이 짧은 편지의 처리를 위한 우편서비스를 실용

적으로 대체하고 있다. 전자우편은 인터넷에서 가장 널리 사용되는 응용프로그램이다.

사용자는 또한 IRC를 이용하여 다른 컴퓨터의 사용자와 실시간으로 채팅을 할 수 있다.

최근에는 인터넷 전화설비 및 소프트웨어를 이용하여 실시간으로 음성통화까지 가능하게

되었다.

 

인터넷에서 가장 널리 사용되는 서비스 중의 하나가 월드와이드웹이다. 웹의 가장 두드러

진 특성은 즉시 상호 참조를 할 수 있게 해주는 방법인 하이퍼텍스트인데, 대부분의 웹사

이트들에서 텍스트 내에 다른 색으로 표시되어 있거나 또는 밑줄로 표시되어 있는 단어나

문장이 바로 그 것이다. 사용자가 이러한 단어나 구절을 선택하면, 이것과 관련 있는 사

이트나 페이지로 전환된다. 때로는 이러한 링크는 클릭이 가능하도록 만들어진 이미지

(또는 이미지의 일부)에도 숨겨져 있을 수 있다. 마우스의 포인터를 하이퍼텍스트 링크에

갖다대면, 포인터의 모양이 화살표에서 손 모양으로 바뀌는데, 이것은 다른 사이트나 페이

지로 전환하기 위해 클릭할 수 있다는 것을 가리킨다.

 

웹을 사용하면 무수히 많은 량의 정보에 쉽게 액세스할 수 있다. 웹 서핑은 웹 브라우저

를 통해 이루어지는데, 유명한 것으로는 넷스케이프 네비게이터와 마이크로소프트의 인터

넷익스플로러가 있다. 특정 웹사이트의 모습은 어떤 브라우저를 사용하느냐에 따라 다소

다르게 보일 수도 있다. 또한 최신 버전의 브라우저들은 애니메이션, 가상현실, 소리, 음

악파일 등에 있어 이전 버전에 비해 더 많은 특수기능들을 제공한다.

 

 

 

(5). ARPANet (Advanced Research Projects Agency Network)?

 

아파넷은 인터넷의 기초가 된 네트웍이다. 아파넷은 패킷 스위칭 개념을 이용하여 전용회

선으로 서로 연결된 여러 대의 컴퓨터로 구성되었으며, 주로 미 군당국에서 자금을 지원

하였다.

 

아파넷은 이후 1980년대에 들어서면서 새로운 군사용 네트웍인 DDF(Defense Data Network)

와 국립과학재단의 후원을 받는 과학 및 학술컴퓨터 네트웍인 NSFNet으로 분리되었다.

1995년에 NSFNet은, 인터넷 백본(vBNS라고 불린다)을 PSINet, UUNET, ANS/AOL, 스프린트,

MCI, 및 AGIS-Net99 등과 같은 상용 백본 제공업체의 컨소시움으로 바꾸기 위해, 차례대

로 단계적 철수를 시작했다.

 

 

 

 

 

 

1. DNS 개요(Concept)

____________________

 

- DNS(Domain Name System / Service)

 

(1). 초기의 도메인 관리

 

 

 

+-------------Domain-----------------+

|                                    |

|  SERVER -------+------> SERVERA    |

|  HOST.txt      |                   |

|                +------> SERVERB    |

|                |                   |

|                +------> SERVERC    |

|                |                   |

|                +------> .....      |

|                                    |

+------------------------------------+

 

[Main Server] -------------------> [Domin Server]

  HOST.TXT                          /etc/hosts

(Domain <--> IP)

 

      [그림] 초기의 도메인 관리

 

 

 

(2). 현재의 도메인 관리

 

DNS(Domain Name System), BIND(Berkeley Internet Name Domain)

- BIND 4.X

- BIND 8.X

- BIND 9.X

 

 

 

==== DNS Client ====       ==== DNS Server =====                              

Resolver                     in.named(53)

- /etc/nsswitch.conf        /etc/named.conf

- /etc/resolv.conf           DB : /var/named/

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

Web Browser                   - Forward Zone File(D==>IP)

- http://www.itbank.com       - Reverse Zone File(IP==>D)

                              - localhost Zone File(Caching)

                              - hint File(named.root, hint)

 

             [그림] BIND 동작

 

 

------------------------------------------------------

도메인           

------------------------------------------------------

.                             - Nameless Root Domain

.com                   - 1차 도메인(국가 도메인 포함)

                                      (예) kr, jp, ....

                                      (예) .com, .org, ....

.itbank.com            - 2차 도메인

                                      (예) yahoo.com, itbank.com, daum.net

.yahoo.co.kr   - 3차 도메인

------------------------------------------------------

       

(예) www.yahoo.co.kr

            A   A  A

|   |  |

           (a) (b)(c)

(a) : 3차 도메인

(b) : 2차 도메인

(c) : 1차 도메인

 

            [그림] 도메인 이름 체계

 

 

* 수업시에 사용하는 도메인 이름 체계

(예) www.solarisXXX.example.com

 

 

 

[참고] BIND (Berkeley Internet Name Domain)?

BIND는 BSD 기반의 유닉스 시스템을 위해 설계된 DNS이다. BIND는 서버와 resolver 라이

브러리로 구성되어 있다. 네임서버는 클라이언트들이 이름 자원들이나 객체들에 접근하여,

네트웍 내의 다른 객체들과 함께 이러한 정보를 공유할 수 있게 해주는 네트웍 서비스이

다. 이것은 사실상, 컴퓨터 네트웍 내의 객체들을 위한 분산 데이터베이스 시스템이다.

BIND는 호스트 이름과 주소를 저장하고 검색하는데 사용되기 위한 BSD 네트웍 프로그램

(버전 4.3 이상)에 완전히 통합되어 있다.

 

시스템 관리자는 BIND를 네트웍 호스트들의 file(/etc/hosts) 내에 있는 호스트 테이블

룩업의 대체용으로 사용하도록 시스템을 설정할 수 있다. BSD의 기본 설정은 BIND를 사용

하는 것이다.

 

 

 

 

 

2. Solaris 9 DNS 기본 설정

______________________________________

 

솔라리스 9에서는 기본적으로 BIND 8.2.X 버전이 설치 되어 있다. 현재 솔라리스 09/05 버

전에는 8.2.4 버전이 설치되어 있다. 기본적으로 설치 되어 있는 Bind 프로그램을 사용하

는 경우 데몬만 존재하고 /etc/named.conf, /var/named/DB 파일들이 존재하지 않기 때문에

생성을 해 줘야 한다. 설정 파일들은 특정한 문법(Syntax)가 존재하기 때문에 매뉴얼 페이

지를 참고하여 작성하여야 한다.

 

[참고] /etc/named.conf, /var/named/DB 작성시 주의점

경험상, 설정파일이나 DB 파일들에는 탭이나 스페이스를 모두 사용할 수 있다고 되어 있

지만 탭을 사용하는 경우 알수 없는 에러가 생기는 경우를 많았다. 반드시 스페이스를 사

용하여 필드를 구분하자. 일부 다른 문서에서는(특히나 다른 유닉스) 스페이스 대신해서

탭을 쓸것을 권장하지만 솔라리스의 특성으로 여겨진다. 주의하자.

 

 

 

패키지 : SUNWinamd

---------------------------------------

==== DNS Server =====                             

   in.named(53)

   /etc/named.conf

   DB : /var/named/

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

- Forward Zone File(D==>IP)

- Reverse Zone File(IP==>D)

- localhost Zone File(Caching)

- hint File(named.root, hint)

---------------------------------------

 

 

(0). Bind 프로그램 설치 확인

 

패키지를 살펴 보면 특별한 설정파일은 없고 in.named, in.named-xfer 프로그램만 존재한

다는 것을 확인할 수 있다.

 

# pkginfo | grep Domain

system      SUNWidnd       Internationalized Domain Name Support Developer Files

system      SUNWidnl       Internationalized Domain Name Support Library Files

system      SUNWinamd      Internet Domain Name Server   <----- Bind 프로그램 확인

 

# pkgchk -v SUNWidnd

# pkgchk -v SUNWidnl

# pkgchk -v SUNWinamd

/usr

/usr/sbin

/usr/sbin/in.named

/usr/sbin/named-xfer

 

 

 

(1). DNS 서비스 데몬 확인

 

DNS 서비스 데몬 in.named는 기본적으로 설치가 되어 있다.

 

# which in.named

/usr/sbin/in.named

 

# in.named -v

in.named BIND 8.3.3 Thu Jun 16 08:11:42 PDT 2005

        Generic Patch-5.9-June 2005

 

 

 

(2). DNS 서비스 포트 확인

 

DNS 서비스 포트는 53으로 설정 되어 있다.

 

# grep 53 /etc/services

domain          53/udp

domain          53/tcp

 

 

 

(3). /etc/named.conf, /var/named/* 확인

 

DNS 서버 주설정 파일인 /etc/named.conf 존재하지 않는다. 또한 /etc/named.conf 파일이

없으므로 /var/named/DB 파일들도 존재하지 않는다.

 

# ls -l /etc/named.conf

/etc/named.conf: No such file or directory

 

# ls -ld /var/named

/var/named: No such file or directory

 

 

 

(4). DNS Server 설정

 

DNS 서버 설정을 위해서 /etc/named.conf 파일을 만들고 /var/named/DB 파일들을 생성해

주는 DNS.sh 스크립트를 실행하자. DNS.sh 스크립트는 /etc/named.conf 파일을 생성하고

/var/named 디렉토리를 만든후 그안에 exampleXXX.zone, exampleXXX.rev, localhost.rev

named.root 파일을 생성한다. 또한 /etc/nsswitch.conf, /etc/resolv.conf 파일도 설정

해 준다.

 

# mkdir /mnt/server

# mount 172.16.8.254:/root/shell /mnt/server

# cd /mnt/server

# ./DNS.sh

 

 

 

(5). DNS Server 설정 확인

 

DNS 서버 설정을 다음과 같이 확인하자. in.named 데몬을 띄우고 nslookup 명령어를 통해

확인해 보자. 각 설정 파일의 정보가 정확한지 확인을 해야 한다. in.named 데몬을 띄울때

/var/adm/messages 파일을 모니터링 하는 것을 잊지 말자.

 

# ls -l /etc/named.conf

# ls -l /var/named

# cat /etc/resolv.conf

# cat /etc/nsswitch.conf | grep hosts

....

hosts: files dns

....

 

 

 

(6). DNS 서버 실행

 

# in.named

# pgrep -lf in.named

  193 /usr/sbin/in.named

 

# nslookup www.solarisXXX.example.com

 

 

 

(7). DNS Server 관련 파일들

 

/etc/named.conf                                   DNS Main Conifguration File

 

/var/named/exampleXXX.zone         Forward Zone File

/var/named/exampleXXX.rev          Reverse Zone File

/var/named/localhost.rev           Localhost Zone File

/var/named/named.root                      Hint File

 

/etc/nsswitch.conf                         DNS Client File

/etc/resolv.conf                           DNS Client File

 

 

 

 

 

3. Bind 8.2.4(Solaris 9)

 

각 서버들에 대한 자세한 소개는 "2_DNS8x.txt" 파일에 있다. DNS 서버in.named 데몬은

/etc/named.conf 파일을 설정을 가지고 부팅시에 /etc/rc2.d/S72inetsvc Startup Script

에 의해 설정된다. 솔라리스 9 버전에는 BIND 8.2.X, 또는 BIND 8.3.X 버전이 설치 되어

있다.

 

 

 

(1). 서버의 종류(Server Types)

 

서비스를 제공하는 서버의 영역에 따른 분류

Root Servers(Nameless Root)

■ 1차 도메인 서버/2차 도메인 서버/....

 

서버의 목적에 따른 분류

■ Primary / Secondary Servers(Master / Slave Servers)

■ Caching-Only Servers

■ Forwarding Servers

 

 

 

(2). 클라언트 쿼리 종류(Answer Types)

 

Answers that are returned from DNS servers can be described as authoritative or

non-authoritative.

 

Answers from authoritative DNS servers are:

* Sourced from a disk-based file.

* Usually correct. Because humans administer the DNS, it is possible for

 incorrect data to enter the DNS database.

 

Answers from non-authoritative DNS servers are:

* Sourced from a server cache

* Usually correct

* Can be incorrect if the server’s cache contains stale data

 

 

[EX] nslookup 명령어 확인(Windows에서 확인)

 

C:\> nslookup www.daum.net

Server:  kns.kornet.net

Address:  168.126.63.1

 

Non-authoritative answer:        <----- 출력 정보 확인

Name:    daumtop.daum.akadns.net

Addresses:  211.115.77.214, 211.115.77.211, 222.231.51.78, 211.115.115.212

          222.231.51.77, 211.115.77.213, 222.231.51.40, 211.115.77.212

 

 

2008. 9. 1. 18:21

IPv6-IPv4-IPv6 Tunnel Configuration

 

 

 

               IPv6-IPv4-IPv6 Tunnel Configuration

 

 

 

 

 

                                   172.16.0.0

------+---------------------------------------+--------

      |                                       |

   (pcn0)  172.16.8.200                     (pcn0)  172.16.8.205

<solaris200>                             <solaris205>

   (pcn0:1)192.168.1.1                      (pcn0:1)192.168.2.1

      |                                       |

      +-192.168.1.2(pcn0)                     +-192.168.2.2(pcn0)

      |                                       |

      +-192.168.1.3                           +-192.168.2.3

      |                                       |

      +-192.168.1.4                           +-192.168.2.4

      |                                       |

      +-192.168.1.5                           +-192.168.2.5

      |                                       |

      +-192.168.1.6                           +-192.168.2.6

      |                                       |

      +-192.168.1.7                           +-192.168.2.7

      |                                       |

      +-192.168.1.8                           +-192.168.2.8

      |                                       |

      +-192.168.1.9                           +-192.168.2.9

      |                                       |

      +-192.168.1.10                          +-192.168.2.10

 

                                     [그림] 실습 구성도

 

 

(자리배치도)

-----------------------------------

200 201 202            203 204 205

-----------------------------------

206 207 208            209 210 211

-----------------------------------

212 213 214            215 216 217

-----------------------------------

218 219 220            221 222 223

-----------------------------------

224 225 226            227 228 229

-----------------------------------

 

자리 번호: 201 -> 번호 할당: 2

        - pcn0   192.168.1.2

        - pcn0:1 192.168.1.202

자리 번호: 203 -> 번호 할당: 2

        - pcn0   192.168.2.2

        - pcn0:1 192.168.2.202

 

 

 

-------------

1. 공통 작업

-------------

 

(준비사항) 전체적인 설정

- IPv6 NIC 설정은 없는것으로 한다.

- in.ndpd 데몬이 뜨지 않아야 한다.

- routing table 정보에 default router 설정이 없어야 한다.

- 라우터 설정은 "강사"가 설정한다.

 

# ls /etc/hostname6.*

# rm /etc/hostname6.pcn0

 

# ifconfig pcn0 inet6 down unplumb

# ifconfig lo0 inet6 down unplumb

# ifconfig -a

 

# pgrep -lf in.routed

# pgrep -lf in.rdisc

 

# pkill -9 in.routed

# pkill -9 in.rdisc

 

# pgrep -lf in.ndpd

# pkill in.ndpd    (# pkill -9 in.ndpd)

 

# route flush

 

 

 

 

 

---------------

2. Router 작업

---------------

 

(At Router)

 

인터페이스 설정

        pcn0   인터페이스(172.16.8.XXX)

        pcn0:1 가상인터페이스 설정(192.168.[1-2].1)

        pcn1   unplumb

라우터 설정

        in.routed -s

        in.rdisc -r

        ■ ip_forwarding ON

 

 

(1). 인터페이스 설정

 

(a). pcn0 설정

서버와 통신이 되는지 확인한다. 기존의 설정을 그래도 사용한다.

# ifconfig -a

# ping -s 172.16.8.254

 

(b). pcn0:1 가상인퍼테이스 설정(192.168.X.1)

# ifconfig pcn0:1 plumb up

# ifcofnig pcn0:1 192.168.[1-2].1 netmask 255.255.255.0 broadcast +

 

(c). pcn1 unplumb

NAT Device에 연결된 NIC는 unplumb 시켜 놓는다.

# ifconfig pcn1 down unplumb

 

 

 

(2). 라우터 설정

 

# route flush

 

# in.routed -s

# in.rdisc -r

# ndd -set /dev/ip ip_forwarding 1

 

# pgrep -lf in.routed

# pgrep -lf rdisc

# ndd -get /dev/ip ip_forwarding

 

# netstat -nr

(상대방 라우터가 반드시 보여야 한다.)

 

 

 

(3). 라우터 상태 점검(Router1, 예: 172.16.8.200)

 

(IP 설정 점검) Router1

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 172.16.8.200 netmask ffff0000 broadcast 172.16.255.255

        ether 0:c:29:ab:48:bd

pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.1.1 netmask ffffff00 broadcast 192.168.1.255

 

-> pcn1 unplumb 시킴

-> pcn0:1 IP 192.168.1.1 설정

 

 

(Routing Table 점검) Router1

# netstat -nr

Routing Table: IPv4

  Destination           Gateway           Flags  Ref   Use   Interface

-------------------- -------------------- ----- ----- ------ ---------

192.168.1.0          192.168.1.1          U         1     11  pcn0:1

192.168.2.0          172.16.8.205         UG        1      0  pcn0  <----- 정보 확인

172.16.0.0           172.16.8.200         U         1      5  pcn0

224.0.0.0            172.16.8.200         U         1      0  pcn0

127.0.0.1            127.0.0.1            UH       21   5418  lo0

 

 

(Router 설정 점검) Router1

# pgrep -lf in.routed

  567 in.routed -s

# pgrep -lf in.rdisc

  570 in.rdisc -r

# ndd -get /dev/ip ip_forwarding

1

 

 

 

(4). 라우터 상태 점검(Router2, 예: 172.16.8.205)

 

(IP 설정 점검) Router2

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 172.16.8.205 netmask ffff0000 broadcast 172.16.255.255

        ether 0:c:29:da:a8:1e

pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.2.1 netmask ffffff00 broadcast 192.168.2.255

 

-> pcn1 unplumb

-> pcn0:1 IP 192.168.2.1 설정

 

 

(Routing Table 점검) Router2

# netstat -nr

Routing Table: IPv4

  Destination           Gateway           Flags  Ref   Use   Interface

-------------------- -------------------- ----- ----- ------ ---------

192.168.1.0          172.16.8.200         UG        1      0  pcn0   <----- 설정 확인

192.168.2.0          192.168.2.1          U         1      1  pcn0:1

172.16.0.0           172.16.8.205         U         1     17  pcn0

224.0.0.0            172.16.8.205         U         1      0  pcn0

127.0.0.1            127.0.0.1            UH       45  75281  lo0

 

 

(Router 설정 점검) Router2

# pgrep -lf in.routed

 2223 in.routed -s

# pgrep -lf in.rdisc

 2225 in.rdisc -r

# ndd -get /dev/ip ip_forwarding

1

 

 

 

 

---------------

3. Host 작업

---------------

 

(At Client) 예: 192.168.2.2

 

(가정) 인터페이스는 Bridge Device 연결된 NIC1(pcn0)만 사용하는것으로 가정한다.

- 인터페이스 설정

        - pcn0 설정 (예: 192.168.[1-2].X)

        - pcn1 unplumb

        - Default Router 설정(192.168.[1-2].1)

- 테스트

 

 

 

(1). 인터페이스 설정

 

(a). pcn0 설정

# ifconfig pcn0 192.168.[1-2].X netmask 255.255.255.0 broadcast + up

 

(b). pcn1 unplumb

# ifconfig pcn1 down unplumb (-> 솔라리스 CDE 환경에서 작업)

# ifconfig -a

 

(c). Default Router 설정

# route flush

# route add default 192.168.[1-2].1

# netstat -nr

 

 

 

(2). Host 설정 점검

 

(IP 설정 점검) 192.168.2.2

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.2.2 netmask ffffff00 broadcast 192.168.2.255

        ether 0:c:29:4d:b1:ff

 

-> pcn1 unplumb

-> pcn0 IP 192.168.2.2

 

 

(Routing Table 점검) 192.168.2.2

# netstat -nr

Routing Table: IPv4

  Destination           Gateway           Flags  Ref   Use   Interface

-------------------- -------------------- ----- ----- ------ ---------

192.168.2.0          192.168.2.2          U         1      4  pcn0

224.0.0.0            192.168.2.2          U         1      0  pcn0

default              192.168.2.1          UG        1      5          <----- 설정 확인

127.0.0.1            127.0.0.1            UH       20  27673  lo0

 

 

 

 

(IP 설정 점검) 192.168.1.2

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.1.2 netmask ffffff00 broadcast 192.168.1.255

        ether 0:c:29:5d:97:e

 

 

(Routing Table 점검) 192.168.1.2

# netstat -nr

Routing Table: IPv4

  Destination           Gateway           Flags  Ref   Use   Interface

-------------------- -------------------- ----- ----- ------ ---------

192.168.1.0          192.168.1.2          U         1      1  pcn0

224.0.0.0            192.168.1.2          U         1      0  pcn0

default              192.168.1.1          UG        1     14        <----- 설정 확인

127.0.0.1            127.0.0.1            UH       35   7139  lo0

 

 

 

192.168.2.2 ------- Router1 ------------------ Router2 ------- 192.168.1.2

          192.168.2.1 172.16.8.205   172.16.8.200 192.168.1.1     |

                 |           |             |            |         |

-------------->  |           |             |            |         |

                             |             |            |         |

-------------------------->  |             |            |         |

                                           |            |         |

---------------------------------------->  |            |         |

                                                        |         |

----------------------------------------------------->  |         |

                                                                  |

----------------------------------------------------------------> |

 

(192.168.2.2) -> (192.168.2.1)

              -> (172.16.8.205)

                  -> (172.16.8.200)

                  -> (192.168.1.1)

                  -> (192.168.1.2)

 

# ping 192.168.2.1

# ping 172.16.8.205

# ping 172.16.8.200

# ping 192.168.1.1

# ping 192.168.1.2

 

 

 

(Trouble Shooting)

라우터에 이상이 있는 경우

- (a). 라우팅 테이블을 확인한다.

- (b). 라우터의 아이피를 재 설정해 본다.

 

호스트에 이상이 있는 경우

- (a). 아이피를 재 설정 해 본다.

 

 

 

 

 

4. Configuring IPv6-Over-IPv4 Tunnels

 

(1). 가상 NIC 추가 및 IPv6 설정 (예: 192.168.1.202 <----> 192.168.2.202)

- pcn0:1 (192.168.[1-2].20X) : 가상 인터페이스 설정

- pcn0에 IPv6 주소 생성

- ip.tun0 설정

 

(At 192.168.1.202) 192.168.1.2

 

(a). pcn0에 IPv6 주소 생성

# ifconfig pcn0 inet6 plumb up

 

(b). pcn0:1(192.168.1.20X) 설정

# ifconfig pcn0 addif 192.168.1.20X up

 

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.1.2 netmask ffffff00 broadcast 192.168.1.255

        ether 0:c:29:20:b:b6

pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.1.202 netmask ffffff00 broadcast 192.168.1.255     <----- IP 정보 확인

pcn0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2

        ether 0:c:29:20:b:b6

        inet6 fe80::20c:29ff:fe20:bb6/10                                <----- IPv6 정보 확인

 

 

(At 192.168.2.202) 192.168.2.2

 

(a). pcn0에 IPv6 주소 생성

# ifconfig pcn0 inet6 plumb up

 

(b). pcn0:1(192.168.2.20X) 설정

# ifconfig pcn0 addif 192.168.2.20X up

 

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.2.2 netmask ffffff00 broadcast 192.168.1.255

        ether 0:c:29:20:b:b6

pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.2.202 netmask ffffff00 broadcast 192.168.1.255     <----- IP 정보 확인

pcn0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2

        ether 0:c:29:20:b:b6

        inet6 fe80::20c:29ff:fe20:bb6/10                                <----- IPv6 정보 확인

 

 

 

(IP Tunnel 설정) 192.168.1.2   -> 192.168.2.2

                 192.168.1.202 -> 192.168.2.202

 

(At 192.168.1.202) 192.168.1.2

 

# ifconfig ip.tun0 inet6 plumb

# ifconfig ip.tun0 inet6 tsrc 192.168.1.202 tdst 192.168.2.202 up

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.1.2 netmask ffffff00 broadcast 192.168.1.255

        ether 0:c:29:20:b:b6

pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.1.202 netmask ffffff00 broadcast 192.168.1.255

pcn0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2

        ether 0:c:29:20:b:b6

        inet6 fe80::20c:29ff:fe20:bb6/10

ip.tun0: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 4

        inet tunnel src 192.168.1.202 tunnel dst 192.168.2.202

        tunnel hop limit 60

        inet6 fe80::c0a8:1ca/10 --> fe80::c0a8:2ca       <----- 정보 확인

 

 

(IP Tunnel 설정) 192.168.2.2   -> 192.168.1.2

                 192.168.2.202 -> 192.168.1.202

 

(At 192.168.2.202) 192.168.2.2

 

# ifconfig ip.tun0 inet6 plumb tsrc 192.168.2.202 tdst 192.168.1.202 up

# ifconfig -a

lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1

        inet 127.0.0.1 netmask ff000000

pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.2.2 netmask ffffff00 broadcast 192.168.2.255

        ether 0:c:29:4d:b1:ff

pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2

        inet 192.168.2.202 netmask ffffff00 broadcast 192.168.2.255

pcn0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2

        ether 0:c:29:4d:b1:ff

        inet6 fe80::20c:29ff:fe4d:b1ff/10

ip.tun0: flags=2200851<UP,POINTOPOINT,RUNNING,MULTICAST,NONUD,IPv6> mtu 1480 index 6

        inet tunnel src 192.168.2.202 tunnel dst 192.168.1.202

        tunnel hop limit 60

        inet6 fe80::c0a8:2ca/10 --> fe80::c0a8:1ca      <----- 정보 확인

 

# ping fe80::c0a8:1ca

# ping -s fe80::c0a8:1ca

 

=> 패킷 캡쳐를 통해 확인해 본다.

 

 

 

 

 

 

 

 

 

 

 

 

 


2008. 8. 29. 17:34

ref_icmp



  ICMP(Internet Control Messages Protocol)



1. ICMP?
IP 프로토콜의 문제점을 해결하기 위해 생성된 프로토콜로 데이터 전송시 제어 정보 전달
을 위한 프로토콜을 의미한다.

[Ref.] IP 프로토콜의 문제점
송신자 시스템이 수신자 시스템에게 데이터그램을 전송할때 비 연결성에 주안점을 둔 IP
프로토콜은 오류제어와 같은 메커니즘이 없으므로 이로 인해 다음과 같은 데이터 그램 전
송시 문제가 생길수 있다.
- 최종 목적지 도달불가나 호스트 사용불가를 탐지 불가능
- 경로 설정 루프의 오류로 인한 TTL 매캐변수 만료 전달 불가능
- 데이터그램 단편의 사라짐으로 인한 데이터그램이 전달되지 않을 가능성
- 단편화가 혀용되지 않고 데이터그램 크기가 중간 네트워크에 비해 너무 커서 데이터 그
  램을 발송 불가능
- 라우터에서 네트워크 혼잡으로 인한 수신 데이터그램을 처리 할 수 없을 경우가 발생



2. ICMP의 주요 기능
- 모든 IP 구현은 ICMP를 동반해야 한다.
- ICMP는 IP 패킷과 함께 실행된다. 즉 ICMP는 비록 IP 모듈에서 구현되지만 IP의 클라이언
  트라고 할 수 있다.
- ICMP는 오류보고나 제어 목적이지 IP 데이터 패킷을 신뢰할 수 있는 전송을 가능하게 하
  는 것은 아니다.
- ICMP는 첫번째 IP 데이터그램 단편화에 대해서만 오류를 보고한다. 즉, 단편 오프셋 필
  드가 0(zero)으로 설정된 IP 데이터그램 단편만을 보고한다는 의미이다. 나머지 데이터
  그램 단편에 대해 ICMP 메세지를 보내지 않게 하는 것이다.
- ICMP는 IP 데이터그램에 관한 오류보고 메커니즘이지 데이터그램 문제에 관한 오류 메시
  지는 생성하지 않는다.


[Ref.] ICMP 프로토콜 사용시 오류보고를 할수 없는 상황
- ICMP 메시지의 경로 설정 또는 전달시
  ICMP 오류메시지 생성시 메시지 개수가 늘고 네트워크 트래픽 발생 우려가 있다.
- IP 동보전송 또는 다중 전송 데이터그램 전송시
  동보전송이나 다중 전송시 발생하는 ICMP 오류메시지는 브로드캐스팅, 멀티캐스팅 데이터
  그램을 수신하는 각 노드가 ICMP 메시지를 생성하여 네트워크 트래픽 발생 우려
- 데이터링크 계층 동보전송 또는 다중 전송시
  위의 경우와 같음
- 루프백 주소 127.x.x.x 나 0.0.0.0과 같은 고유 IP 노드를 식별하지 않는 출발지 주소
  또는 네트워크 접두어가 0인 주소를 가진 데이터그램 전송시



3. ICMP 구조

송신 시스템에게 IP 전달에 대한 다양한 메시지를 전달하기 위한 프로토콜이다.


(1). 메시지 종류

오류보고 메시지(Error Reporting Messages)
 Type 3 : 목적지 도달 불가
 Type 4 : 발신지 억제
 Type 5 : 경로 재지정
 Type 11: 시간 초과
 Type 12: 매개변수 문제

질의 메시지(Query Messages)
 Type 8 : Echo Request
 Type 0 : Echo Reply
 Type 9 : Router 광고
 Type 10: Router 요청
 Type 13: Timestamp Request
 Type 14: Timestamp Reply
 Type 15: IP 정보 요구(구형)
 Type 16: IP 정보 응답(구형)
 Type 17: 주소마스크 요구
 Type 18: 주소마스크 응답


(2). 메시지 형식

총 8Bytes 헤더로 구성되어 있으며 처음 4Bytes는 모든 ICMP에서 동일하며 나머지 4Bytes
는 조금씩 다르게 구성되어 있다.


+------------+------------+---------------------------------+
|   Type     |    Code    |    Checksum                     |
+-----------------------------------------------------------+
|                Type 별로 다른 부분                        |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                   [그림] ICMP 메시지 형식


(3). ICMP & IP 상관 관계

ICMP는 TCP/IP 모델 중 Internet 계층에 속하며 IP 모듈 내 ICMP 모듈이 포함된 형태의 관
계성을 갖는다.

-------------------------------------------
Application Layer        (예) ping 명령어

-------------------------------------------
Transport Layer                |
                               V
-------------------------------------------
Internet Layer               ICMP
                             IP
-------------------------------------------
Network Interface Layer      Packet

-------------------------------------------
Hardware Layer               Signal

-------------------------------------------


(3-1) ICMP 캡슐화

ICMP 메시지는 인터넷과 라우터를 거쳐서 운반되어야 하므로 IP에 의해 캡슐화 되어 진다.
즉, IP가 없으면 상위 계층 프로토콜 데이터는 라우터 경계에 도달할 수 없게 된다. 이는
ICMP 메시지가 IP 데이터 그램의 데이터 부분에 포함된다는 것을 의미한다.

(특징) ICMP는 IP 데이터그램의 일부에 포함
       IP 헤더 중 프로토콜 종류 번호는 1로 명시


                  +-------------------------------------------+
                  |         ICMP 데이터         |
                  +-------------------------------------------+
                                                            
         +--------+-------------------------------------------+
         | IP헤더 |         IP 데이터그램        |
         +--------+-------------------------------------------+
                                                            
+--------+----------------------------------------------------+
|DataLink|                  프레임 데이터        |
|Header  |                      (MTU)                         |
+--------+----------------------------------------------------+

                    [그림] ICMP Encapsulation


(4). ICMP 유형


■ ICMP 유형 8, 0
에코 요청/응답(Echo Request/Reply Header)


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=8   |   Code=0   |    Checksum                     |
+-----------------------------------------------------------+
|       Identifier        |    Sequence Number              |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                [그림] ICMP Echo Request

Identifire 필드와 Sequence Number 필드는 프로토콜에 의해 전형적으로 정의되지는 않았
으며 송신자에 의해 임의로 사용될 수 있음.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=0   |   Code=0   |    Checksum                     |
+-----------------------------------------------------------+
|       Identifier        |    Sequence Number              |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                [그림] ICMP Echo Reply


■ ICMP 유형 3
목적지 미도달(Destination Unreachable)

IP패킷은 최적의 경로를 통해 목적지에 도착하려고 하지만 모든 패킷이 전달되지는 않는다.
일반적인으로 이 경우 패킷이 전달되지 않은 라우터에서 탐지되고 ICMP 유형 3을 출발지
호스트에게 전달한다.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=3   | Code=0~15  |    Checksum                     |
+-----------------------------------------------------------+
|                       Not Used                            |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                [그림] Network Unrereachable Messages


코드(Code)는 다음표를 참고하자.

[표] 코드 유형(Code)
----------------------------------------------------------------------------------
Code Description
----------------------------------------------------------------------------------
0 - 하드웨어 고장등의 이유로 네트워크에 도달할 수 없음. 라우터만 생성가능
1 - 호스트에 도달할 수 없음. 라우터에 의해서만 생성 가능
2 - 프로토콜에 도달할 수 없음. 즉, IP 데이터그램이 도착했으나 상위 TCP 프로토
   콜이 수행되지 않고 있다면 이 메시지가 보내짐. 목적지 호스트만 생성 가능
3 - 포트에 도달할 수 없음. 데이터그램이 향하고 있는 응용프로세스가 수행되지
   않고 있음. 목적지 호스트만 생성 가능함.
4 - 단편화가 필요하나 데이터그램의 DF 필드가 설정되어 있음. 즉 다른 네트워크로
   보내기 위해서는 데이터그램을 잘라야 하는데 자를 수 없음.
5 - 발신지 라우팅이 수행될수 없음. 발신지 라우팅 옵션에 정의된 한개 이상의 라
   우터를 방문 할 수 없음(엄격한 소스 라우팅이 설정된 경우에 발생)
6 - 목적지 네트워크가 알려져 있지 않음. 0번과는 다르게 목적지 네트워크에 대한
   정보를 가지고 있지 않은 경우 발생.
7 - 목적지 호스트가 알려져 있지 않음. 0번과는 다르게 목적지 호스트의 존재를 라
   우터가 알고 있지 못하는 경우 발생.
8 - 발신지 호스트가 고립되어 있음.
9 - 목적지 네트워크와의 통신이 관리상의 이유로 금지되어 있음.
10 - 목적지 호스트로의 통신이 관리상의 이유로 금지되어 있음.
11 - 명시된 서비스 유형에 대해 네트워크에 도달할 수 없음.
12 - 명시된 서비스 유형에 대해 호스트에 도달할 수 없음.
13 - 관리자가 필터를 유형에 대해 호스트에 도달할 수 없음.
14 - 호스트 우선순위가 위반되었기 때문에 호스트에 도달할 수 없음. 요청된 우선순
   위가 목적지를 향해서는 허용되지 않을 경우 발생.
15 - 우선순위가 충분히 높지 않아서 호스트에 도달할 수 없음. 네트워크 관리자가
   네트워크의 운용을 위해 우선 순위의 최소값을 설정하였는데 데이터그램의 우선
   순위가 최소값보다 낮을때 발생.
----------------------------------------------------------------------------------


■ ICMP Type 4
출발지 억제(Source Quench)

라우터 집중?

송신시스템이 100Mbps급 이더넷을 통해 라우터로 패킷을 보내지만 라우터 외부 이더넷 인
터페이스가 1.544Mbps 밖에 되지 않는다면 일시적으로 라우터 버퍼는 더 이상 송신 시스템
에서 보내온 패킷을 받지 못한 상태에 빠지게 된다. 이것을 라우터 집중이라고 한다.


해결책

집중현상을 보이고 있는 라우터가 송신자 시스템에게 버퍼가 가득차 더 이상 패킷을 받을
수 없다는 메시지를 보냄으로써 해결할 수 있으며, 이는 ICMP 유형 4를 사용하여 전달하면
된다.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=4   |   Code=0   |    Checksum                     |
+-----------------------------------------------------------+
|                       Not Used                            |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                [그림] Route Source Quench



■ ICMP Type 5
라우트 재지정(Route Redirection)

라우터간에 서로 경로 설정표를 주고 받음으로써 경로 설정에 관한 최적의 정보 또는 최
적에 가까운 정보를 갖게 되지만 호스트는 최소한 경로 설정 정보를 갖도록 설계 된다.
이 때 호스트는 데이터그램을 전달하도록 하기 위해 라우터에서 제공하는 최적의 경로로
데이터그램을 전달하도록 하기 위해 라우터에서 제공하는 최적의 경로로 데이터그램을 전
달하려고 하며 라우터가 자기 구간의 부하나 트래픽으로 인해 다른 라우터에게 데이터그
램을 전송하기 위해 생성되는 메시지이다.

라우터가 송신하고자 하는 데이터그램을 좀 더 좋은 경로로 보내기 위해 다수 라우터 중
최적의 라우터를 탐지할 경우 이를 알리고자 위해서다.


                                RIP/OSPF
Internet -------- Router1 ------------------ Router2 --------- Internet
               172.16.8.254       |        172.16.0.1
                                  |
                            HOSTA(172.16.8.XXX)

- RIP(Routing Information Protocol)
- OSPF(Open Shortest Path First)


■ ICMP Type 9
라우터 광고(Route Advertisement)

ICMP 유형 9, 10은 호스트들이 직접 연결된 네트워크의 모든 라우터를 동적으로 발견할
수 있게 해 주는 ICMP 라우터 발견 메커니즘을 구현하기 위해서 사용한다. 라우터가 사용
하는 설정 프로토콜과 상관없이 모든 라우터를 찾을 수 있다.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=9   |   Code=0   |        Checksum                 |
+-----------------------------------------------------------+
| Number of  | Address    |        Life Time                |
| Address    | Entry Size |                                 |
+-----------------------------------------------------------+
|             Router Address 1                              |
+-----------------------------------------------------------+
|             Router Preference 1                           |
+-----------------------------------------------------------+
|             Router Address 2                              |
+-----------------------------------------------------------+
|             Router Preference 2                           |
+-----------------------------------------------------------+
|             .....                                         |
+-----------------------------------------------------------+

                [그림] Route Advertisement


한 세그먼트에 존재하는 호스트들은 기본 게이트웨이 IP 주소를 구성할 필요가 없다. 라우
터는 ICMP 유형 9를 이용하여 매 7분 ~ 10분 간격으로 세그먼트내에 존재하는 시스템에게
메시지를 송부한다.


■ ICMP Type 10
라우터 선택 메시지(Route Solicitation)

ICMP 유형 10 즉, 라우터 선택 메시지는 호스트 시스템이 지역에 존재하는 IP 주소를 획득
하기 위해 사용되어 진다. 호스트가 라우터의 주소를 발견하기 위해 사용한다. 호스트는
같은 세그먼트내에 존재하는 라우터를 발견하기 위해 ICMP 유형 10을 브로드캐스트나 멀
티게스트를 이용하여 전송한다. 그럼 라우터는 이 메시지를 받고, 라우터는 ICMP 유형 9
(라우터 광고 메시지)를 통해 응답한다. 이 때 호스트는 매 7분 ~ 10분 간격으로 부터
ICMP 유형 9 메시지를 받게 된다.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=10  |   Code=0   |    Checksum                     |
+-----------------------------------------------------------+
|       Identifier        |    Sequence Number              |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                [그림] ICMP Echo Reply


■ ICMP Type 11
시간 초과(Time Exceeded)

(a) ICMP 시간 초과 메시지 생성 상황(1)
TTL 필드의 원래 설정값이 너무 낮거나 데이터그램의 여행 경로가 너무 길거나 무한 루프
가 발생한 경우에 생성된다.

(b) ICMP 시간 초과 메시지 생성 상황(2)
데이터그램이 단편화 되어 있음에도 불구하고 단편화된 데이터그램이 모두 도달하지 않아
재조립이 불가능한 경우에 생성된다. 특정 데이터그램이 단편화 되면 최종 호스트는 단편
화된 데이터그램에 대해 재조립에 책을을 져야 한다. 단편화된 데이터그램은 개별적으로
라우터를 통과하여 목적지까지 여행을 하게 된다. 만약 특정 단편화된 데이터그램이 경로
여행 중 없어진다면 호스트는 데이터그램을 재조립할 수 없으므로 전체 데이터그램을 삭
제하게 된다.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
|   Type=11  |  Code=0~1  |    Checksum                     |
+-----------------------------------------------------------+
|                       Not Used                            |
+-----------------------------------------------------------+
|                          데이터                           |
+-----------------------------------------------------------+

                [그림] Time Exceeded

Code 0 : TTL 만료로 인한 시간 초과
Code 1 : 데이터그램의 미도착으로 인한 시간 초과


■ ICMP Type 13, 14
시간 요청, 응답(Timestamp Request / Reply)

IP 노드는 자체의 시계를 유지하고 있다. ICMP 유형 13과 14 메시지는 원격 IP 노드로 부
터 시간을 알아 보기 위해 사용된다. 이는 NTP라는 프로토콜이 존재하지만 가장 단순화된
IP 노드의 시간을 동기화 한다.


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
| Type=13,14 |   Code=0   |    Checksum                     |
+-----------------------------------------------------------+
|       Identifier        |    Sequence Number              |
+-----------------------------------------------------------+
|                 Original Timestamp                        |
+-----------------------------------------------------------+
|                 Receive Timestamp                         |
+-----------------------------------------------------------+
|                 Transmit Timestamp                        |
+-----------------------------------------------------------+

                [그림] Timestamp Request / Reply


Type 필드 13 : 시간 요청
Type 필드 14 : 시간 응답
협정 시계시(UT) 자정으로 부터 계산함. 밀리초 단위로 계산
시작 시간(Original Timestamp)은 송신 호스트에서 지정
수신 시간(Receive Timestamp)은 수신 호스트에서 지정
변화 시간(Transmit Timestamp)은 ICMP 응답 메시지가 출발하는 시점의 시간을 지정


■ ICMP Type 15, 16
정보 요청, 응답(Information Request, Reply)

ICMP 요청 15는 요청 호스트의 IP 주소를 알아내기 위한 거이며, 유형 16은 응답을 되돌려
주기 위해 사용된다. 더이상 사용치 않고 있으며 RFC 1122에서 사용하지 말것 을 권장하고
있다. RARP, BOOTP 또는 DHCP를 사용할 것을 권장하고 있다.

- ICMP 유형 15 : 요청한 호스트 IP 주소를 알기 위함
- ICMP 유형 16 : 요청한 호스트 IP 주소에 대한 응답


■ ICMP Type 17, 18
주소 마스크 요청, 응답(Address Mask Request / Reply)

ICMP 유형 17, 18은 특정 호스트가 요청한 서브넷 마스크를 획득하고 사용하기 위해 생성
된다. 메시지가 생성되는 위치는 호스트이다. 디스크 없는 워크스테이션과 같은 자체 구성
시스템이 부트 할 때 자체의 서브넷 마스크를 발견할 수 있도록 하기 위함.

- ICMP 유형 17 : 요청한 호스트의 서브넷 마스크를 알아 보기 위함
- ICMP 유형 18 : 요청한 호스트의 서브넷 마스크에 대한 응답


    1Bytes       1Bytes                  2Bytes
|<---------->|<---------->|<------------------------------->|
+------------+------------+---------------------------------+
| Type=17,18 |   Code=0   |    Checksum                     |
+-----------------------------------------------------------+
|       Identifier        |    Sequence Number              |
+-----------------------------------------------------------+
|                     Address Mask                          |
+-----------------------------------------------------------+

                [그림] ICMP Address Mask

2008. 8. 29. 17:27

ref_ipmp

          

     
  IPMP(Internet Protocol Multi-Pathing, IP Multi-Pathing)
     



INDEX
_____________________

1. IPMP Feature
2. IPMP Overview
3. IPMP Configuration Type
4. IPMP Implementation
5. Reference



현재 썬에서는 (a)IPMP, (b)Sun Trunking Software 등을 제공함으로써 썬 고객들의 네트워
크 대역폭에 대한 요구를 충족시키고 있다. IPMP Software는 운영체제에 기본 내장 되어
있지만 Sun Trunking Software는 기본 내장되어 있지 않다.



0. IPMP의 필요성
______________________

현재 사용하고 있는 방식의 NIC 카드의 문제점은 Hub, Switch 같은 장치와 연결되는 케이
블에 이상이 있는 경우 서버의 통신은 문제가 발생되게 된다. 그리고 NIC 카드가 노후화로
인해 이상이 있다고 하더라도 문제가 발생된다.

이런 문제점을 해결하기 위해서는 같은 네트워크에 여러개의 네트워크 인터페이스(NIC)를
달고 IPMP 설정을 통해서 높은 대역폭을 제공하면서 각 NIC의 Failover 기능을 수행할 수
있도록 설정하면 문제가 해결된다.


------+-----+-----+-----+-----------------+-----------
      |     |     |     |                 |
      |     |     |     |                 |
  +--qfe0--qfe1--qfe2--qfe3--+          CLINET
  |                          |
  |          SERVER          |
  |                          |
  +--------------------------+

       [그림] IP Multipath Configuration


[Ref.] Sun Trunking Software
Sun Trunking Software는 솔라리스 운영체제에 기본 내장되어 있는 프로그램이 아니므로
라이센스 비용을 들여서 사야 한다.

Sun Trunking software is not part of the Solaris OE and must be purchased separately.
Sun Trunking software is an aggregation technology that:

* Up to eight full-duplex ports on two Sun Quad FastEthernet™ (qfe) adapters to 
  obtain 800-Mbps full-duplex performance
* Links up to two full-duplex ports on a Sun™ Gigabit Ethernet Adapter (ge) to
  obtain 2-Gbps full-duplex performance between a Sun server and a Sun Trunking
  compatible switch.


                        SERVER

                       ||||||||
                       ||||||||
                       ||||||||        Network links are aggreagted
                       ||||||||  ----> in to a fat network pipe.
                       ||||||||
                       ||||||||
                       ||||||||

                        Switch

                           |
   ------------------------+---------------------------
         |       |       |       |       |      |
       ClientA ClientB ClientC ClientD ......



1. IPMP Feature
______________________

솔라리스 9버전부터 내장되기 시작했는데 9버전이 나올당시에 출시 되었던 8버전에도 기술
이 내장되었다.


(1). IPMP Feature

■ Eliminates a single network adapter as a single point-of-failure in these cases:
   * Network adapter failure detection (failover)
   * Network adapter repair detection  (failback)

■ Provides outbound load spreading when traffic is flowing to multiple destinations.

■ Enables interfaces to failover within approximately 10 seconds when using the
   default configuration.

■ Can be configured by adjusting the parameters in the /etc/default/mpathd file.

■ Can be configured for both IPv4 and IPv6.

■ Allows interfaces to be configured as Standby Interfaces. These types of
   interfaces are only used for failover and are not used for outbound load
   spreading, unless they are explicitly chosen by an application.


(2). IPMP Requirements

■ The Solaris 8 10/00 OE, as a minimum.

■ Unique media access control (MAC) addresses must be configured on each network
   interface.

   - The default configuration for most Sun network adapters has all network
     interfaces on a specific server using the same MAC address.
   - IPMP requires that all interfaces exist on the same network. Switched
     configurations use MAC addresses when making network decisions.
   - Therefore, you must change the system’s default configuration for MAC
     addresses to avoid a MAC address conflict.

■ Multiple network adapter interfaces must be connected on each subnet.
   - You can configure IPMP with a single network interface to take advantage of
     network failure detection. To use the full benefit ofIPMP, make sure that two
     or more network interfaces are connected to the same subnet.

■ A network adapter group name must be assigned to IPMP interfaces.

   - Interfaces that are to be deployed as multipath interfaces must belong to a
     multipath group. The in.mpathd multipath process uses the multipath group.
     Use a meaningful name that does not include spaces when you choose a group
     name. The multipath name is local to the system and is not used across the
     network.

■ A test address is assigned to an interface.

   - The multipath process uses test addresses, which must be routable addresses,
     to monitor the status of each individual interface. Use the test addresses to
     detect failure and recovery of an interface. These addresses are deprecated at
     configuration time to make sure that they cannot be used to pass network
     traffic from other applications.

■ Additional hosts must exist on the same subnet.

    - The test interfaces use ICMP echo request, reply, or both to hosts that they
      reach by addressing the 224.0.0.1 multicast group or the default router, as
      listed in the /etc/defaultrouter file.


솔라리스 8 10/00(2000.10) 버전부터 이 기능이 내장 되었습니다.
■ SUNWcsr(운영체제 core 패키지)에 포함되어 있습니다.
■ 각 NIC는 유일한 MAC 주소를 가져야 한다.
■ in.mpathd 데몬의해서 동작 된다.
■ 각 NIC에 Test Address가 존재해야 한다.
■ Test NIC는 각 NIC와 224.0.0 또는 동일한 Default router 접근할수 있
  어야 한다.


(3). Interface Failure Detection and Repair

The in.mpathd process can detect both the failure and the repair of an interface by:

* Sending and receiving ICMP echo requests and responses through the interface.
* Monitoring the internal IFF_RUNNING flag on the interface.



2. IPMP Overview
_______________________

IPMP는 다음과 같은 2가지 기능을 갖습니다.
- Failover
- Failback

(1). Failover
는 하나의 시스템에 여러개의 NIC(Network Interface Card)를 사용할때 NIC 카드를
Grouping 해서 그 중 하나의 NIC가 통신 실패(Fail)하는 경우 이를 점검하고 정상적인
다른 NIC로 Failover 해 주는 기능입니다.

(2). Failback
장애(통신 실패, Fail)가 발생한 NIC를 복구한 후(Failover 기능), 관리 자의 특별한 설
정 없이 자동으로 원래 설정으로 돌려 주는 기능입니다.



3. IPMP Configuration Type
______________________________

IPMP를 설정 하는 방법은 다음과 같이 2가지가 존재합니다.
- Standby NIC 갖는 환경     (Active-Standby)
- Standby NIC 갖지 않는 환경(Active-Active)


(1). Standby NIC 갖는 IPMP 환경
서비스를 하는 NIC와 서비스를 하지 않는 NIC를 그룹으로 묶고(Grouping) 실제 서비스를
하지 않는 NIC로 서비스를 하고 있는 NIC에 대해 Failover 기능을 제공해 주기 위한 환경
입니다. 다시 말해서 서비스를 안정적으로 가지고 가기 위해서 백업 NIC를 갖는 것과 같
습니다.


(2). Standby NIC 갖지 않는 IPMP 환경
그룹으로 묶여있는 NIC들이 네트워크 서비스를 각각하고 있다가 그룹내의 NIC 하나가 통신
실패(Fail)이 발생한 경우 남아있던 정상적인 NIC로 Failover 하는 환경입니다. 다시 말해
서 서비스를 안정적으로 가지고 가기 위해서 그룹내의 모든 NIC가 활성화 상태에 있다가
하나의 NIC가 이상이 있지만 다른 NIC가 정상 서비스를 하는 것입니다.


(3). 두 가지 방법의 차이점
<Standby NIC 갖지 않는 IPMP 환경>
- 그룹내의 하나의 NIC가 이상이 있는 경우(통신 실패가 있는 경우) 다른 NIC가 다른 NIC
  들이 서로 Failover 기능을 제공한다.

<Standby NIC 갖는 IPMP 환경>
- 그룹내의 NIC 중 Standby NIC가 서비스 NIC의 Failover 기능을 제공하지만 반대로
  Standby NIC에 대한 Failover 기능은 제공되지 않는다.


[Ref.] Failover, Failback 기능을 사용하기 위해서는 Test NIC(Logical Interface) 필요
<Standby NIC 갖지 않는 IPMP 환경>
- 그룹내 모든 NIC에 Test NIC(Logical Interface) 필요
 
<Standby NIC 갖는 IPMP 환경>
- Test NIC(Interfaec)로만 설정한다.



4. IPMP Implementation
______________________________

(1). Standby NIC 갖는 IPMP 설정

    +=======HOSTA=======+
    |                   |
    |               hme0   (192.168.8.100)
    |               hme0:1 (192.168.8.101)
    |
    |               hme1   (192.168.8.200)
    |               hme1:1 (192.168.8.201)
    |                   |
    +===================+

    Grouping : hme0, hme1 (testgroup)
    Test NIC : hme0:1(For hme0), hme1:1(For hme1)



(현재 설정)
# cat /etc/release
솔라리스 8 버전 이상(Solaris 8 10/00 이상)

# eeprom local-mac-address?=true

# ifconfig hme0 down unplumb
# ifconfig hme1 down unplumb

# ifconfig hme0 plumb 192.168.8.100 group testgroup up
# ifconfig hme0 addif 192.168.8.101 deprecated -failover up
(# ifconfig hme0 addif 192.168.8.101 deprecated netmask + broadcast + -failover up)

# ifconfig hme1 plumb 192.168.8.200 group testgroup up
# ifconfig hme1 addif 192.168.8.201 deprecated -failover up
(# ifconfig hme1 addif 192.168.8.201 deprecated netmask + broadcast + -failover up)

# pgrep -lf in.mpathd

(주의) 만약 in.mpathd 데몬이 떠 있지 않은 경우 띄워 준다.
# ps -ef | grep in.mpathd
# /sbin/in.mpathd


-------------------------- Solaris 9 x86 on VMWare TEST ---------------------------
[EX] Active-Active IPMP 설정(Solaris 9 x86 on VMWare)

    +=======HOSTA=======+
    |                   |
    |               pcn0   (192.168.8.100)
    |               pcn0:1 (192.168.8.101)
    |
    |               pcn1   (192.168.8.200)
    |               pcn1:1 (192.168.8.201)
    |                   |
    +===================+

    Grouping : pcn0, pcn1 (testgroup)
    Test NIC : pcn0:1(For pcn0), pcn1:1(For pcn1)


0. 전제 조건
- NIC 2장 모두 NAT Device에 연결한다.


1. 작업 순서
- NIC1 -> (Bridge -> NAT)
- IPMP 설정
 pcn0   (192.168.10.100)
 pcn0:1 (192.168.10.101)
 pcn1   (192.168.10.200)
 pcn1:1 (192.168.10.201)
- TEST

(a) NIC1 (Bridge -> NAT)

(b). IPMP Configuration
# cat /etc/release
                         Solaris 9 9/05 s9x_u8wos_05 x86
           Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 01 August 2005

# ifconfig pcn0 down unplumb
# ifconfig pcn1 down unplumb

# ifconfig pcn0 plumb 192.168.10.100 group testgroup up
# ifconfig pcn0 addif 192.168.10.101 deprecated -failover up

# ifconfig pcn1 plumb 192.168.10.200 group testgroup up
# ifconfig pcn1 addif 192.168.10.201 deprecated -failover up

# pgrep -lf in.mpathd


(c). TEST

(At Clinet)
# ping -s 192.168.10.100
-> 메세지 확인

(At Server)
# if_mpadm -d pcn0
-> Clinet 확인
# ifconfig -a
-> pcn0 설정 값 확인

# if_mpadm -r pcn0
-> Client 확인
# ifconfig -a
-> pcn0 설정 값 확인

(At Client)
# ping -s 192.168.10.200

(At Server)
# if_mpadm -d pcn1
-> Client 확인
# ifconfig -a
-> pcn1 설정 값 확인

# ip_mpadm -r pcn0
-> Client 확인
# ifconfig -a
-> pcn0 설정 값 확인

------------------------------------------------------------------------------------




(부팅시 설정)
# cat /etc/release
# eeprom local-mac-address?=true

# cat /etc/hosts
.....
192.168.8.100      solaris100        # Data address for hme0
192.168.8.101      solaris100-hme0   # hme0:1 Test address for hme0
192.168.8.200      solaris200        # Data address for hme1
192.168.8.201      solaris200-hme1   # hme1:1 Test address for hme1


# cat /etc/hostname.hme0
192.168.8.100 broadcast + netmask + group testgroup up \
addif 192.168.8.101 deprecated netmask + broadcast + -failover up

# cat /etc/hostname.hme1
192.168.8.200 broadcast + netmask + up group testgroup \
addif 192.168.8.201 deprecated netmask + broadcast + -failover up


* 192.168.8.XXX or solarisXXX    Assigns the address associated with the solarisXXX
                                 name.

* netmask +                      Looks up the mask in the netmasks database.

* broadcast +                    Results in a default broadcast address appropriate
                                 for the address and netmask.

* group testgroup                Assigns testgroup as the name for a IPMP group.

* up                             Marks the interface as “up,” and initializes the
                                 hardware.

* addif 192.168.8.XXX            Creates the next unused logical interface, and
                                 assigns it the IP address associated with the
                                 solarisXXX-hmeX name.

* deprecated                     Marks the address as a deprecated address.
                                 Addresses that are marked as deprecated are not
                                 used as source addresses for outbound packets
                                 unless either there are no other addresses
                                 available on this interface or the application is
                                 bound to this address explicitly. The output from
                                 the ifconfig -a command shows DEPRECATED as
                                 one of the flags associated with this interface.

* -failover                      Marks the address as a non-failover address.
                                 Addresses that are marked in this way do not fail
                                 over when the interface fails. The output from the
                                 ifconfig -a command shows NOFAILOVER as
                                 one of the flags associated with this interface.


(2). Test (Failover, Failback)


    ======= HOSTA =======      |      ======= HOSTB =======
         Active    hme0 -------|------hme0  # ping -s HOSTA       
                   hme0:1      |
         Active    hme1 -------|
                   hme1:1      |
    =====================      |      =====================

(a). HOSTB에서 HOSTA로 ping 명령어에 -s 옵션을 사용하여 hme0(192.168.8.100)
     으로 연속적인 ICMP echo reply 신호를 받는다.
(b). HOSTA에서 hme0의 NIC의 LAN 선을 뽑는다.
(c). HOSTB에서 계속된 ping 시도가 되고 있는지 확인한다.
     (잠시 끊김현상이 발생하기는 하지만 바로 복구되는 것을 확인한다.)
(d). HOSTA에서 ifconfig 명령어를 사용하여 hme0에 대한 IP 설정값을 확인한다.
     (0.0.0.0 으로 설정된것을 확인할수 있다.)
(e). 잠시후에 HOSTA에서 ifconfig 명령어를 사용하여 hme0에 대한 IP 설정값을
     확인한다.(Failback 기능으로 인해 IP가 원래대로 설정이 돌아 온것을 확인
     한다.)
   


(3). Standby NIC를 갖는 IPMP 설정

(현재 설정)
부팅시의 설정 사항을 보면 알수 있을 것이다.

(부팅시 설정)
* /etc/hostname.hme0
192.168.8.100 netmask + broadcast + group testgroup deprecated -failover up

* /etc/hostname.hme1
192.168.8.200 netmask + broadcast + group testgroup up \
addif 192.168.8.201 deprecated netmask + broadcast + standby up


(4). Test(Failover, Failback)
테스트도 "4.(2)" 테스트와 비슷하게 수행한다.



5. /etc/default/mpathd & in.mpathd
____________________________________


The starting of the in.mpathd daemon is controlled by the
TRACK_INTERFACES_ONLY_WITH_GROUPS parameter in the
/etc/default/mpathd file.

If the TRACK_INTERFACES_ONLY_WITH_GROUPS variable is set to yes, the
ifconfig utility’s group option starts the in.mpathd process
automatically. That is, as soon as you use the ifconfig utility with the
group option in the command, the in.mpathd process starts. If the
TRACK_INTERFACES_ONLY_WITH_GROUPS variable is set to no, the
/etc/rcS.d/S30network.sh run control script starts the in.mpathd
process at boot time.

# cat /etc/default/mpathd
#
#pragma ident   "@(#)mpathd.dfl 1.2     00/07/17 SMI"
#
# Time taken by mpathd to detect a NIC failure in ms. The minimum time
# that can be specified is 100 ms.
#
FAILURE_DETECTION_TIME=10000
#
# Failback is enabled by default. To disable failback turn off this option
#
FAILBACK=yes
#
# By default only interfaces configured as part of multipathing groups
# are tracked. Turn off this option to track all network interfaces
# on the system
#
TRACK_INTERFACES_ONLY_WITH_GROUPS=yes



6. TEST 하기 위한 명령어
_________________________

To verify the system’s failover configuration, or to change the operational
status of IPMP interfaces, use the if_mpadm utility. You can use this utility
to take an interface offline (detach), by forcing a failover, and verifying
that an alternate interface takes over as expected. If configuration errors
occur, they appear at this stage. Also, use the if_mpadm utility to reattach
a detached interface.

# if_mpadm -d hme0  (Detach an online interface)
# if_mpadm -r hme0  (Reattach an offline interface)

[Ref.] 메세지 모니터링을 위해서 console window를 띄어 놓고 테스트 하면 좋다.
# dtterm -C &



7. Reference
________________

Sun Book : Network Administration for the Solaris 9 Operating Environment
           (SA-399) "Modules 6" Reference

2008. 8. 29. 16:39

ref_ndd

 

                                         

 

                     ndd CMD

 

 

 

 

 

1. ndd Overview

__________________

 

get and set driver configuration parameters

 

     ndd gets and sets selected configuration parameters in  some

     kernel  drivers.  Currently,  ndd  only supports the drivers

     that implement the TCP/IP  Internet  protocol  family. Each

     driver  chooses  which parameters to make visible using ndd.

     Since these parameters are usually tightly  coupled  to  the

     implementation,  they  are  likely to change from release to

     release. Some parameters may be read-only.cl

 

     If the -set option is omitted, ndd queries the named driver,

     retrieves the value associated with the specified parameter,

     and prints it. If the  -set  option  is  given,  ndd  passes

     value,  which  must  be  specified, down to the named driver

     which assigns it to the named parameter.

 

     By convention, drivers that support ndd also support a  spe-

     cial  read-only  parameter  named ``?'' which can be used to

     list the parameters supported by the driver.

 

ndd 명령어를 통해 많은 네트워크 설정값을 설정할 수 있다. 하지만 ndd 명령어로 설정한

값은 부팅시에는 적용되지 않고 현재 적용만된다. 부팅시에도 적용하도록 설정하기 위해

서는 /etc/init.d/inetinit 시작 스크립트를 사용해도 되고 또는 /etc/rc2.d 디렉토리에

개인적인 시작 스크립트를 생성하여 기능을 추가해도 된다.

 

 

 

 

 

2. 네트워크 장치 & 프로토콜

 

(1). 네트워크 프로토콜

 

/dev/arp

/dev/rarp

/dev/icmp

/dev/tcp

/dev/ip

 

 

(2). 네트워크 장치

 

/dev/hme

/dev/qfe

 

 

(3). 사용예

 

# ndd /dev/arp \?

# ndd /dev/rarp \?

# ndd /dev/icmp \?

# ndd /dev/tcp \?

# ndd /dev/ip \?

 

 

 

 

 

3. ndd 명령어

___________________

 

(3.1) 기본사용법

 

ndd [ -get | -set ] /dev/ip [ \? | ip_forwarding ]

                      /dev/arp

 

# ndd /dev/ip \?

# ndd -get /dev/ip \?

 

# ndd /dev/ip ip_forwarding

# ndd -get /dev/ip ip_forwarding

 

# ndd -set /dev/ip ip_forwarding 1

 

 

 

(3.2) 대표적인 인자(Driver Parameter)

 

# ndd -get /dev/ip ip_forwarding

0                    IP Forwarding : Off

1                    IP Forwarding : On

 

# ndd -get /dev/hme link_speed

0                    NIC Link Speed : 10Mbps

1                    NIC Link Speed : 100Mbps

 

# ndd -get /dev/hme link_mode

0                    NIC Link Mode : Half Duplex

1                    NIC Link Mode : Full Duplex

 

# ndd –get /dev/hme link_status

0                    NIC is down

1                    NIC is up

 

# ndd –get /dev/hme instance

0                    NIC 1st

1                    NIC 2nd

2                    NIC 3rd

...

 

Instance NIC카드 넘버

 

[참고] Virtual Interface Number

To set more than 256 virtual ip addresses. By default solaris can have 256 virtual

ip addresses per interface. This default can be be change using this command.

 

# ndd -get /dev/ip ip_addrs_per_if

256

 

# ndd -set /dev/ip ip_addrs_per_if <Number>    (Number 1 ~ 8192)

 

 

 

 

 

 

 

 

2008. 8. 11. 00:35

Chapter 9. 원격 접속과 파일전송

                  Remote Connection & File Transfer

 

 

 

 

INDEX

______________________________________________________

 

1. Introducing an Example Network

2. Remote Connection History

3. Remote Connection & File Transmission for System V

4. Remote Connection & File Transmission for BSD

5. Remote Connection & File Transmission for Securiy

______________________________________________________

 

 

 

 

1. 네트워크 관련 용어

 

LAN(Local Area Network)

A network that covers a small area, usually less than a few thousand feet or meters.

 

WAN(Wide Area Network)

A network that can span thousands of miles or kilometers.

 

[참고] LAN(근거리 통신망, Local Area Network)

LAN[]이란 300m 이하의 통신회선으로 연결된 PC, 메인프레임, 워크스테이션 들의 집합을

말한다. LAN은 컴퓨터 사이의 전류나 전파신호가 정확히 전달될 수 있는 거리, 즉 한 기관

의 빌딩 내에 설치된 컴퓨터 장비들을 직원들이 가장 효과적으로 공동 사용할 수 있도록

연결된 고속의 통신망이다.

 

1970년대 말에서 1980년초 제록스사의 한 연구소에서 LAN에 관한 중요한 업적이 이루어졌

. 이 연구소에서 이더넷(Ethernet ; 공기가 없는 진공상태의 공간에 전파가 흘러갈 수

있는 물질이 존재한다고 가정하여 지은 독일어 단어 "에테르"에서 따온 말)이라고 이름을

붙인 컴퓨터 연결방법이 처음으로 실용화되었다.

 

[참고] WAN(광역 통신망, Wild Area Network)

WAN[]이란 지리적으로 흩어져 있는 통신망을 의미하는 것으로서 근거리통신망, LAN

구별하여 보다 넓은 지역을 커버하는 통신구조를 나타내는 용어로 사용된다. 보통 LAN

범위는 1개의 빌딩이나 학교, 연구소 및 생산공장 등의 일정 구역내인 것에 반해, WAN

넓은 지역을 연결하는 네트웍를 지칭하는 것으로 지방과 지방, 국가와 국가, 또는 대륙과

대륙 등과 같이 지리적으로 완전하게 떨어져 있는 장거리 지역 사이를 연결하고 있는 통신

망이다.

 

광역통신망은 사설망일 수도 있고 임차한 망도 될 수 있지만, 이 용어는 보통 공공망까지

를 포함하는 개념을 내포하고 있다. 지역적으로 LAN WAN 사이에 위치하는 중간정도 크기

의 네트웍을 특히 MAN이라고 부른다.

 

 

 

 

 


 

2. 원격접속과 파일전송

 

Remote Connection & File Transmission History

 

-----------+----------+--------------+--------------

           | System V |      BSD     |   Linux

-----------+----------+--------------+--------------

Remote     | telnet   |  rlogin, rsh |    ssh

Connection |          |              |

           |          |              |

File       | ftp      |  rcp         |    scp, sftp

Transfer   |          |              |

-----------+----------+--------------+--------------

 

 

[참고] 패킷 암호화에 대해서

위의 표에 있는 System V / BSD 계열의 모든 명령어는 패킷을 암호화 시키지 않는 단점을

가지고 있다. 그래서 원격 접속과 파일 전송을 할 때 패킷의 내용을 노출 시킬수 있게 된

. 그래서 최근에는 ssh, scp, sftp 프로그램과 같이 패킷을 암호화 할수 있는 프로그램

을 권장하고 있다.

 

 

[EX] 패킷 암호화 실습

[TERM1] # snoop HOSTA HOSTB

[TERM2] # telnet HOSTB

 

 

 

 

 

3. 원격접속 & 파일전송 명령어(System V 계열)

 

Remote Connection & File Transmission for System V

telnet 명령어

ftp 명령어

 

 

 

(1). telnet CMD

____________________

 

     telnet - user interface to a remote system using the  TELNET

     protocol

 

     The telnet utility communicates with another host using  the

     TELNET  protocol. If telnet is invoked without arguments, it

     enters command mode, indicated by its  prompt,  telnet>.  In

     this  mode, it accepts and executes its associated commands.

     See USAGE, telnet Commands, below. If  it  is  invoked  with

     arguments, it performs an open command with those arguments.

 

     If, for example, a host is specified as @hop1@hop2@host, the

     connection  goes  through  hosts  hop1 and hop2, using loose

     source routing to end at host. If a leading ! is  used,  the

     connection  follows  strict  source  routing. Note that when

     telnet uses IPv6, it can only use loose source routing,  and

     the connection ignores the !.

 

     Once a connection has been opened, telnet enters input mode.

     In  this  mode,  text  typed is sent to the remote host. The

     input mode entered will be either "line mode", "character at

     a  time",  or  "old  line  by line", depending upon what the

     remote system supports.

 

     In "line mode", character processing is done  on  the  local

     system,  under  the control of the remote system. When input

     editing or character echoing is to be disabled,  the  remote

     system  will relay that information.  The remote system will

     also relay changes to any special characters that happen  on

     the remote system, so that they can take effect on the local

     system.

 

     In "character at a time" mode, most text  typed  is  immedi-

     ately sent to the remote host for processing.

 

     In "old line by line" mode, all text is echoed locally,  and

     (normally) only completed lines are sent to the remote host.

     The "local echo character" (initially  ^E) may  be  used  to

     turn  off  and  on the local echo. (Use this mostly to enter

     passwords without the password being echoed.).

 

     If the "line mode" option is enabled, or if  the  localchars

     toggle is TRUE (the default in "old line by line" mode), the

     user's quit, intr, and flush characters are trapped locally,

     and sent as TELNET protocol sequences to the remote side. If

     "line mode" has ever been enabled, then the user's susp  and

     eof are also sent as TELNET protocol sequences. quit is then

 

     sent as a TELNET ABORT instead of BREAK. The options  toggle

     autoflush  and  toggle  autosynch cause this action to flush

     subsequent output to the terminal  (until  the  remote  host

     acknowledges  the  TELNET  sequence);  and to flush previous

     terminal input, in the case of quit and intr.

 

     While connected to a remote host, the user can enter  telnet

     command  mode  by  typing  the telnet escape character (ini-

     tially ^]). When in command mode, the normal terminal  edit-

     ing  conventions  are  available.  Pressing  <RETURN> at the

     telnet command prompt causes  telnet to exit command mode.

 

 


 

(1-1). telnet 명령어 실행 모드

 

telnet Remote Connection Excution Mode

- 대화형 모드(Interractive Mode)

- 비대화형 모드(Noninterractive Mode)

 

telnet 명령어 실행 모드

(비대화형 모드)  # telnet 172.16.8.254

 

(대화형 모드)    # telnet

                 telnet> open 172.16.8.254

 

 

(1-2). 기본사용법

 

# telnet  [호스트이름/아이피] [포트]

 

(telnet 명령어 사용법)

# telnet 172.16.8.254 

# telnet 172.16.8.254 23 (/etc/services 정의)

# telnet solaris254      (/etc/hosts 정의)

 

 

[참고] 잘 알려진 서비스 포트(Well-kown Port Number, 0 ~ 1023, 0 ~ 65535)

------------------

포트    서비스명

------------------

20,21   FTP

22      SSH

23      TELNET

25      SMTP

53      DNS

67,68   DHCP(Bootp)

80      WEB

110     POP3

111     sunrpc

123     NTP

143     IMAP

------------------

 

[참고] telnet 명령어 수행시 암호를 잘못 입력한 경우

# telnet localhost

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

 

SunOS 5.9

 

login: root

Password:          <----- 암호 잘못 입력(암호: k)

Login incorrect

 

login: <Ctrl + ]>  <----- Escape Charater 입력

telnet>  quit       <----- 'quit' 입력

[참고] telnet 연결 화면시 에러 메세지

 

■ 상대편 서버의 이름을 잘못 지정한 경우

■ 상대편 서버가 정상적으로 동작하지 않는 경우

■ 상대편 서버로 로그인시 암호가 틀린 경우

root 사용자로 로그인시 CONSOLE 변수가 지정이 잘못된 경우

■ 상대편 서버에서 TCP_Wrapper로 막고 있는 경우

 

 

■ 상대편 서버의 이름을 잘못 지정한 경우

서버의 도메인을 알수 없을 경우

- /etc/hosts 파일의 정의가 되지 않은 경우

- DNS 서버에 도메인 등록이 되어 있지 않은 경우

 

----------------------메세지----------------------

# telnet solaris250       <----- /etc/hosts 파일에 solaris250 없음

solaris254: Unknown host  <----- 메세지 확인

--------------------------------------------------

 

 

■ 서버가 정상적으로 동작하지 않는 경우

- 서버의 아이피를 잘못 지정한 경우

- 서버가 Down 되어져 있는 경우

 

----------------------메세지----------------------

# telnet 172.16.8.250     <----- 172.16.8.250 아이피가 없음

Trying 172.16.8.250...

telnet: Unable to connect to remote host: Connection refused <----- 메세지 확인

--------------------------------------------------

(주의) 메세지를 받기 위해서는 약 10~20초 정도를 기다려야 한다.

 

 

■ 암호가 틀린 경우

- 로그인시 사용자의 암호를 잘못 입력한 경우

 

----------------------메세지----------------------

# telnet solaris254

Trying 172.16.8.254...

Connected to solaris254

Escape charater is '^]'

 

SunOS 5.9

 

login: user01

Password:       <----- 틀린 암호 입력(암호: 12345)

Login incorrect <----- 메세지 확인

--------------------------------------------------

 

 


 

root 사용자로 로그인시 CONSOLE 변수가 잘못 지정된 경우

 

----------------------메세지----------------------

# telnet 172.16.8.254

Trying 172.16.8.254...

Connected to 172.16.8.254.

Escape character is '^]'.

 

SunOS 5.9

 

login: root

Password:              <----- 정상 암호 입력(암호: knit)

Not on system console  <----- 메세지 확인

Connection to 172.16.8.254 closed by foreign host.

--------------------------------------------------

 

# vi /etc/default/login

......

[수정전]

#CONSOLE=/dev/console

[수정후]

CONSOLE=/dev/console

 

# telnet localhost

root 사용자로 로그인

 

(복구 작업)

# vi /etc/default/login

(이전 상태로 복원)

 

 

 

TCP_Wrapper에 의해 막힌 경우

 

# vi /etc/default/inetd

.....

[수정전]

ENABLE_TCPWRAPPERS=NO

[수정후]

ENABLE_TCPWRAPPERS=YES

 

# pkill -1 inetd

# echo "ALL: ALL" > /etc/hosts.deny

 

----------------------메세지----------------------

# telnet 172.16.8.254

Trying 172.16.8.254...

Connected to solaris254

Escape charater is '^]'

Connection to solaris254 closed by foreign host. <----- 메세지 확인

--------------------------------------------------

 


 

(복구 작업)

# vi /etc/default/inetd

-> 이전 상태로 복원

 

# rm /etc/hosts.deny

# pkill -1 inetd

 

 

 

 

 

(2). ftp CMD

____________________

 

     The ftp command is the user interface to the Internet  stan-

     dard  File  Transfer  Protocol (FTP). ftp transfers files to

     and from a remote network site.

 

     The host and optional port with which ftp is to  communicate

     may  be  specified on the command line. If this is done, ftp

     immediately attempts to establish a  connection  to  an  FTP

     server  on  that  host.  Otherwise,  ftp  enters its command

     interpreter and awaits instructions from the user. When  ftp

     is  awaiting  commands from the user, it displays the prompt

     ftp>.

 

     -i    Turns off interactive prompting during  multiple  file

           transfers.

 

 

 

(2-1). ftp 명령어 사용법

 

# ftp [옵션] [호스트이름/아이피] [포트]

 

ftp> help

ftp> bin  (solaris9 default)

ftp> ascii(solaris8 default)

ftp> hash

ftp> prompt

ftp> get filename

ftp> put filename

ftp> mget filename

ftp> mput filename

ftp> quit

ftp> bye

 

 

[참고] FTP Client Tools(GUI) - gftp

http://www.sunfreeware.com 다운 받아서 설치하면 된다.

 

 

 


 

(2-2). ftp 명령어 실습 1

 

=====HOSTA=====            ======HOSTB======

/tmp/uploadfile   =====>  /tmp

/root             <=====  /tmp/uploadfile

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

 

     [그림] 파일 업로드 / 다운로드

 

 

# mkfile 10m /tmp/test.solarisXXX

# mkdir /root

# ftp 172.16.8.254

root 사용자로 로그인

ftp> help

 

■ 업로드/다운로드 포인터 맞추기

■ 편리한 기능 설정

■ 업로드/다운로드

■ 확인 접속 해제

 

 

(a). 업로드/다운로드 포인터 맞추기(upload/download pointer)

ftp> lcd /tmp

ftp> cd  /tmp

ftp> ls

 

[참고] 업로드/다운로드 포인터

 

===== HOSTA =====            ===== HOSTB =====

 

 현재 디렉토리 ----------------> 홈디렉토리

 () /test                           /

 

 

 

(b). 편리한 기능 설정(FTP function)

ftp> bin               // unix 에서는 보통 bin mode로 동작하기 때문 맞추지 않으면 에러발생

ftp> ascii     // text 형태로~

ftp> hash      // 8k 단위로 # 표시

ftp> prompt    // 대화형 모드

 

[참고] 파일 전송모드 설정(ascii/bin)

 

===== HOSTA =====            ===== HOSTB =====

                   전송모드

File(s) ------------------------>

- ASCII             ASCII

- BINARY            BINARY

     * Binary Files

     * Compress Files

     * Archive Files

     * Encyption Files

 

 

[참고] 해쉬 설정(hash)

 

===== HOSTA =====            ===== HOSTB =====

 

File(s)

500Mbytes ----------------------->

                8k단위 #(Pound) 표시

 

 

[참고] 대화형 모드 ON/OFF(prompt)

 

===== HOSTA =====            ===== HOSTB =====

 

File(s)

file1, file2 ... ----------------->

                업로드/다운로드(y/n)?

 

 

 

(c). 업로드/다운로드(upload/download)

ftp> put test.solarisXXX

ftp> get test.solarisXXX

ftp> mput test.*

ftp> mget test.*

 

ftp> ls  [-al]

ftp> dir [-al]

 

ftp> bye

ftp> quit

 

 

 


 

[참고] 자동 파일 업/다운로드 스크립트

/root/shell/auto_ftp.sh

# rcp 172.16.8.254:/root/shell/auto_ftp.sh /test

 

-------------- auto_ftp.sh 설명 -------------------

#!/bin/ksh

 

#IP=172.16.8.254

IP=172.16.8.1

USERNAME=user01

PASSWD=user01

PORT=2121

#B_FILE=file_`date +'%m%d'`.tar.gz    # Backup File

B_FILE=backup.`date +'%m%d'`          # Backup File

 

ftp -n $IP $PORT << EOF                      // < redirect stdin , << here documentation

user $USERNAME $PASSWD

bin

hash

prompt

cd c:\a

lcd /root/test

put $B_FILE

EOF

----------------------------------------------------

 

(2-3). ftp 명령어 실습 2

 

===== Solaris Server =====            ===== Window Server =====

      /source (소스)

          |

          V

      /root/test/backup.0723 =========>   c:\a

 

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

 

  [그림] Solaris Server에서 Window Server로 자동 백업 설정

 

 

         Backup File : /root/test/backup.0723

         Windows     : 172.16.8.1

         Solaris     : 172.16.8.254

         Windows Backup Directory : C:\a

 

Function 1) Solaris Backup (/source => /root/test/backup.0723)

Function 2) Solaris->Windows Backup(/root/test/backup.0723->C\a)

 

 

 

(Function1)

# tar cvf /root/test/backup.0723 /source

# crontab -e

0 5 * * 0 tar cvf /root/test/backup.`date +'%m%d'` /source

 

[EX1] 실습

# mkdir /source

# cp /etc/passwd /source

# cp /etc/hosts /source

 

# cd /test

# tar cvf backup.0121 /source

 

 

 

(Function2)

# crontab -e

0 6 * * 0 /root/shell/auto_ftp.sh

 

 

 

[EX2] 실습

 

UNIX Server --------> Window Server

# ftp IP              ftp

   |

   +--> auto_ftp.sh

 

Windows) ftp 프로그램 실행 > "서버" > 적당한 정보 입력

        * 서버 IP    : 121.160.70.XXX

        * 홈디렉토리 : c:\a

        * [ ] ID 없이 접속 허용

        * [ ] 읽기만 허용

        * 아이디 / 비밀번호 : user01 / user01

        * 포트 : 21

        * 허용인원 : 5

       

UNIX   )# vi /test/auto_ftp.sh

        IP=121.160.70.148  --> 적당한 IP로 수정

        .....

        lcd /test    # 정보 수정(/root/test -> /test)

        cd c:\a      # Delete a Line  --> 라인 삭제

        .....

        # chmod 755 auto_ftp.sh

        # ./auto_ftp.sh

 

 

[참고] UNIX <--> Window 서버 동기화

- auto_ftp.sh 스크립트 사용

- SAMBA 서버 이용

- rsync 서버 이용

 

 

 


 

(2-4). ftp 관련 파일

 

/etc/ftpd/ftpusers

/etc/shells

 

 

 

(a). /etc/ftpd/ftpusers

 

/etc/ftpd/ftpusers 파일안에는 한개의 라인당 한명의 사용자가 등록 될수 있으면 이 파

일에 등록된 사용자는 FTP로 접속할 수 없다. Solaris 9 버전부터 ftpusers 파일은

/etc/ftpd 디렉토리에 존재하지만 이전버전에서는(Solaris 8 버전 이하) /etc 디렉토리

하위에 존재했었다. 기본 설정 파일을 그대로 사용한다면 시스템 사용자(System Account)

FTP로 로그인 할 수 없다. 하지만 일반사용자(: user01, user02...) FTP로 로그인

이 가능하다.

 

(FTP 서버 사용자 기본 정책)

- root 사용자는 FTP 서버에 접속 불가능

- 일반 사용자는 접속 가능(: user01, user02....)

 

# cat /etc/ftpd/ftpusers

root

daemon

bin

sys

adm

lp

uucp

nuucp

.....

 

[EX] /etc/ftpd/ftpusers 파일 예

# vi /etc/ftpd/ftpusers

root     <---- ENV_main.sh에 의해 삭제된 라인 등록

daemon

bin

sys

......

# ftp localhost

220 sun99 FTP server ready.

Name (localhost:root): root      <----- root 사용자로 로그인

331 Password required for root.

Password:                        <----- root 사용자 암호 입력

530 Login incorrect.             <----- 메세지 확인

Login failed.

 

# vi /etc/ftpd/ftpusers

daemon   <----- root 사용자 라인 삭제

bin

sys

......

# ftp localhost

root 사용자로 로그인 --> 정상적인 접속이 됨

 

 

 

[참고] /etc/ftpd/ftpusers 파일을 사용한 보안 강화

 

/etc/ftpd/ftpusers 파일 활용 예

# awk -F: '{print $1}' /etc/passwd > /etc/ftpd/ftpusers

 

# vi /etc/ftpd/ftpusers

root

....

user01

...

user02

....

#ftpuser     # FTP Upload User

....

 

[참고] /root/shell/ftpusers_limit.sh

 

 

 

(b). /etc/shells

 

/etc/shells 파일은 FTP 서버에 접속하여 명령어를 실행할때 사용할 수 있는 쉘을 정의 할

수 있다. 한개의 라인에 하나의 쉘을 정의한다. 이 파일은 솔라리스 기본 설치시 존재하지

않는다. 따라서 모든 사용자는 /etc/passwd 파일의 마지막 필드에 존재하는 쉘을 사용하여

FTP 작업을 할수 있다.

 

====== FTP Client ======           ======== FTP Server ========

 

# ftp Sever ----------------------> ID/PASS(인증)

                          user01     * /etc/passwd

                                       user01:--------:/bin/ksh

                                     * /etc/shells

                                        /bin/ksh     // FTP 로 접속시 할당 받을 쉘

                                        ....                  // 다른 서비스도 정의한다.

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

 

/etc/shell 파일의 정의 방식

 

# cat /etc/shells          // 한라인에 한 개의 쉘

/bin/ksh

/bin/csh

/bin/sh

/usr/bin/ksh

.....

 

 

[EX] /etc/shells 파일 실습

 

# touch  /etc/shells

# ftp localhost

Connected to localhost.

220 solaris254 FTP server ready.

Name (localhost:root): user01      <----- user01 사용자로 로그인

331 Password required for user01.

Password:                          <----- user01 사용자 암호 입력

530 Login incorrect.               <----- 메세지 확인

Login failed.

ftp> quit                          <----- 'quit' 입력

 

# vi /etc/shells

/bin/ksh

 

# ftp localhost

user01 사용자 로그인

===> user01 사용자 로그인 가능

 

(시스템 복원)

# rm /etc/shells

 

 

 

 

 

4. 원격접속 & 파일전송 명령어(BSD 계열)

 

Remote Connection & File Transmission for BSD

rlogin 명령어

rsh 명령어

rcp 명령어

 

 

 

(1). r 명령어 동작원리

 

HOSTA    ---->     HOSTB

# telnet B          Auth(ID/PASS)

# rlogin B          Auth(/etc/hosts.equiv, ~/.rhosts)         // 인증과 관련된 파일

 

/etc/hosts.equiv   System wild Conf.                 // 전체 사용자

~/.rhosts            System specific Conf.   // 개인적인~

____________________                                 // 하지만 root는 둘다 제외된다.

 

HOSTA

HOSTA  user01

+

 

/etc/hosts.equiv

~/.rhosts

---------------------

HOSTA

HOSTA  +

HOSTA  user01

+      user01

+      +

 

 

HOSTA    ---->     HOSTB

# rlogin B          Auth(~root/.rhosts)

                         HOSTA

                         HOSTA  user01

                         +   +

 

 

[EX] .rhosts 파일 생성

# cat >  /.rhosts

+ +

<CRTL + D>

# cat /.rhosts

 

 

 

(2). rlogin CMD

____________________

 

     rlogin establishes a remote login session from your terminal

     to the remote machine named hostname.

 

     Hostnames are listed in the hosts  database,  which  may  be

     contained in the /etc/hosts and /etc/inet/ipnodes files, the

     Network Information Service (NIS) hosts  map,  the  Internet

     domain name server, or a combination of these. Each host has

     one official name (the first name in  the  database  entry),

     and  optionally one or more nicknames. Either official host-

     names or nicknames may be specified in hostname.

 

     Each remote machine may have a file  named  /etc/hosts.equiv

     containing  a list of trusted hostnames with which it shares

     usernames. Users with the same username on  both  the  local

     and  remote  machine  may rlogin from the machines listed in

     the remote machine's /etc/hosts.equiv file without supplying

     a  password.  Individual  users may set up a similar private

     equivalence list with the file .rhosts in their home  direc-

     tories.  Each  line in this file contains two names: a host-

     name and a username separated by a  space.  An  entry  in  a

     remote  user's  .rhosts file permits the user named username

     who is logged into hostname to log in to the remote  machine

     as the remote user without supplying a password. If the name

     of the local host is not found in the /etc/hosts.equiv  file

     on  the  remote machine, and the local username and hostname

     are not found in the remote user's .rhosts  file,  then  the

     remote  machine will prompt for a password. Hostnames listed

     in /etc/hosts.equiv and .rhosts files must be  the  official

     hostnames listed in the hosts database; nicknames may not be

     used in either of these files.

 

     For security reasons, the .rhosts  file  must  be  owned  by

     either the remote user or by root.

 

     The remote terminal type is the same as your local  terminal

     type (as given in your environment TERM variable).  The ter-

     minal or window size is also copied to the remote system  if

     the  server  supports  the  option,  and changes in size are

     reflected as well. All echoing takes  place  at  the  remote

     site,  so that (except for delays) the remote login is tran-

     sparent.  Flow  control  using  <CTRL-S>  and  <CTRL-Q>  and

     flushing of input and output on interrupts are handled prop-

     erly.

 

 

(2.1) 명령어 사용법

                                   // # rcp source destination

# rlogin hostname

# rlogin -l username hostname (-l : login name)

# rlogin username@hostname

 

[EX] rlogin 실습

# rlogin localhost

# rlogin 172.16.8.254

# exit

# rlogin -l user01 172.16.8.254

user01 사용자의 인증이 되어 있지 않기 때문에 로그인 시에 인증이 되어야 한다.

$ exit

 

rlogin   : 미리 인증(:~/.rhosts)이 되어 있지 않으면 접속할 당시에 패스워드를 통해

           인증하게 된다.

rsh, rcp : 미리 인증이 되어 있지 않으면 명령어 수행이 되지 않는다.

 

 

 

(3). rsh CMD

____________________

 

     rsh connects to the  specified  hostname  and  executes  the

     specified  command.  rsh  copies  its  standard input to the

     remote command, the standard output of the remote command to

     its  standard  output,  and the standard error of the remote

     command to its standard error.  Interrupt,  quit,  and  ter-

     minate  signals  are  propagated  to the remote command. rsh

     normally terminates when the remote command does.

 

     If you omit command, instead of executing a single  command,

     rsh logs you in on the remote host using rlogin(1).

 

     rsh will not return the exit status code of command.

 

     Shell metacharacters which are not quoted are interpreted on

     the  local  machine,  while quoted metacharacters are inter-

     preted on the remote machine. See EXAMPLES.

 

     If there is no locale setting in the initialization file  of

     the  login  shell (.cshrc, . . .) for a particular user, rsh

     always executes the command in the  "C"  locale  instead  of

     using the default locale of the remote machine.

 

 

(3-1). 명령어 사용법

 

# rsh hostname CMD

 

# rsh 172.16.8.254 hostname

# rsh 172.16.8.254 ls -l /tmp

# rsh 172.16.8.254 ls -l /root/docs

 

 

 

(4). rcp CMD

____________________

 

     The rcp command copies files between machines. Each filename

     or  directory  argument  is either a remote file name of the

     form:

 

     hostname:path

 

     or a local file name (containing no ":" (colon)  characters,

     or "/" (backslash) before any ":" (colon) characters).

 

     The hostname can be an IPv4  or  IPv6  address  string.  See

     inet(7P) and inet6(7P). Since IPv6 addresses already contain

     colons, the hostname should be enclosed in a pair of  square

     brackets  when an IPv6 address is used. Otherwise, the first

     occurrence of a colon can be interpreted  as  the  separator

     between hostname and path. For example,

 

     [1080::8:800:200C:417A]:tmp/file

 

     If a filename is not a full path  name,  it  is  interpreted

     relative  to  your  home  directory on hostname. A path on a

     remote host may be quoted using \, ",  or  ',  so  that  the

     metacharacters are interpreted remotely.

 

     rcp does not prompt for passwords; your current  local  user

     name  must exist on hostname and allow remote command execu-

     tion by rsh(1).

 

     rcp handles third party copies,  where  neither  source  nor

     target  files are on the current machine. Hostnames may also

     take the form

 

     username@hostname:filename

 

     to use username rather than your current local user name  as

     the user name on the remote host. rcp also supports Internet

     domain addressing of the remote host, so that:

 

     username@host.domain:filename

 

     specifies the username to be used,  the  hostname,  and  the

     domain  in  which that host resides. File names that are not

     full path names will be interpreted  relative  to  the  home

 

 

(4-1). 명령어 사용법

 

# rcp file1 172.16.8.254:/tmp

# rcp 172.16.8.254:/tmp/file1 /tmp

# rcp -r dir1 172.16.8.254:/tmp

# rcp -r 172.16.8.254:/root/shell /root

# rcp 172.16.8.254:/root/* .

# rcp file1 user01@172.16.8.254:/tmp

 

 

[EX] rcp 실습

# rcp -r 172.16.8.254:/root/shell /root

 

# touch  /root/test.solarisXXX

# rcp /root/test.solarisXXX 172.16.8.254:/tmp

# rsh 172.16.8.254 ls -l /tmp

 

 

[참고] .rhosts 파일 정책(Policy)

 

(a). 사용자 홈디렉토리에 .rhosts 파일을 정기적으로 지우는 정책

 

# find /export/home -name .rhosts -type f -exec rm {} \;

 

# crontab -e

0 6 * * * find /export/home -name .rhosts -type f -exec rm {} \;

 

 

(b). 사용자 홈디렉토리에 .rhosts 파일을 못 만들도록 하는 정책

user01 Home Directory : /export/home/user01

 

# cd /export/home/user01

# mkdir .rhosts (rwxr-xr-x root        other)

# touch .rhosts/.notperm (rw-r--r-- root other)

 

# chmod 000 .rhosts

# chmod 000 .rhosts/.notperm

 

--------- /export/home/user01 ---------- (user01:other rwxr-xr-x)

 

      .rhosts 디렉토리 생성(관리자) (root:other rwxr-xr-x)

                  |

                  +----------------> 디렉토리 삭제(사용자)

                  |                  # rmdir .rhosts

                  |

      .rhosts/.notperm 파일생성(관리자) .rhosts (root:other rwxr-xr-x)

                  |                          +-- .notperm(root:other rw-r--r--)

                  |

                  +----------------> 디렉토리 삭제(사용자)

                                     # rm -r .rhosts

 

(사용자 테스트)

# telnet localhost

user01 사용자로 로그인

$ touch .rhosts

touch: cannot change times on .rhosts

 

$ rmdir .rhosts

rmdir: directory ".rhosts": Directory not empty

 

$ rm -r .rhosts

rm: cannot read directory .rhosts: Permission denied

 

$ ls .rhosts

.rhosts: Permission denied

 

$ cd .rhosts

ksh: .rhosts: permission denied

 

 

 

[참고] 사용자의 환경파일의 내용을 수정하지 못하도록 관리자가 설정

 

사용자의 홈 : /export/home/user02

 

/export/home/user02 (root other rwxr-xr-x)

               |

               +--- .profile (root other rw-r--r--)

               |

               +--- work (user02 staff rwxr-xr-x)

 

# cd /export/home

# mv user02 user02.old

# mkdir /export/home/user02

# cd ~user02

# vi .profile

PATH=/bin:/sbin:/usr/bin:/usr/dt/bin:/usr/sbin

export PATH

 

cd work

# mkdir work

# chown user02:staff work

 

# telnet localhost

user02/user02

 

$ pwd

$ id

$ echo $PATH

$ vi ~/.profile

수정가능(X)

:wq!

 

 

5. 원격접속 & 파일전송 명령어 (암호화 방식)

 

Remote Connection & File Transmission for Securiy

ssh 명령어

scp 명령어

sftp 명령어

 

 

[SSH 에 대해서]

전형적인 TCP/IP Transport Layer 암호화 메커니즘을 사용하며, 이것은 암호화 엔진을 위

하여 대중적인 Blowfish 또는 정부 지원의 tripe-DES(Data Encryption Standard) 알고리

즘을 사용한다. 암호화 기술의 사용은 상호 작용 세션의 내용이 클라이언트 및 서버 이외

에는 누구에게도 알려지지 않게 한다. 세션 데이터 암호화뿐만 아니라, 식별 및 인증 과

정이 RSA 암호화 기술을 사용하여 암호화 된다. 이것은 사용자이름과 패스워드의 조합이

3자에 의해 sniff 될수 없음을 의미 한다.

 

[SSH 클라이언트 연결 수립과정]

(a). 클라이언트 연결을 요청하기 위해 서버 포트로 연결한다.(default port 22)

(b). 서버는 표준 public RSA 호스트 키(1024 bits)와 매시간 변경되는 다른 RSA 서버키

     (768 bits)를 가지고 응답한다. 서버 키가 시간마다 변경되기 때문에, 한 세션의 트

     래픽에 대한 키가 crack 되어도, historic 데이터는 여전히 암호화되어 이러한 공격

     툴를 제한한다.

(c). 서버는 알지 못하는 호스트로부터 연결을 거부하도록 설정될 수 있지만 기본적으로

     모든 클라이언트로 부터 연결을 허용한다.

(d). 만약 연결이 수용되면, 클라이언트는 256비트의 임의 번호로 구성되는 세션 키를 생

     성하고 서버가 지원하는 암호화 알고리즘(tripe-DES or Blowfish)을 선택한다.

(e). 클라이언트 RSA를 사용하는 세션키를, 호스트 및 서버 키 모두를 사용하여 암호화하

     고 암호화된 키를 서버로 돌려보낸다.

(f). 서버는 세션 키를 해독하여 클라이언트와 서버 사이의 암호화가 사용가능하게 된다.

(g). 만약 기본 인증메커니즘이 선택된다면, 클라이언트는 secure channel을 통해 서버에

     대한 사용자 이름과 패스워드를 전달한다.

 

# ssh -l user01 172.16.8.254                                              sshd(22)

 [client]       --------- request connection (port 22)       -----------> [server]

generate 256bit <-------- send 1024bit host key & server key -----------

client key                (public RSA Key)        (Time Based)

                --------- send new key                       ----------->

                <-------- request username/password          ------------ secure channel

                                                                          established

                --------- send username/password             ----------->

                <-------- accept or reject connection        ------------

 

                         [그림] ssh 클라이언트/서버 연결과정

 

다음 그림은 일반적인 암호화 방식을 나타낸다.

---------- HOSTA -----------                   ---------- HOSTB -----------

                                   전송

A ---> 암호화알고리즘 ---> " ----------------> " ---> 복호화알고리즘 ---> A

         +3   /2                                         * 2  -3

                   A                                              A

                     |                                              |

                    Key                                            Key

 

                        [그림] 일반적인 암호화 방식

(1). ssh CMD

____________________

 

     ssh (Secure Shell) is a program for logging  into  a  remote

     machine  and  for executing commands on a remote machine. It

     is intended to replace rlogin and rsh, and to provide secure

     encrypted communications between two untrusted hosts over an

     insecure network. X11 connections and arbitrary TCP/IP ports

     can also be forwarded over the secure channel.

 

     ssh connects and logs into the specified hostname. The  user

     must  prove  his or her identity to the remote machine using

     one of several methods depending  on  the  protocol  version

     used:

 

  SSH protocol version 1

     First, if the machine the user logs in  from  is  listed  in

     /etc/hosts.equiv or /etc/shosts.equiv on the remote machine,

     and the user names are the same on both sides, the  user  is

     immediately  permitted  to  log  in.  Second, if .rhosts  or

     .shosts exists in the user's home directory  on  the  remote

     machine  and  contains  a  line  containing  the name of the

     client machine and the name of the user on that machine, the

     user  is  permitted  to  log in. This form of authentication

     alone is normally not allowed by the server  because  it  is

     not secure.

 

     The second (and primary) authentication method is the rhosts

     or hosts.equiv method combined with RSA-based host authenti-

     cation. It means that if the login  would  be  permitted  by

     $HOME/.rhosts,     $HOME/.shosts,    /etc/hosts.equiv,    or

     /etc/shosts.equiv, and if additionally the server can verify

     the client's host key (see /etc/ssh_known_hosts in the FILES

     section), only then is login permitted. This  authentication

     method  closes security holes due to IP spoofing, DNS spoof-

     ing, and routing spoofing.

 

     Note to the administrator: /etc/hosts.equiv,  $HOME/.rhosts,

     and  the  rlogin/rsh  protocol  in  general,  are inherently

     insecure and should be disabled if security is desired.

 

     As a third authentication  method,  ssh  supports  RSA-based

     authentication. The scheme is based on public-key cryptogra-

     phy. There are cryptosystems where encryption and decryption

     are  done  using  separate  keys,  and it is not possible to

     derive the decryption key from the encryption  key.  RSA  is

     one  such  system.  The  idea  is  that  each user creates a

     public/private key pair  for  authentication  purposes.  The

     server  knows  the  public  key, and only the user knows the

     private key. The file $HOME/.ssh/authorized_keys  lists  the

     public keys that are permitted for logging in. When the user

     logs in, the ssh program tells the server which key pair  it

     would  like  to use for authentication. The server checks if

     this key is permitted, and if so, sends the  user  (actually

     the  ssh  program running on behalf of the user) a challenge

     in the form of a random number, encrypted by the user's pub-

     lic  key.  The  challenge  can  only  be decrypted using the

     proper private key. The  user's  client  then  decrypts  the

     challenge  using  the  private  key,  proving that he or she

     knows the private key  but  without  disclosing  it  to  the

     server.

 

     ssh implements the  RSA  authentication  protocol  automati-

     cally.  The  user creates his or her RSA key pair by running

     ssh-keygen(1).    This   stores   the   private    key    in

     $HOME/.ssh/identity     and     the     public     key    in

     $HOME/.ssh/identity.pub in the user's  home  directory.  The

     user     should    then    copy    the    identity.pub    to

     $HOME/.ssh/authorized_keys in his or her home  directory  on

     the  remote machine (the authorized_keys file corresponds to

     the conventional $HOME/.rhosts file, and  has  one  key  per

     line,  though  the  lines can be very long). After this, the

     user can log in without giving the password. RSA authentica-

     tion is much more secure than rhosts authentication.

 

     The most convenient way to use  RSA  authentication  may  be

     with  an  authentication  agent.  See  ssh-agent(1) for more

     information.

 

     If other authentication methods fail, ssh prompts  the  user

     for  a password. The password is sent to the remote host for

     checking. However, since all communications  are  encrypted,

     the password cannot be seen by someone listening on the net-

     work.

 

  SSH protocol version 2

     When a user connects using the protocol version 2, different

     authentication  methods  are available. At first, the client

     attempts to authenticate using the  public  key  method.  If

     this method fails, password authentication is tried.

 

     The public key  method  is  similar  to  RSA  authentication

     described  in  the  previous  section  except  that  the DSA

     algorithm is used instead of the patented RSA algorithm. The

     client  uses  his  private DSA key $HOME/.ssh/id_dsa to sign

     the session identifier and sends the result to  the  server.

     The  server checks whether the matching public key is listed

     in $HOME/.ssh/authorized_keys and grants access if both  the

     key is found and the signature is correct. The session iden-

     tifier is derived from a shared Diffie-Hellman value and  is

     known only to the client and the server.

 

     If public key authentication fails or is  not  available,  a

     password  can be sent encrypted to the remote host for prov-

     ing the user's identity. This protocol 2 implementation does

     not yet support Kerberos or S/Key authentication.

 

     Protocol 2 provides additional mechanisms for  confidential-

     ity  (the traffic is encrypted using 3DES, Blowfish, CAST128

     or Arcfour) and integrity (hmac-sha1, hmac-md5). Notice that

     protocol  1  lacks  a  strong  mechanism  for  ensuring  the

     integrity of the connection.

 

  Login session and remote execution

     When the user's identity has been accepted  by  the  server,

     the  server  either executes the given command, or logs into

     the machine and gives the user a normal shell on the  remote

     machine.  All communication with the remote command or shell

     will be automatically encrypted.

 

     If a pseudo-terminal has been allocated (normal  login  ses-

     sion), the user can disconnect with ~., and suspend ssh with

     ~^Z. All forwarded connections can be listed with ~#. If the

     session  blocks  waiting for forwarded X11 or TCP/IP connec-

     tions  to  terminate,  ssh  can  be  backgrounded  with  ~&,

     although  this  should  not  be used while the user shell is

     active, as it can cause the shell  to  hang.  All  available

     escapes can be listed with ~?.

 

     A single tilde character can be sent as ~~ (or by  following

     the  tilde by a character other than those described above).

     The escape character must always  follow  a  newline  to  be

     interpreted  as special. The escape character can be changed

     in configuration files or on the command line.

 

     If no pseudo tty has been allocated, the  session  is  tran-

     sparent and can be used to reliably transfer binary data. On

     most systems, setting the escape character  to  "none"  will

     also make the session transparent even if a tty is used.

 

     The session terminates when the  command  or  shell  in  the

     remote machine exits and all X11 and TCP/IP connections have

     been closed. The  exit  status  of  the  remote  program  is

     returned as the exit status of ssh.

 

  X11 and TCP forwarding

     If the user is using X11 (the DISPLAY  environment  variable

     is  set), the connection to the X11 display is automatically

     forwarded to the remote side in such a way that any X11 pro-

     grams  started  from  the shell (or command) will go through

     the encrypted channel, and the  connection  to  the  real  X

     server  will be made from the local machine. The user should

     not manually set DISPLAY. Forwarding of X11 connections  can

     be configured on the command line or in configuration files.

 

     The DISPLAY value set  by  ssh  will  point  to  the  server

     machine,  but  with a display number greater than zero. This

     is normal behavior, because ssh creates a "proxy"  X  server

     on  the  server  machine for forwarding the connections over

     the encrypted channel.

 

     ssh will also automatically set up Xauthority  data  on  the

     server  machine. For this purpose, it will generate a random

     authorization cookie, store it in Xauthority on the  server,

     and  verify that any forwarded connections carry this cookie

     and replace it by the real cookie  when  the  connection  is

     opened.  The real authentication cookie is never sent to the

     server machine (and no cookies are sent in the plain).

 

     If the user is using an authentication agent, the connection

     to  the  agent is automatically forwarded to the remote side

     unless disabled on the command line or  in  a  configuration

     file.

 

     Forwarding of arbitrary TCP/IP connections over  the  secure

     channel  can be specified either on the command line or in a

     configuration file. One possible application of TCP/IP  for-

     warding  is  a  secure  connection  to  an electronic purse.

     Another possible application is going through firewalls.

 

  Server authentication

     ssh automatically maintains and checks a database containing

     identifications  for  all  hosts it has ever been used with.

     RSA host keys are stored in  $HOME/.ssh/known_hosts  in  the

     user's    home    directory.    Additionally,    the    file

     /etc/ssh_known_hosts  is  automatically  checked  for  known

     hosts.  Any  new hosts are automatically added to the user's

     file. If a host's identification  ever  changes,  ssh  warns

     about this and disables password authentication to prevent a

     trojan horse from getting the user's password. Another  pur-

     pose  of  this  mechanism  is  to  prevent man-in-the-middle

     attacks which could otherwise  be  used  to  circumvent  the

     encryption. The StrictHostKeyChecking option (see below) can

     be used to prevent logins to machines whose host key is  not

     known or has changed.

 

 

(1-1). ssh 명령어 사용법

 

# ssh hostname

# ssh -l username hostname

# ssh username@hostname

 

 

 

(2). sftp CMD

_____________________

 

     The sftp utility is an  interactive  file  transfer  program

     with a user interface similar to ftp(1) that uses the ssh(1)

     command to create a secure connection to the server.

 

     sftp implements the SSH File Transfer Protocol as defined in

     IETF  draft-ietf-secsh-filexfer.  There  is  no relationship

     between the protocol used  by  sftp  and  the  FTP  protocol

     (RFC959) provided by ftp(1).

 

(2-1). sftp 명령어 사용법

 

sftp 명령어는 ftp 명령어를 기반으로 만들어 졌기 때문에 명령어 형식이 거의 흡사하다.

 

# sftp 172.16.8.254

# sftp user01@solaris254

 

[EX] sftp 명령어 실습

 

# sftp 172.16.8.254

Connecting to 172.16.8.254...

The authenticity of host '192.168.1.200' can't be established.

RSA key fingerprint in md5 is: 66:2c:f0:80:41:26:f7:1f:5d:a3:be:8c:0d:9a:e5:e1

Are you sure you want to continue connecting(yes/no)? yes <----- 'yes' 입력

Warning: Permanently added '192.168.1.200' (RSA) to the list of known hosts.

root@192.168.1.200's password:  <----- 암호 입력(암호: knit)

sftp > help                     <----- 'help' 입력

Available commands:

cd path                       Change remote directory to 'path'

lcd path                      Change local directory to 'path'

chgrp grp path                Change group of file 'path' to 'grp'

chmod mode path               Change permissions of file 'path' to 'mode'

chown own path                Change owner of file 'path' to 'own'

help                          Display this help text

get remote-path [local-path]  Download file

lls [ls-options [path]]       Display local directory listing

lmkdir path                   Create local directory

lpwd                          Print local working directory

ls [path]                     Display remote directory listing

lumask umask                  Set local umask to 'umask'

mkdir path                    Create remote directory

put local-path [remote-path]  Upload file

pwd                           Display remote working directory

exit                          Quit sftp

quit                          Quit sftp

rename oldpath newpath        Rename remote file

rmdir path                    Remove remote directory

rm path                       Delete remote file

!command                      Execute 'command' in local shell

!                             Escape to local shell

?                             Synonym for help

sftp > quit   <----- 'quit' 입력

 

 

 


 

(3). scp CMD

_____________________

 

     The scp utility copies files between hosts on a network.  It

     uses ssh(1) for data transfer, and uses the same authentica-

     tion and  provides  the  same  security  as  ssh(1).  Unlike

     rcp(1),  scp  will  ask for passwords or passphrases if they

     are needed for authentication.

 

     Any file name may contain a host and user  specification  to

     indicate  that  the  file is to be copied to/from that host.

     Copies between two remote hosts are permitted.

 

(3-1). scp 명령어 사용법

 

scp 명령어는 rcp 명령어를 기반으로 만들어 졌기 때문에 명령어의 형식이 거의 흡사하다.

 

# scp /tmp/file1 172.16.8.254:/tmp

# scp -r /root/test 172.16.8.254:/tmp

# scp -r 172.16.8.254:/tmp /test

# scp -r file1 user01@172.16.8.254:/tmp

 

 

 

(4). ssh 관련 파일들

 

- $HOME/.ssh/known_hosts

- $HOME/.ssh/identity

- $HOME/.ssh/identity.pub

- $HOME/.ssh/id_dsa.pub

- $HOME/.ssh/config

- $HOME/.ssh/authorized_keys

- /etc/ssh/ssh_known_hosts

- /etc/ssh/ssh_config

- $HOME/.rhosts

- /etc/hosts.equiv

- /etc/ssh/shosts.equiv

- /etc/ssh/sshrc

- $HOME/.ssh/rc

- $HOME/.ssh/environment

 

 

 

     $HOME/.ssh/known_hosts

           Records host keys for all hosts the  user  has  logged

           into   that   are  not  in  /etc/ssh_known_hosts.  See

           sshd(1M).

 

     $HOME/.ssh/identity

 

     $HOME/.ssh/id_dsa

           Contains the RSA and the DSA  authentication  identity

           of  the  user.  These files contain sensitive data and

           should be readable by the user but not  accessible  by

           others (read/write/execute). Notice that ssh ignores a

           private key file if it is accessible by others. It  is

           possible  to  specify a passphrase when generating the

           key. The passphrase will be used to encrypt the sensi-

           tive part of this file using 3DES.

 

     $HOME/.ssh/identity.pub

 

     $HOME/.ssh/id_dsa.pub

           Contains the public key for authentication,  that  is,

           the public part of the identity file in human-readable

           form. The contents of the $HOME/.ssh/identity.pub file

           should  be  added to $HOME/.ssh/authorized_keys on all

           machines where you wish to log in using RSA  authenti-

           cation. The contents of the $HOME/.ssh/id_dsa.pub file

           should be added to $HOME/.ssh/authorized_keys  on  all

           machines  where you wish to log in using DSA authenti-

           cation. These files are not  sensitive  and  can,  but

           need not, be readable by anyone. These files are never

           used automatically and are  not  necessary.  They  are

           provided only for the convenience of the user.

 

     $HOME/.ssh/config

           This is the per-user configuration file. The format of

           this file is described above. This file is used by the

           ssh client. This file does  not  usually  contain  any

           sensitive information, but the recommended permissions

           are read/write for the user and not accessible by oth-

           ers.

 

     $HOME/.ssh/authorized_keys

           Lists the DSA keys that can be used for logging in  as

           this  user. This file is not highly sensitive, but the

           recommended permissions are read/write  for  the  user

           and not accessible by others.

 

     /etc/ssh/ssh_known_hosts

           Systemwide    list     of     known     host     keys.

           /etc/ssh_known_hosts  contains  RSA  keys.  This  file

           should be prepared by the system administrator to con-

           tain  the  public  host  keys  of  all machines in the

           organization and should be  world-readable.  The  file

           contains  public  keys, one per line, in the following

           format, with fields separated by spaces: system  name,

           number  of  bits in modulus, public exponent, modulus,

           and optional comment field. When different  names  are

           used  for  the  same machine, all such names should be

           listed, separated by commas. See sshd(1M).

 

           The  canonical  system  name  (as  returned  by   name

           servers) is used by sshd(1M) to verify the client host

           when logging in. Other names are  needed  because  ssh

           does not convert the user-supplied name to a canonical

           name before checking the key, to prevent someone  with

           access  to  the  name  servers from being able able to

           fool host authentication.

 

     /etc/ssh/ssh_config

           Systemwide  configuration  file.  This  file  provides

           defaults  for  those  values that are not specified in

           the user's configuration file, and for those users who

           do not have a configuration file.

 

           This file must be world-readable.

 

     $HOME/.rhosts

           This file is used in .rhosts  authentication  to  list

           the  host/user  pairs  that  are  permitted to log in.

           (Notice that this file is also used by rlogin and rsh,

           which  makes  using  this file insecure.) Each line of

           the file contains a host name (in the  canonical  form

           returned  by  name  servers),  and then a user name on

           that host, separated by a  space.  On  some  machines,

           this  file may need to be world-readable if the user's

           home  directory  is  on  an  NFS  partition,   because

           sshd(1M)  reads  it  as  root. Additionally, this file

           must be owned by the user and must not have write per-

           missions  for  anyone else. The recommended permission

           for most machines is read/write for the user  and  not

           accessible by others.

 

           Notice that, by default, sshd(1M) will be installed so

           that  it  requires  successful RSA host authentication

           before  permitting  .rhosts  authentication.  If  your

           server  machine does not have the client's host key in

           /etc/ssh_known_hosts,   you   can    store    it    in

           $HOME/.ssh/known_hosts.  The easiest way to do this is

           to connect back to the client from the server  machine

           using ssh. This will automatically add the host key to

           $HOME/.ssh/known_hosts.

 

     $HOME/.shosts

           This file is used exactly the same way as .rhosts. The

           purpose  for  having  this  file  is to be able to use

           rhosts  authentication  with  ssh  without  permitting

           login with rlogin(1) or rsh(1).

 

 

     /etc/hosts.equiv

           This file is used during  .rhosts  authentication.  It

           contains  canonical  hosts  names,  one per line. (See

           sshd(1M) for the full  format  description.).  If  the

           client  host is found in this file, login is automati-

           cally permitted, provided that client and server  user

           names  are  the same. In addition, successful RSA host

           authentication is normally required. This file  should

           only be writable by root.

 

     /etc/ssh/shosts.equiv

           This file is processed  exactly  as  /etc/hosts.equiv.

           This file may be useful to permit logins using ssh but

           not using rsh or rlogin.

 

     /etc/ssh/sshrc

           Commands in this file are executed  by  ssh  when  the

           user  logs  in just before the user's shell or command

           is started. See sshd(1M) for more information.

 

     $HOME/.ssh/rc

           Commands in this file are executed  by  ssh  when  the

           user  logs  in just before the user's shell or command

           is started. See sshd(1M) for more information.

 

     $HOME/.ssh/environment

           Contains additional definitions for environment  vari-

           ables. See ENVIRONMENT VARIABLES.


2008. 8. 8. 18:46

Chapter 8. 프로세스 관리


Process Administration

 

 

INDEX

_______________________________________

 

1. Process Information

2. Default Process Administration

3. Extenston Process Administration

_______________________________________

 

 

 

프로세스(Process) ?

- 실행중인 프로그램그램이다.

 

프로세스는 컴퓨터 내에서 실행중인 프로그램의 인스턴스이다. 이 용어는 몇몇 운영체계에

서 사용되는, "태스크"라는 용어와 의미상으로 가깝다. 유닉스나 몇몇 다른 운영체계에서

, 프로그램이 시작되면 프로세스도 시작된다. 태스크와 마찬가지로, 프로세스는 그 프로

세스가 추적 관리될 수 있게 하기 위한 특정한 데이터 셋이 관련되어 실행 중인 프로그램

이다. 여러 명의 사용자들에 의해 공유되고 있는 응용프로그램은 일반적으로 각 사용자들

의 실행단계에서 하나의 프로세스를 갖는다.

 

프로세스는 자프로세스라고도 불리는 서브프로세스를 시작시킬 수 있다. 자프로세스는 부

프로세스의 복제로서 부프로세스의 자원을 일부 공유하는데, 부프로세스가 종료되면 더

이상 존재할 수 없다. 프로세스들은 몇 가지 IPC 방식을 통하여 정보를 교환하거나 그들의

연산을 동기화할 수 있다.

 

IPC 방식의 대표적인 메쏘드는

      (a)Pipes named pipes

      (b)Message queueing

      (c)Semaphores,

      (d)Shared Memory

      (e)Socket

등이다.

 

 


1. 프로세스 정보(Process Information)

 

ps 명령어를 통해서 프로세스 정보를 확인할 수 있다. 이런 정보는 존재해야만 출력이 될

수 있다. 프로세스의 정보는 /proc 디렉토리에 하위에 프로세스 아이디(PID) 번호와 대응

이 되는 이름을 가진 디렉토리에 존재한다.

 

다음은 기본적인 프로세스 정보에 대한 내용이다.

- PID(Process Identification)

- PPID(Parent Process ID)

- UID/GID

- EUID/EGID

- Control Terminal

 

 

 

(1). 프로세스 정보가 존재하는 디렉토리

프로세스에 대한 정보는 /proc 디렉토리에 해당 프로세스의  PID 번호 디렉토리안에 정보

가 존재하게 된다.   이 디렉토리 안에 존재하는 파일들은 대부분 텍스트 파일로 되어 있지

않기 때문에 프로세스의 정보를 확인 할때 pCMD(: pfiles, pstack, ptree, ....)등의 명령

어를 사용해야 한다.

프로세스 정보 디렉토리 : /proc/PID

 

# admintool &

[1]    479     <----- admintool PID 번호 확인(479)

 

# ps

   PID TTY      TIME CMD

   467 pts/3    0:00 ksh

   479 pts/3    0:00 admintoo   <----- admintool PID 번호 확인(479)

 

# ls -ld /proc/479

 

admintool 종료(adminitool exit)

# ls -ld /proc/479

/proc/479: No such file or directory

 

 

 

[참고] procfs 특징

(a). /proc 디렉토리 하위에 PID 번호의 디렉토리가 생성되고 그안에 프로세스 정보가 쌓

     이게 된다. /proc/PID 디렉토리 하위에는 프로세스의 정보에 관련한 자세한 내용이

     파일과 디렉토리에 존재하게 된다.

(b). /proc/PID 디렉토리의 소유자는 프로세스를 실행시킨 사람의 소유이다.

 

 

 

[참고] 프로세스 정보를 자세하게 보기 위해서는 다음 파일을 참고 한다.

/root/docs/Reference/Process_CMD.txt

- 위의 문서중 pldd, pfiles, pstack, ptree, ptime 명령어는 반드시 알아 두자.

pldd     : 프로세스가 사용하고 있는 동적 라이브러리 확인

pfiles   : 프로세스가 사용하고 있는 파일들 확인

pstack   : 프로세스가 사용하고 있는 stack 공간 확인

ptree    : 프로세스 tree 구조 확인

ptime    : 프로세스가 실행된 시간 확인

 

 

 

(2). PID

 

프로그램을 실행 하면 프로세스가 되며, 각각의 프로세스를 식별하기 위해 할당되는 번호로

PID 번호가 할당 된다.

 

 

 

(3). 부모프로세스(PPID)의 의미 확인

 

- PPID(Parent PID)

 

# ps

   PID TTY      TIME CMD

   467 pts/3    0:00 ksh

 

# ksh

# ps

   PID TTY      TIME CMD

   467 pts/3    0:00 ksh

   490 pts/3    0:00 ksh

 

# ps -l

 F S   UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN TTY      TIME CMD

 8 S     0  467   465  0  40 20 d4f1f138    500 d4f1f1a4 pts/3    0:00 ksh

 8 S     0  490   467  0  50 20 d4f1e338    500 d4f1e3a4 pts/3    0:00 ksh

 

 

PID=467

------------+

            |

            | PID=490, PPID=467

            +----------------------

 

[그림] 자식프로세스, 부모프로세스

 

 

 

(4). UID/GID, EUID/EGID의 의미 확인

 

- UID(User Identification)

- GID(Group Identification)

- EUID(Effective UID)

- EGID(Effective GID)

 

 

 


(5). 제어 터미널의 의미 확인

 

제어 터미널 필드에 올수 있는 정보는 다음과 같다.

 

제어 터미널(Control Terminal)

/dev/pts/5

/dev/term/b

/dev/console

?

 

 

 

 

2. 프로세스 관리 (1)

 

Default Process Administration

- 프로세스 실행(Process Execution)

- 프로세스 확인(Process Verification)

- 프로세스 종료(Process Termination)

 

 

(1). 프로세스 실행

 

하나의 프로그램을 실행하면 하나의 프로세스가 된다. 프로세스는 2가지 방법 형태로 실행

이 가능하며 (a)첫번째 방식은 포그라이운드(fg, foreground)에서의 실행 이고, (b)두번째

방식은 백그라운드(bg, background)에서의 실행이다.

 

프로세스 실행 방법

(fg) # admintool

(bg) # admintool &

 

(Foreground Process)

 

fg  ksh

-----------------+                     +-----------------

                 |                     |

                 |  ksh      admintool |

                 +---------------------+

 

# admintool

# ls

 

 

(Background Process)

 

bg  ksh 

-----------------+---------------------+---------------------

                 |                     |

                 | ksh       admintool |

                 +---------------------+

 

# admintool &

[1] PID

# ls

(2). 프로세스 확인

 

실행된 프로세스를 확인할 때는 ps 명령어를 사용한다.

# ps -ef | grep inetd

 

(명령어 옵션 사용법)

# ps

# ps l         // long info

# ps -a        // user가 실행 시킨 모든 데몬

# ps -U 100 (# ps -U user01, # ps -U user01,user02,user03)

# ps -t pts/5          // TERM 5에서 실행 중인 프로세스

# ps -ef | grep inetd

 

[ps 명령어 출력 화면 해석]

# ps

PID TTY      TIME CMD

467 pts/3    0:00 ksh

 

----------------------------------------------------------------------------

종류    설 명

----------------------------------------------------------------------------

PID     프로세스 아이디(식별 번호)

TTY     제어 터미널

TIME    CPU 사용 누적 시간(Comunitive Time)

CMD     명령어

----------------------------------------------------------------------------

 

[ps -l 명령어 출력 화면 해석]

# ps -l

F S   UID   PID  PPID  C PRI NI   ADDR      SZ    WCHAN    TTY      TIME CMD

8 S   0     467  465   0 40  20  d4f1f138  500   d4f1f1a4 pts/3    0:00 ksh

 

----------------------------------------------------------------------------

종류    설 명

----------------------------------------------------------------------------

F        현재는 의미가 없음

S        프로세스의 상태정보(Process Status)

         - S : Sleeping, process is waiting for an event to complete.

         - O : Occupy, process is running on a processor.

         - R : Runnable, process is on run queue.

         - T : Stopped, either by a job control signal or because it is being traced

         - Z : Zombie, process terminated and parent not waiting

UID      프로세스 실행 사용자

PID      프로세스 아이디(식별 번호)

PPID     부모 프로세스 아이디(식별 번호)

PRI      프로세스 우선 순위(Prioty)

NI       NICE , 프로세스의 우선 순위를 조정하는 값

ADDR    프로세스의 메모리상의 주소

SZ       가상 메모리 크기

WCHAN    프로세스 락(lock) 또는 이벤트시에 사용하는 프로세스 휴식(sleep) 주소

TTY      제어터미널

TIME     CPU 사용 누적 시간

CMD      명령어

----------------------------------------------------------------------------

 

 

 

-----------------------------------------------------------------------------------

필드   

-----------------------------------------------------------------------------------

UID    The effective user ID of the process's owner.

 

PID    The process ID.

 

PPID   The parent process ID.

 

C      The processor utilization for scheduling. This field is not displayed when

       the -c option is used.

 

CLS    The scheduling class to which the process belongs:

      real-time, system, or timesharing. This field is included only with the -c

       option.

 

PRI    The kernel thread's scheduling priority. Higher numbers indicate a higher

      priority.

 

NI     The process's nice number, which contributes to its scheduling priority.

       Making a process nicer means lowering its priority.

 

ADDR   The address of the proc structure.

 

SZ     The virtual address size of the process.

 

WCHAN  The address of an event or lock for which the process is sleeping.

 

STIME  The starting time of the process (in hours, minutes, and seconds).

 

TTY    The terminal from which the process (or its parent) was started. A question

       mark indicates that there is no controlling terminal.

 

TIME   The total amount of CPU time used by the process since it began.

 

CMD    The command that generated the process.

-----------------------------------------------------------------------------------

 

[ps -ef 명령어 출력 화면 해석]

# ps -ef | more

UID     PID  PPID C  STIME     TTY      TIME CMD

root    0    0    0   10:01:51  ?        0:03 sched

----------------------------------------------------------------------------

종류    설 명

----------------------------------------------------------------------------

UID      프로세스 실행 사용자

PID      프로세스 아이디(식별 번호)

PPID     부모 프로세스 아이디(식별 번호)

STIME    프로세스 시작 시간(Start Time)

TTY      제어 터미널

TIME     CPU 실행 누적 시간

CMD      명령어

----------------------------------------------------------------------------

[참고] ps 명령어 옵션

# man ps

.....

     The ps command prints information  about  active  processes.

    Without  options, ps prints information about processes that

     have the same effective user ID  and  the  same  controlling

    terminal  as  the invoker. The output contains only the pro-

     cess ID, terminal identifier, cumulative execution time, and

     the   command  name.  Otherwise,  the  information  that  is

     displayed is controlled by the options.

 

     Some options accept lists as arguments. Items in a list  can

     be either separated by commas or else enclosed in quotes and

     separated by commas  or  spaces.  Values  for  proclist  and

     grplist must be numeric.

 

     -e     Lists information about every process now running.

 

     -f    Generates a full listing. (See below for significance

            of columns in a full listing.)

 

     -l    Generates a long listing. (See below.)

 

     -a     Lists information about all processes most  frequently

            requested: all  those  except  session  leaders  and

            processes not associated with a terminal.

 

     -t  term

            Lists only process data associated with term. Terminal

            identifiers are  specified as a device file name, and

            an identifier. For example, term/a, or pts/0.

 

     -u  uidlist

            Lists only process data whose effective user ID number

            or login name is given in uidlist. In the listing, the

            numerical user ID will be printed unless you give  the

            -f option, which prints the login name.

 

     -U  uidlist

            Lists information for processes  whose  real  user  ID

            numbers  or login  names  are  given  in uidlist. The

            uidlist must be a single argument in  the  form  of a

            blank- or comma-separated list.

......

 

 


[참고] 솔라리스 시스템의 모든 프로세스 구분

모든 프로세스 종류(Process Type)

- 데몬 (Daemon Process)

- 사용자 프로세스(User Process)

 

+-----------+ <-------+  

|           |         |

|  Daemon   |         |

|           |         |

|-----------| <-+     -e

|           |   |     |

| User Proc.|  -a,-t |

|           |   |     |

+-----------+ <-+ <---+

 

User proc

         t : term

        u : user

 

프로세스를 생성하는 것은 2종류가 있다. 사람 즉 유저가 생성하는 프로세스와 데몬이 생성하는 프로세서다.

그중에서 사용자가 생성하는 프로세스의 목록을 알고 싶다면 ps -a 명령어로 확인이 가능하고, 시스템의 모든 프로세스를 확인하고 싶다면 ps -e명령어로 확인이 가능하다.

 

[참고] Daemon 이란?

시스템을 위해 또는 서비스를 위해 백그라운드에서 동작하는 프로세스이다.

 

 

 

(3). 프로세스 종료

 

프로세스 종료 방법

# kill PID   (# kill -15 PID)

# kill -9 PID

 

* 시그널(Signal)

___________________________________________

 

1  SIGHUP   프로세세 재시작(HangUp)

2  SIGINT   인터럽트(Interrupt, <Ctrl + C>)

9  SIGKILL  강제 종료(force exit signal)

15 SIGTERM  정상 종료(exit)

___________________________________________

 

[참고] 시그널(Signal)이란?

프로세스가 생성하거나 또는 프로세스에게 보내는 비동기적 알림 이벤트이다. 대부분의

동작은 프로세스 종료(Exit), Core 파일 생성(Core), 프로세스 정지(Stop)등이다.

 

# man -s 3head signal

 

# kill -l                 // signal list 확인

# kill -l HUP

# kill -l 1

 

 

[참고] kill 명령어 사용법

# kill PID

# kill -15 PID

# kill -TERM PID

# kill -s term PID         // -s : 특별히 보낼 시그널을 지정 시그널 이름이나 번호가 온다.

# kill -s TERM PID

 

 

[EX] kill -9 명령어 실습

[TERM1] 사용자 윈도우

# telnet localhost

user01 사용자로 로그인

$ id

 

[TERM2] 관리자 윈도우

# w

  5:24오후  up  9:01,  4 users,  load average: 0.02, 0.01, 0.01

User    tty           login@  idle  JCPU   PCPU  what

.....

user01  pts/8         5:24오후                      -ksh

.....

 

# ps -U user01

   PID TTY      TIME CMD

  1185 pts/8    0:00 ksh

# kill -9 1185

 

 

[참고] pgrep 명령어

ps + grep

 

# ps -ef | grep   inetd

    root   186    1  0 08:24:03 ?        0:00 /usr/sbin/inetd -s

# pgrep  -l inetd

  186 inetd

# pgrep  -lf inetd

  186 /usr/sbin/inetd -s

 

 

[참고] pkill 명령어

ps + kill

 

# ps -ef | grep   inetd

# kill -1 inetd's PID

or

# pkill  -1 inetd

 

 

 

[참고] nice & renice

프로세스의 우선 순위 조정 명령어

- nice   : 프로세스의 실행 시킬때 우선 순위를 정의할 수 있다.

- renice : 실행중인 프로세스의 우선 순위를 정의할 때 사용한다.

 

 


3. 프로세스 관리 (2)

 

프로그램을 실행하면 한나의 프로세스가 뜨게 되고, 이것을 하나의 잡(Job)이라고 표시한

. 다음은 잡 단위로 관리하는 방법에 대한 소개이다.

 

 

(1). (Job) 실행

 

잡 실행 방법

- 포그라운드 실행 방법

- 백그라운드 실행 방법

 

         +-----bg-----+

         |            |

+-----fg-----+        |

|            |        |

|            |        |

|            |        |

|            |--------+

|            |

+------------+

 

[EX] 프로세스 실행

# sleep  500 &

[1]     576

 

# sleep  600 &

[2]     579

 

[참고]

[1]   : Job ID

576   : Process ID

 

 

 

(2). (Job) 확인 및 작업 이동

 

Process Verification

 

[EX] (Job) 작업 이동

# jobs

[2] +  Running                 sleep 600 &

[1] -  Running                 sleep 500 &

 

# fg %1

sleep 500

<Ctrl + Z>

^Z[1] + Stopped (SIGTSTP)        sleep 500 &

 

# bg %1

[1]     sleep 500 &

 

 

(3). (Job) 종료

 

프로세스() 종료(Process Exit)

# kill %1 (Process Termination)

# stop %1 (Process Stop)

 

- Ctrl+Z  (Foreground Process Stop)

- stop %1 (Background Process Stop)

 

 

[EX] 프로세스 종료

# kill %1

[1] + Terminated               sleep 500 &

 

# kill %2

[2] + Terminated               sleep 600 &

 

 

 

[참고] 솔라3리스에서 실시간 프로세스를 확인하는 명령어

sdtprocess (GUI, Graphic User Interface)

prstat     (CLI, Command Line Interface)

 

# sdtprocess

or

CDE -> pannel -> Desktop Control -> Find Process

 

sdtprocess 기능(Function)

- 정열하는 방법(CPU, MEM Sor2ting)

- Refresh 시간 지정 방법(Sampling Time)

- 프로세스 찾기(Find Process)

- 프로세스 종료(Process Kill)

 

# prstat

[참고] prstat 프로세스 모니터링

http://blog.naver.com/jwsanta?Redirect=Log&logNo=60009529440

http://blog.naver.com/jwsanta?Redirect=Log&logNo=60009529471

http://blog.naver.com/jwsanta?Redirect=Log&logNo=60009529513

 

 

[참고] UNIX 실시간 프로세스 확인 명령어

- SUN  Solaris : prstat, sdtprocess

- HP  HP-UX   : glance, top

- IBM  AIX     : topas, nmon

 

 

[참고] 유닉스 성능 점검 툴

- sar      system activity reporter

- vmstat   report virtual memory statistics

- iostat   report I/O statistics

- netstat  show network status

- mpstat   report per-processor or per-processor-set statistics


[
참고] 솔라리스 성능에 관련한 점검 툴 

[참고] 솔라리스 성능에 관련한 점검 툴

/root/docs/Reference/SolarisPerformanceAdminTool.txt

 

 

 

[참고] 시그널

 

# man -s 3head signal

     A signal is an asynchronous notification of an event. A sig-

     nal  is said to be generated for (or sent to) a process when

     the event associated with that signal first occurs. Examples

     of such events include hardware faults, timer expiration and

     terminal activity, as well as the invocation of the  kill(2)

     or  sigsend(2)  functions.   In some circumstances, the same

     event generates signals for multiple  processes.  A  process

     may  request  a  detailed  notification of the source of the

    signal  and  the  reason   why   it  was   generated.   See

    siginfo(3HEAD).

 

     Signals can be generated  synchronously  or  asynchronously.

     Events directly caused by the execution of code by a thread,

     such as a reference to an unmapped, protected, or bad memory

     can  generate  SIGSEGV or SIGBUS; a floating point exception

     can generate   SIGFPE;  and  the  execution  of  an  illegal

    instruction can generate SIGILL. Such events are referred to

     as traps; signals generated by traps are said to be synchro-

    nously  generated.  Synchronously generated signals are ini-

     tiated by a specific thread and are delivered to and handled

     by that thread.

 

     Signals may also be generated by calling kill(), sigqueue(),

     or  sigsend().  Events  such as keyboard interrupts generate

     signals, such as SIGINT, which are sent to the  target  pro-

     cess.  Such  events  are  referred to as interrupts; signals

     generated by interrupts are said to be  asynchronously  gen-

     erated. Asynchronously generated signals are not directed to

     a particular thread but are handled by an  arbitrary  thread

     that meets either of the following conditions:

 

        o  The thread is blocked in a call  to  sigwait(2)  whose

          argument includes the type of signal generated.

 

        o  The thread has a signal mask that does not include the

          type  of  signal generated. A process responds to sig-

           nals in similar ways whether it is using  threads   or

          it   is   using  lightweight  processes  (LWPs).  See

          thr_create(3THR). Each process may  specify  a  system

          action  to be taken in response to each signal sent to

           it, called the signal's disposition.  All  threads  or

          LWPs  in the process share the disposition. The set of

          system signal actions for  a  process  is  initialized

          from  that  of its parent. Once an action is installed

           for a specific signal, it  usually  remains  installed

          until another disposition is explicitly requested by a

           call to either  sigaction(), signal() or  sigset(), or

          until   the  process  execs().  See  sigaction(2)  and

          signal(3C). When a process execs,  all  signals  whose

          disposition  has  been set to catch the signal will be

           set to SIG_DFL. Alternatively, a process  may  request

           that the system automatically reset the disposition of

           a signal to  SIG_DFL after it  has  been  caught.  See

          sigaction(2) and signal(3C).

 

 

 

[참고] nice & renice

 

프로세스의 우선 순위 조정 명령어

- nice   : 프로세스의 실행 시킬때 우선 순위를 정의할 수 있다.

          (invoke a command with an altered scheduling priorit)

- renice : 실행중인 프로세스의 우선 순위를 정의할 때 사용한다.

 

 

 

(1). nice 명령어

 

     The nice utility invokes command, requesting that it be  run

     with a different system scheduling priority. The priocntl(1)

     command is a more general interface to scheduler functions.

 

     nice 명령어는 다른 시스템 스케줄링 우선순위가 동작을 요청할때

     사용하는 명령어이다.

 

     The invoking process (generally the user's shell) must be in

     a scheduling class that supports nice.

 

     사용자 쉘에서 사용하는 프로세스 요청은 스케줄링 클래스 중에

     존재해야 한다. 이때 nice 명령어를 사용할 수 있다.

 

     If the C shell (see csh(1)) is used, the full  path  of  the

    command  must be specified; otherwise, the csh built-in ver-

     sion of nice will be invoked. See csh Builtin below.

 

     csh을 사용한다면 nice 명령어의 전체 경로를 지정해야 한다.

     렇지 않으면 csh 내장명령어인 nice가 실행된다.

 

 

(명령어 형식)

# nice CMD

# nice -10 CMD

# nice --10 CMD

# nice -n 10 CMD

# nice -n -10 CMD

 

- 포그라운드로 프로그램을 실행하면 기본적인 NI 값은 20이다.

- 백그라운드로 프로그램을 실행하면 기본적인 NI 값은 24이다.

- "# nice CMD" 실행을 하면 NI 값은 10이 높아진다.

- "# nice --10 CMD" 실행을 하면 NI 값은 10이 낮아진다.

- "# nice -10 CMD" 실행을 하면 NI 값은 10이 높아진다.

 

NI --> 증가, PRI --> 증가, 우선순위 --> 낮아짐

NI --> 감소, PRI --> 감소, 우선순위 --> 높아짐

 

 

[EX] nice 명령어 실습

[TERM1]

# admintool &

# admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2329   561  0  40 20 d4eb6a50   2284 d5fbc94a 21:25:34 pts/6    0:00 admintool

 8 S     root  2328   561  0  52 24 d4f57858   2284 d5fb607a 21:25:28 pts/6    0:00 admintool

 

[TERM1]

admintool 종료 후

# nice admintool &

# nice admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2340   561  0  70 30 d4f57858   2284 d5fb65ba 21:27:40 pts/6    0:00 admintool

 8 S     root  2339   561  0  82 34 d4eb6a50   2284 d5fb607a 21:27:31 pts/6    0:00 admintool

 

[TERM1]

admintool 종료 후

# nice --10 admintool &

# nice --10 admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2366   561  0  40 10 d4f54e58   2284 d5f7c572 21:34:22 pts/6    0:00 admintool

 8 S     root  2365   561  0  40 14 d4e64748   2284 d5fb8d32 21:34:13 pts/6    0:00 admintool

 

 

[TERM1]

admintool 종료후

# nice -5 admintool &

# nice -5 admintool

 

[TERM2]

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2356   561  0  67 29 d4f54e58   2284 d5f8f14a 21:31:21 pts/6    0:00 admintool

 8 S     root  2357   561  0  55 25 d4e64748   2284 d5fb8d32 21:31:29 pts/6    0:00 admintool

 

 

 


(2). renice 명령어

 

     The renice command alters the scheduling priority of one  or

     more  running  processes.  By  default,  the processes to be

     affected are specified by their process IDs.

 

     renice 명령어는 하나 또는 그 이상의 프로세스의 스케줄링 우선

     순위를 조정하는 명령어이다.

 

     If the first operand is a number within the valid  range  of

    priorities  (-20  to 20), renice will treat it as a priority

     (as in all but the first synopsis form).  Otherwise,  renice

     will treat it as an ID (as in the first synopsis form).

 

     만약 첫번째 연산자가 숫자라면(우선순위 범위: -20 ~ 20) renice

     명령어는 우선순위를 다루게 된다. 그렇지 않다면, renice 명령어

     는 그것을 ID(PID)로 다루게 된다.

 

  Altering Process Priority

     Users other than the privileged  user  may  only  alter  the

    priority  of  processes they own, and can only monotonically

     increase their "nice value" within the range 0 to  19.  This

    prevents  overriding  administrative  fiats.  The privileged

     user may alter the priority  of  any  process  and  set  the

     priority to any value in the range -20 to 19. Useful priori-

     ties are: 19 (the affected  processes  will  run  only  when

     nothing else in the system wants to); 0 (the "base" schedul-

     ing priority),; and any negative value (to  make  things  go

     very  fast).  20  is  an  acceptable nice value, but will be

     rounded down to 19.

 

     권한이 있는 사용자들은 단지 자신의 프로세세에 대한 우선순위를

     조정할 수 있다. 그리고 "nice value" (value is 0 to 19) 명령어

     를 통해서 우선순위를 일정하게 증가만 시킬수 있다. 이것은 관리

     자의 명령어 수행과 중첩되는 것을 막아 준다.  권한이 있는 사용

     자 어떤 프로세스의 우선순위를 조정할 수 있을 것이다.  그리고

     우선순위를 설정하기 위한 값의 범위는 "-20 ~ 19"로 설정 할 수

     있다.

     19 => 일반적인 우선순위(시스템에서 영향을 받지 않는 경우)

     0  => "base" 스케줄링 우선순위

     negative value => 더 높은 우선순위를 나타냄

     20 => 사용할 수 있는 nice 값이다. 그러나 19로 설정할 수도 있

     .

 

 

(명령어 형식)

 

# renice 15 PID

# renice -15 PID

# renice -n 15 PID

# renice -n -15 PID

 

- 포그라운드로 프로그램을 실행하면 기본적인 NI 값은 20이다.

- 백그라운드로 프로그램을 실행하면 기본적인 NI 값은 24이다.

- "# renice CMD" 실행을 하면 현재 NI 값에 10이 더 높아진다.

- "# renice 10 CMD" 실행을 하면 NI 값은 기본값(20) 10이 더 높아진다.

- "# renice -10 CMD" 실행을 하면 NI 값은 기본값(20) 10이 더 낮아진다.

 

NI --> 증가, PRI --> 증가, 우선순위 --> 낮아짐

NI --> 감소, PRI --> 감소, 우선순위 --> 높아짐

 

 

[EX] renice 명령어 실습

[TERM1]

# admintool &

# admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  52 24 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 20 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 5 2474     

# renice 5 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  55 25 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  55 25 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 10 2474

# renice 10 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  70 30 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  70 30 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 40 2474

renice: 40:getpriority: No such process

# renice 40 2475

renice: 40:getpriority: No such process

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  97 39 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  97 39 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

renice 명령어 다음에 있는 40 PID 번호로 인식했다. renice 명령어의 최대 범위는 20

지이다. 이것을 넘으면 renice 명령어를 그냥 실행 한 것과도 같아 진다. renice 명령어를

우선순위 값 없이 사용한다면 이전의 NI 값에 10을 더하게 된다. 하지만 NI의 최대 범위는

39를 넘을 수 없다.

 

아래와 같이 원래 우선순위로 조정한다.

 

# renice 4 2474

# renice 0 2475


# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474  561  0  52 24 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 20 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 2474

# renice 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI     ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  82 34 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  70 30 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 2474

# renice 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  97 39 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  97 39 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

renice 명령어 다음에 있는 40 PID 번호로 인식했다. renice 명령어의 최대 범위는 20
지이다. 이것을 넘으면 renice 명령어를 그냥 실행 한 것과도 같아 진다. renice 명령어를
우선순위 값 없이 사용한다면 이전의 NI 값에 10을 더하게 된다. 하지만 NI의 최대 범위는
39
를 넘을 수 없다.

아래와 같이 원래 우선순위로 조정한다.

 

# renice 4 2474

# renice 0 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  52 24 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 20 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice -10 2474

# renice -10 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  40 10 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 10 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice -19 2474

# renice -19 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  40  1 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40  1 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice -25 2474

# renice -25 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  40  0 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40  0 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

 renice 명령어를 통해서 NI 값의 최소 범위는 -19이다. 이것보다 더 큰 값을 쓰더라도 모

  -19로 인식된다.

 renice 명령어를 통해서 NI 값의 최소 범위는 -19이다. 이것보다 더 큰 값을 쓰더라도 모
-19로 인식된다.

 


2008. 8. 8. 01:15

Chapter 7. Korn Shell Characteristic

Chapter 7.  Korn Shell Characteristic

_________________________________

 

 

Redirection

Pipe

Korn Shell Function

Variable

Korn Shell Metacharacter

History

Alias

Environment File

 

 

■ 커널의 기능

- 하드웨어 자원 관리

- Device 관리

- 메모리 , 가상메모리 관리

 

 

쉘의 기능(Shell Function)

- 명령어 해석기(Command Interpreter)

- 프로그램 할수 있는 언어(Programable Language)

 

 

(1). 방향 재지정(Redirection)

 

 

fd(파일 기술자, File Descriptor)

 

[EX] 프로그램에서의 File Descriptor

main()

{

    int fd;

    fd=open(......);

}

 

 

예약되어진 파일 기술자(File Descriptor)

---------------------------------------

번호  설 명

---------------------------------------

0    표준입력 stdin (Standard Input)

1    표준출력 stdout(Standard Ouput)

2    표준에러 stderr(Standard Error)

---------------------------------------

 

 

stdin(Keyboard)======> SHELL ========> stdout(Monitor)

                            |

                            |

                     stderr(Monitor)

 

         [그림] 표준입력, 표준출력, 표준에러

 

[EX] 표준출력, 표준에러의 예

# ls /var /nodir

 

 

[EX] 표준입력, 표준출력의 예

# cat

Hello    stdin

Hello    stdout

Solaris

Solaris

<Ctrl + D>

 

# cat <  /etc/passwd

# cat >  filename

Hello

Solaris

<Ctrl + D>

# cat filename

 

 

 

(1.1) 입력 재지정(Redirection stdin)

 

[FORMAT]  CMD   <   filename

          CMD  0<  filename

          CMD  <<  filename(X) => Here Documentation

 

# mailx  -s "Solaris TEST" root@example.com < mail.txt

 

[참고] mailx 명령어를 통한 메일 보내기

# mailx  root

Subject: Solaris TEST  <---- 메일 제목 입력("Solaris TEST")

test mail for user01  <---- 내용 입력

<ctrl+D>  or  .        <---- <Ctrl + D> 입력

#

 

 

 

(1.2) 출력 재지정(Redirection stdout)

 

[FORMAT]  CMD   >   filename

          CMD  1>   filename

           CMD  >>   filename

          CMD  1>>  filename

 

# ls -l > file.txt

# cat file.txt

 

[참고] '>>'(출력 리다이렉션)을 사용한 파일 내용 추가

 

----file1----

    1111

    2222

-------------

 

# echo 1111 > file1

# echo 2222 > file1

# cat file1

# echo 3333 >> file1

 

 

 

(1.3) 에러 재지정(Redirection stderr)

 

[FORMAT]  CMD  2>   filename

          CMD  2>>  filename

 

# ls /var /nodir > file.txt

 

Standard Output

Standard Error

 

# ls /var /nodir 2> file.txt

 

Standard Output

Standard Error

 

# ls /var /nodir > file1.txt 2>    file2.txt

 

Standard Output

Standard Error

 

# ls /var /nodir > file1.txt 2>&1    

// > 로 표준 출력을 file1.txt에 주고 2> 로 표준에러를 &1(표준출력) 로 리디렉션

 

[참고]  Redirection : CMD > filename

         PIPE        : CMD | CMD

 

# ls -l  1> 1

 

[참고] 터미널 출력이 있는 명령어 수행시

# cmd > file.log      (X)

# cmd > file.log 2>&1 (0)

 

[참고] CMD 2>/dev/null

일반사용자 전체 시스템의 파일과 디렉토리 목록중에 core 파일을 찾을려고 할때 검색할려고

하는 내용보다 권한이 되지 않아서 'Permission Denied' 에러 메세지가 더 많이 출력되는 경

우가 존재할 수 있다. 이런 경우 명령어의 마지막에 '2>/dev/null'을 붙여서 에러메세지는

보지 않고 정상적인 출력 결과만 보는 경우가 있다.

 

$ find / -name core -type f 2>/dev/null

 

 

[참고] confiugre --prefix=/usr/local/apache 2> apache.log

# ./configure --prefix=/usr/local/apache 2> apache.log

# ./configure --prefix=/usr/local/apache > apache.log 2>&1

 

 

 


(2). pipe

앞의 CMD의 출력 결과가 뒤의 CMD 입력값으로 들어간다.

 

[FORMAT] CMD  |    CMD

            -------

            -------

           Kernel Buffer

 

 

# ls -l | grep Error (X)

 

 

# ls -l > file.txt

# grep Error file.txt

 

ls -l          grep Error file.txt

      file.txt

 

# ls -l | grep Error

    ----------

    ----------

   Kernel Buffer

 

 

[EX] pipe 활용 예

# ps -ef | more          (# CMD | more) 한페이지가 넘는 페이지 출력 방법 지정

# ps -ef | grep   inetd  (# CMD | grep inetd) 앞단의 명령어의 출력 결과 중 패턴 검색

 

 

[참고] tee 명령어

 

# ps -ef | grep inetd > file.log

      -------             A

              ------------+

       -------

# ps -ef | grep inetd | tee file.log

 

                ----------           

                ---+ +----          

                    | |

                  file.log

 

EX) tee 명령어 실습

CMD > file.log

CMD | tee file.log

# cal 2002 > file1.log

# cal 2002 | tee file2.log

 

tee 입력값을 화면과 파일에 동시에 출력 시켜줌

 


(3) 콘셀의 기능(Korn Shell Function)

 

# set -o

....

ignoreeof         off

....

markdirs off

....

noclobber         off

....

vi                on

....

 

# set -o vi

# set +o vi

 

 

 

(3.1) 파일 덮어쓰기 방지 기능

 

set -o noclobber

 

# set -o noclobber

# set -o | grep noclobber

# echo 1111 > file1

# echo 2222 > file1

ksh: file1: file already exists    <----- 메세지 확인

 

[참고] CMD >| file1

# echo 3333 >| file1

 

 

(3.2) 파일 이름 자동 완성 기능 & 명령행 편집

 

Filename Completion & Command Line Edit

set -o vi

set -o emacs

# set -o vi

# export EDITOR=vi

# export VISUAL=vi

 

 

(a). 명령행 편집(Command Line Edit)

k (pre-CMD)

j (back-CMD)

h(<-), l(->)

w, b, dd, d$, d0

 

[EX] Command Line Edit

# find / -name core -type f

<Ctrl + C>

# <ESC><K>

# find / -name file1 -type f

 

 

(b). 파일 이름 자동 완성 기능(Filename Completion)

(실습 준비)

# cd /test

# rm -r *

# mkdir dirname1

# touch file.log

 

(자동 완성 기능 실습)

# cd dir<ESC><\>

 

# cd /test

# mkdir dir2

# cd dir<ESC><\>

<ESC><=>

1) dir2/

2) dirname1/

# cd dirn<a><ESC><\>

 

[참고] 와일드 카드(Wild Card)

# cd dirn*

dirname1

dir1

 

[참고] Copy & Paste

(1). Select, Drag & Drop

(2). Mouse Right Button Click & Edit Menu Selection

(3). Ctrl + Insert, Shift + Insert

 

 

 

 

 

[정리] 긴 이름을 가진 파일/디렉토리 다루기

(a). 파일이름자동 완성 기능 사용

(b). 와일드 카드 사용

(c). 복사 & 붙이기

 

 

 

 

 

(3.3) 로그 아웃 방지 기능

 

set -o ignoreeof

 

EOF(End Of File)의 의미를 갖는 <Ctrl + D>가 존재한다.

 

<Ctrl + D>의 의미는?

(a). 파일의 끝을 알려 주는 기능

(b). 현재 프로그램 종료()의 기능

갖는다.

 


(a). 파일의 끝 의미를 갖는 <Ctrl + D>

# mailx root

> Subject : TEST

hello

<Ctrl + D>

 

(b). 현재 프로그램() 종료의 의미를 갖는 <Ctrl + D>

# telnet 172.16.8.254

root 사용자로 로그인

# <Ctrl + D> => 로그아웃된다.

 

# telnet 172.16.8.254

root 사용자로 로그인

# set -o ignoreeof

# <Ctrl + D> => 로그아웃 되지 않는다.

# exit

 

 

 

(4) 변수(Variable)

- 지역 변수(Local Variable)

- 환경 변수(Global Variable, Environment Variable)

- 특수 변수(Special Variable)

// 지역변수와 환경변수의 차이는 export 되었는지에 따라 다르다.

 

(4.1) 변수 선언(Variable Define)

 

sh ------> ksh ------> zsh ------> bash

 

(본쉘 스타일)

(a). 변수를 선언하는 방법

# VAR=5    (변수의 값으로는 숫자나 문자 구별하지 않는다.)

# VAR=hello

# export VAR

 

(b). 변수의 내용을 확인하는 방법

# echo $VAR

 

(c). 변수의 내용을 초기화 하는 방법

# unset VAR

 

(콘쉘 스타일)

(a). 변수를 선언하는 방법

# export VAR=hello

 

(b). 변수의 내용을 확인하는 방법

# print $VAR

 

(c). 변수의 내용을 초기화 하는 방법

# unset VAR

 

 

[EX] 변수 선언 테스트

# VAR=hello

# echo $VAR

# unset  VAR

# echo $VAR

 

 

 

(4.2) export의 의미

# ps

   PID TTY      TIME CMD

   408 pts/3    0:00 ksh

 

# VAR1=5

# VAR2=10

# export VAR2

 

# ksh

# ps

   PID TTY      TIME CMD

   408 pts/3    0:00 ksh

   994 pts/3    0:00 ksh

 

# echo $VAR1

# echo $VAR2

 

# exit

# echo $VAR1

# echo $VAR2

 

 

VAR1=5,  VAR2=10

-----------------+                      +-----------------

                |                   |

                | VAR1=?, VAR2=?    |

                +-------------------+

 

 

 

(4.3) EDITOR, VISUAL

기본적인 편집기를 선언할 때 사용.

 

# EDITOR=vi

# EDITOR=/usr/bin/vi

# export EDITOR

or

# VISUAL=vi

# VISUAL=/usr/bin/vi

# export VISUAL

or

# set -o vi

 

[참고] 기본적인 편집기 선언

OS(썬 개발 프로그램)   : Default Editor (set -o vi)

Oracle DB              : EDITOR

 

 

[참고] set / env

set   : 모든 변수(지역변수 + 환경변수)

env   : 환경변수

 

# VAR1=ITBANK   => 지역변수

# VAR2=SOLARIS  => 환경변수

# export VAR2

 

# set | grep VAR1 (0)

VAR1=ITBANK

# set | grep VAR2 (0)

VAR2=SOLARIS

 

# env | grep VAR1 (X)

# env | grep VAR2 (0)

VAR2=SOLARIS

 

0: View

X: Not View

 

 

 

(4.4) PS1

쉘 프롬프트를 정의할 때 사용하는 변수

 

- root 사용자의 쉘프롬프트 : #

- 일반 사용자의 쉘프롬프트 : $

 

# PS1=[solarisXXX]#

# export PS1

 

# PS1='$PWD> '

# PS1='[$PWD]# '

# export PS1

 

[참고] Bash Shell에서의 PS1 정의 방법

쉘프롬프트: [solaris254@root:/]#

(ksh ) # PS1=[`hostname`@$LOGNAME:'$PWD]# '// 명령어+자신의이름+현재폴더

(bash) # PS1='[\h@\u:\w]$$'

 

 

(4.5) PATH

명령어 검색 위치 지정 변수

 

# PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/ucb

# export PATH

 

EX) ls 명령어 수행

# ls -l

# /usr/bin/ls -l

# cd /usr/bin

# ./ls -l

 

 

[참고] 스크립트 디렉토리

/root/bin, /root/shell : 스크립트 디렉토리

# PATH=$PATH:/root/shell

# export PATH

# script.sh

 

 

[참고] 명령어 실행시 에러 메시지

# cmd

......

ksh: command: not found

......

# find / -name cmd -type f

- 1> 명령어가 없는 경우(-> 명령어 설치)

- 2> PATH 변수에 명령어의 경로가 정의가 않은 경우(-> PATH 변수에 경로 추가)

 

EX) ethereal & printmgr

# ethereal (ksh : ethereal: not found) => 프로그램이 설치 안된 경우

# printmgr (ksh : printmgr: not found) => PATH 변수에 경로가 추가 되지 않은 경우

 

 

 

(4.6) MANPATH

매뉴얼 페이지 검색 경로를 지정할 때 사용

 

# MANPATH=/usr/man:/usr/dt/man:/usr/local/man

# export MANPATH

 

# man ls

(매뉴얼 페이지가 보인다.)

# echo $MANPATH

......:/usr/man:...... (/usr/man ---> /usr/share/man)

 

 

[참고] 매뉴얼 페이지 디렉토리 확인

# cd /usr/share/man

# ls

 

 

 

(4.7) LD_LIBRARY_PATH

라이브러리의 경로를 검색할때 사용하는 변수

 

# LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/usr/local/lib

# export LD_LIBRARY_PATH

 

라이브러리

- 동적 라이브러리(Dynamic Lib.)    : XXXXXX.so

- 정적 라이브러리(Static Lib.)     : XXXXXX.a

 

EX) ls 명령어의 동적 라이브러리 확인

# ldd /usr/bin/ls

         libc.so.1  =>    ?

         libdl.so.1 =>    /usr/lib/libdl.so.1

         /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1

......

ld.so.1: gs: fatal error: libpng.so.2 : open fail : no such file or directory

......

 

# find / -name "libpng.so.2" -type f 2>/dev/null

- libpng.so.2 라이브러리를 찾은 경우

- libpng.so.2 라이브러리를 찾을 수 없는 경우

 

(a). 라이브러리 파일을 찾은 경우

# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

 

(b). 라이브러리 파일을 못 찾은 경우

http://docs.sun.com -> 검색창 -> "libpng.so.2"-> SUNWxxx

http://www.sunfreeware.com

# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

 

 

[참고] 솔라리스 패키지 설치시 고려해야 하는 변수

패키지(Package)

-----------------------

Binary Command(Daemon)  => /usr/local/bin

Configuration File

Library                 => /usr/local/lib

Manual                  => /usr/local/man

Documentation

-----------------------

- PATH

- MANPATH

- LD_LIBRARY_PATH

 

 

 

(4.8) 기타 환경 변수

HOME / PWD / LOGNAME

# echo $HOME

/

# echo $PWD

/test

# echo $LOGNAME

root

 

EX) $HOME의 활용

# cd

# cd $HOME

 

 

 

(4.9) 특수 변수(Special Variable)

- $ : 현재 쉘의 PID 번호를 저장하고 있다.

- ? : 바로 이전 명령어의 정상 실행 여부에 대한 결과 값이 들어 있다.

- ! : 바로 이전 백그라운드 프로세스에 대한 PID 번호를 저장하고 있다.

- 인자변수($0, $1, $2, ....)

 

# echo $$

450

# ps

 

# cal

# echo $?

 

# ls /nodir

# echo $?

 

# sleep 200 &

[1] 450

# echo $!

 

 

[참고] Login Variables

---------------------------------------------------------------

변수이름   선언주체         설명

---------------------------------------------------------------

LOGNAME    login            사용자 로그인 이름 정의

HOME       login            사용자의 홈디렉토리 정의

SHELL      login            사용자의 기본 쉘 정의

PATH       login            사용자의 명령어 검색 경로 정의

MAIL       login            사용자의 mailbox 경로 정의

TERM       login            사용자의 사용 터미널 정의

LPDEST     기본 선언 아님   기본 프린터 정의

PWD        shell            현재 작업 디렉토리 정의

PS1        shell            쉘 프롬프트 정의(sh, ksh)

prompt     shell            쉘 프롬프트 정의(csh)

---------------------------------------------------------------

 

 

 

 

 

[정리] 변수(Variable)

 

- 변수 선언 방법(Variable Definition)

- export 의미?

- 쉘 환경 변수(Shell Environment Variable)

         EDITOR, PATH, MANPATH, LD_LIBRARY_PATH

 

- 지역변수(Locale Variable)

- 환경변수(PATH, MANPATH, LD_LIBRARY_PATH, etc)

- 특수변수(Special Variable)

         $$, $?, $!

 

 

 

 

 

 

 

(5) Korn Shell Metacharater

 

- ' ' :  작은 따옴표(single quote)

- " " :  큰 따옴표(double quote, $, ` `, \)

- ` ` :  역 따옴표(back quote)

- \   :  역 슬래쉬(back slash)

- ;   :  세미콘론(semicolon)

 

[EX] 작은 따옴표 실습(single quote)

// 작은 따옴표는 안에 들어 있는 모든 것들의 쉘 해석을 막는다. 특별한 의미가 없이 그냥 하나의 문자로 인식이 된다. 문자는 공백을 포함한다.

# echo $HOME

# echo '$HOME'

 

[EX] 큰 따옴표 실습(double quote)

// 큰 따옴표는 작은 따옴표와 같은 동작을 하지만 $ , ``, \ 문자의 해석은 제외한다.

# echo "$HOME"

# echo "$HOME is my   directory."

 

[EX] 역 따옴표 실습(back quote)

// 쉘은 역따옴표 안에 있는 것을 명령어로 생각 하고 실행하게 된다.

 

# hostname

# echo `hostname`

# echo `date`

# echo "`hostname` is my hostname.!!!"

# echo "$(hostname) is my hostname.!!!"

 

[EX] 역 슬래쉬 실습(back slash)

// 쉘은 역 슬래쉬 뒤에 오는 것의 의미를 제한하도록 한다.

# echo $HOME

# echo \$HOME

# echo "\$HOME is my directory"

 

# find / -name core -type f -exec rm {}     \;

# find / -name core -type f -exec rm {}     ';'

 

(참고) \

-> `명령어` : 명령어 실행 결과 출력 표시

-> 명령어 \ : 명령어가 아직 끝나지 않음을 표시

         # ls -l

         # ls \

         > -l

 

[EX] 세미콜론 테스트(semicolon)

excution mutliple command a line

 

# date ; cal ; ls -l

# date

# cal

# ls -l

 

 

 

(6) history

 

 

|        | STACK

|        |

|        |

+--------+

 

# history

# history -r (reverse)

# history -n (not number)

# history -5

 

[참고] 히스토리 참고 파일 및 변수

~/.sh_history 히스토리 내용을 지속적으로 저장하는 파일

HISTSIZE    히스토리를 기록하는 Stack의 크기를 지정하는 파일

HISTFILE    히스토리 내용을 지속적으로 저장하는 파일 이름 지정

 

[EX] HISTSIZE, HISTFILE 변수 지정

# HISTSIZE=128 ; export HISTSIZE

# HISTFILE=~/.sh_history ; export HISTFILE

 

     HISTSIZE

           If this variable is set when  the  shell  is  invoked,

          then  the  number  of previously entered commands that

           are accessible by this shell will be greater  than  or

          equal to this number.  The default is 128.

 

     HISTFILE

           If this variable is set when  the  shell  is  invoked,

          then  the  value is the pathname of the file that will

           be used to store the  command  history.  (See  Command

          re-entry below.)

 

 

[참고] r (re-excution)

# history

# r

# r 450

# r vi

# r etc=var 450          ( 450 # vi /etc/dir1/dir2/dir3/filename)

 

 

 

(7) alias

 

선언 방법       # alias    cp='cp -i'

 

선언 확인 방법  # alias

                # alias    cp

 

선언 해제 방법  # unalias cp

 

 

[참고] unalias & Backslash

# \rm -r dir1

 

EX) \rm -r dir1 실습

# cd /test

# mkdir dir1

# cd dir1

# touch file1 file2 file3 file4

# cd ..

# alias rm='rm -i'

# rm -r dir1

rm: examine files in directory dir1 (y/n)? <Ctrl + C>  <----- '<Ctrl + C> 입력

# \rm -r dir1

 

(참고) rm -f (force)

# rm -rf dir1 (일부 유닉스)

 

 

 

 

[정리] 콘쉘의 특징

- Redirection

- Pipe

- Korn Shell Function

- Variable

- Metacharacter

- history

- alias




(8) 환경 파일

 

사용자 로그인시   적용되는 환경파일

 

/etc/profile : 전체 사용자 환경 설정 파일

~/.dtprofile : CDE 환경 사용자 환경 설정 파일 (DTSROUCEPROFILE=true)

~/.profile   : 개인 사용자 환경 설정 파일  (ENV=/.kshrc)

~/.kshrc     : 개인 사용자 환경 설정 파일

 

 

사용자가 CDE 환경으로 로그인하게 되는 경우

/etc/profile

~/.dtprofile

~/.profile

~/.kshrc

파일들이 읽혀 진다. 

 

사용자가 Command Line Login을 하는 경우

/etc/profile

 

~/.profile

~/.kshrc

파일들이 읽혀 진다.

 

/etc/profile ~/.dtprofile, ~/.profile은 로그인시에 한번 읽혀 지고, ~/.kshrc 파일은 콘

쉘이 실행될때 마다 실행이 된다.

 

 

(8.1) /etc/profile

* ~/.profile ~/.kshrc        파일에 정의 될수 있는 모든것들에 대해 정의 가능

* 시스템의 모든 사용자에게 적용할 것에 대한 정의

 

 

(8.2) ~/.profile

* 변수 선언

- PATH

- ENV

- EDITOR

- 기타

 

 

(8.3) ~/.kshrc

* 특정 변수 선언(PS1)

* set -o 설정

* alias  설정

 

 

[참고] 솔라리스 기본 환경 파일 해석

/etc/profile

~/.profile   (-> ENV_main.sh)

~/.kshrc     (-> ENV_main.sh)

 

 

(a). /etc/profile 파일의 해석

 

---------------- /etc/profile 해석-------------------------------

trap ""  2 3 -----> /etc/profile 파일을 실행하는 동안(로그인시) 2번 시그널,

                    3번 시그널을 받아도 종료하지 않는다.

export LOGNAME PATH

-----> 변수 export(/usr/bin/login)

 

if [ "$TERM" = "" ]      -----> $TERM 변수가 선언 안되어 있으면

then

        if /bin/i386     -----> i386(32bits) 일반운영체제

        then

                TERM=sun-color

        else

                TERM=sun

        fi

        export TERM

fi

 

#       Login and -su shells get /etc/profile services.

#       -rsh is given its environment in its .profile.

 

case "$0" in               -----> -ksh /etc/profile

-sh | -ksh | -jsh | -bash)          A

                                    +----- $0

        if [ ! -f .hushlogin ] -----> ~/.hushlogin 파일이 존재하지 않으면    

        then

                /usr/sbin/quota -----> Quota 실행

                #       Allow the user to break the Message-Of-The-Day only.

                trap "trap '' 2"  2

                /bin/cat -s /etc/motd  -----> 로그인시 /etc/motd 내용 출력

                trap "" 2

 

                /bin/mail -E    -----> 새로운 메일이 존재 하면

                case $? in

                0)

                        echo "You have new mail."

                        ;;

                2)

                        echo "You have mail."

                        ;;

                esac

        fi

esac

 

umask 022    -----> UMASK 설정

trap  2 3

--------------------------------------------------------------------

(b). ~/.profile 해석

 

------------------------ ~/.profile 해석 ----------------------------

# (1). stty erase ^H

stty erase ^H    # <Backspace>

# stty erase ^?  # <Delete>

 

-----> Set Terminal Type

         # tty

         # stty

         # stty -a

         ..... erase = ^h .....

         # stty erase <DELETE>

 

# (2). ENV Variable

ENV=~/.kshrc

-----> 추가적인 환경 파일 정의

 

 

# (3). EDITOR Variable

EDITOR=/usr/bin/vi

-----> 기본적인 편집기 선언 변수

 

 

# (4). PATH Variable

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb

PATH=$PATH:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin

PATH=$PATH:/usr/lib/netsvc/yp:/usr/apache/bin

PATH=/usr/sfw/bin:/usr/sfw/sbin:/usr/local/sbin:/usr/local/bin:$PATH

PATH=/usr/local/ssl/bin:$PATH

-----> 명령어의 실행 위치 정의 변수

 

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb\

:/usr/dt/bin:/usr/ccs/bin:/usr/openwin/bin\

:/usr/lib/netsvc/yp:/usr/apache/bin\

:/usr/sfw/bin:/usr/sfw/sbin:/usr/local/sbin:/usr/local/bin\

:/usr/local/ssl/bin

 

 

# (5). MANPATH Variable

MANPATH=/usr/share/man:/usr/man:/usr/openwin/share/man

MANPATH=/usr/sfw/share/man:/usr/local/man:/usr/local/ssl/man:$MANPATH

 

 

# (6) LD_LIBRARY_PATH Variable

LD_LIBRARY_PATH=/usr/lib:/usr/secure/lib:/usr/local/lib

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ssl/lib:/usr/sfw/lib

 

 

export ENV EDITOR PATH MANPATH LD_LIBRARY_PATH

---------------------------------------------------------------------------

 

 


(c). ~/.kshrc 파일의 해석

 

------------------------ ~/.kshrc 파일 해석 -------------------------------

# (1). set -o

set -o vi

set -o trackall  -----> Tracked Alias // 사용된 명령어를 PATH를 뒤지지 않고 기억하고 있다 (빠른검색)

# set -o ignoreeof

# set -o noclobber

 

 

# (2). PS1 Variable

-----> 쉘 프롬프트 정의 변수

# PS1=[$LOGNAME@`hostname`:'$PWD]# '            # EX) [root@solaris254:/]#

# PS1=[`hostname`@'$PWD]# '                     # EX) [solaris254@/]#

# PS1='$PWD'"[`hostname`]# "                    # EX) /etc[sun02]#

# PS1='$PWD> '                                  # EX) /etc>

PS1=['$PWD]# '                                  # EX) [/]#

export PS1

 

 

# (3). alias

# (a). 기본적인 alias

alias c='clear'

alias h='history'

alias cp='cp -i'

alias mv='mv -i'

alias rm='rm -i'

alias ls='ls -hF'

alias llt='ls -aihlF'

alias ll='ls -ailhF | more'

 

# (b). 필요한 경우 선언하는 alias

alias lsf='ls -al | grep ^-'

alias lsd='ls -al | grep ^d'

alias dir='ls -ailhF | more'   -----> 윈도우즈 명령어 실행 alias

alias ipconfig='ifconfig -a'   -----> 윈도우즈 명령어 실행 alias

 

#alias cat='cat -n'

alias df='df -h'

alias nslookup='/usr/sbin/nslookup'

 

# (c). 편리한 기능의 alias

/*

         Webserver(Apache)

         /etc/apache/httpd.conf -----> Configuration File

         /var/apache/htdocs     -----> Source Directory

         /var/apache/logs       -----> Log Directory

         설정 파일을 빨리 편집하도록 하는 기능

*/

alias fconfig='vi /etc/ftpd/ftpaccess'

alias hconfig='vi /etc/apache/httpd.conf'

# 소스디렉토리 이동

alias hdir='cd /var/apache/htdocs'

# 로그파일 모니터링

alias mlog='tail -f /var/adm/messages'

alias slog='tail -f /var/adm/sulog'

alias sslog='tail -f /var/log/syslog'

 

 

# (4). Function

-----> alias pps='ps -ef | head -1 ; ps -ef | grep $1' 같은 기능 제공

pps () {

    if [ $# -ne 1 ] ; then

        echo Usage : $0 Process

    fi

    /usr/bin/ps -elf | head -1

    /usr/bin/ps -elf | grep $1 | grep -v grep

}

 

ppss () {

    if [ $# -ne 1 ] ; then

        echo Usage : $0 Process

    fi

    /usr/ucb/ps -aux | head -1

    /usr/ucb/ps -aux | grep $1 | grep -v grep

}

 

-------------------------------------------------------------------------

 

 

 

 

 

(8.4) 쉘별 환경 파일(sh/ksh/csh User Initialization File)

_______________________________________________________________________________

 

Shell   User           Description

        Initialization

        File

_______________________________________________________________________________

 

sh      /etc/profile    Defines system wild environment at login

        $HOME/.profile  Defines user's environment at login

 

csh     /etc/.login     Defines system wild environment at login

        $HOME/.cshrc    Defines user's environment for all C shells

                        invoked after login shell

        $HOME/.login    Defines user's environment at login

 

ksh     /etc/profile    Defines system wild environment at login

        $HOME/.profile  Defines user's environment at login

        $HOME/$ENV      Defines user's environment at login in the file

                        specified by the Korn shell's ENV environment variable

_______________________________________________________________________________

 

 


[참고] 배쉬쉘 환경 파일(Bash Shell User Initialization Files)

/etc/profile        전체 사용자 환경 파일

~/.bash_profile      사용자 개인 환경 파일

~/.bashrc            사용자 개인 환경 파일

 

 

 

(8.5) 사용자 기본 환경 파일(Default User Initialization Files)

 

/etc/skel (skelton)

_________________________________________

 

Shell           Default File

_________________________________________

 

csh            /etc/skel/local.login

                /etc/skel/local.cshrc

ksh            /etc/skel/local.profile

_________________________________________

 

 

 

[EX] /etc/skel 디렉토리

# useradd -m -d /export/home/user03 -s /bin/ksh user03

# passwd user03

 

# ls -al /export/home/user03

# ls -al /etc/skel

 

# cat > /etc/skel/.exrc

set showmode

set number

<Ctrl + D>

 

# useradd -m -d /export/home/user04 -s /bin/ksh user04

# passwd user04

 

# ls -al /export/home/user04

# ls -al /etc/skel

 

 

 

[참고] 관리자가 사용자의 환경 초기화하는 방법

- /etc/profile 사용하는 방법

- /etc/skel 사용하는 방법

 

 

 


(8.6) 사용자 변수 선언(User Variable Definition)

 

사용자 변수 선언시 sh 계열과 csh 계열은 차이점이 존재한다.

 

(a). csh 계열(csh/tcsh style)

 

변수 선언 방법    # setenv VAR 5

 

변수 확인 방법    # echo $VAR

 

변수 해제 방법    # unset VAR

 

 

 

(b). sh 계열(sh/ksh/zsh/bash style)

 

변수 선언 방법    # VAR=5

                  # export VAR

 

변수 확인 방법    # echo $VAR

 

변수 해제 방법    # unset VAR


2008. 8. 7. 21:37

Chapter 6. Vi 편집기

Chapter 6.  Vi Editor

________________________

 

screen-oriented(visual) display editor based on ex

 

(1). vi 편집기의 특징(Visual Editor Characteristic)

 

- 전체 화면 모드 편집기(Full Screen Editor, Visual Editor)

- ex 편집기의 기능 확장 편집기(vi editor based on ex.)

 

[참고] /root/docs/Fundamental/Ref_vi_example.txt

 

 

 

(2). vi  편집기 실행하기

 

# vi  (: w filename)

# vi filename

# vi -r  filename (recovery)   // 복구 모드

# vi L                       // 리스트 찾기 , 에러난 파일

# vi +38 filename             // 수정 작업을 38(특정)라인에서 바로 시작할 때!

 

     -L    Lists the name of all files saved as the result of  an

          editor or system crash.

 

     -r filename

          Edits  filename  after  an  editor  or  system  crash.

          (Recovers  the  version  of  filename  that was in the

          buffer when the crash occurred.)

 

[EX] vi -r filename 형식의 예

# mailx

..... (중략) .....

A copy of an editor buffer of your file "/etc/vfstab" was saved on solaris254

when the system went down.

This buffer can be retrieved using the "recover" command of the editor.

An easy way to do this is to give the command "vi -r /etc/vfstab".

This works for "edit" and "ex" also.

 

 

[EX] vi -L 형식의 예

# vi -L

/usr/preserve/root:

On   1 01 at 09:00, saved 0 lines of file ""

On   1 17 at 12:27, saved 61 lines of file "/.kshrc"

On   2 15 at 10:13, saved 21 lines of file "/etc/dfs/dfstab"

On   1 31 at 19:48, saved 11 lines of file "/tmp/crontabVwaWPh"

/var/tmp:

No files saved.

 

 

 

(3). vi  Mode 변경

 

- Command Mode (ESC Mode), Edit Mode

- Input/Insert Mode

- Last Line Mode(Ex Mode)

 

 

<Command Mode>  ----- (i, a, o, I, A, O) -----> <Input Mode>

   A   |        <---- (    ESC         ) ------

   |   |

   |   |

   |   +------------- (<Shift+:>, /, ? ) -----> <Last Line Mode>

  +----------------- (    Enter       ) ------

  

* insert, append, open line

 

              [그림] vi 편집기 모드 변환

 

 

 

(4). Command Mode

(4.1) Move

- h, j,  k, l                // 상하좌우 커서이동

- b, w                       // b : back word 이동 , w : word 이동

- 0(^),  $                   // $ : 라인끝 이동  0(^) : 현재행의 처음으로~

- Ctrl+F / Ctrl+B          // 페이지단위 이동

 

- G, 1G, 10G               // nG    : n행으로 이동

- :5, :10                  //  n  : n행으로 이동

 

 

 

(4.2) Delete

- x, dd(=D), 3dd(=3D)      // x : 현재커서의 한글자 삭제

- :1,3d                    // 1 ~ 3 라인 삭제

- dw                       // 한 단어 삭제

- d0, d$          // d0 : 현재커서에서 라인 처음까지 삭제 , d$ : 현재커서에서 라인 끝가지 삭제

- dG                       // dG : 현재커서에서 문서의 마지막까지 삭제

- 3dd                      // 현재에서 3라인 삭제

- d1G                      // 현재에서 1라인까지 삭제

 

(4.3) Copy(Yank) & Paste

- yy(=Y), 3yy(3Y), p or    P                 // yy : 1라인 복사

- :1,3 co 5                                 // 1라인부터 3라인 까지 복사 5라인아래에 paste

- :1,3 m 5                                  // 1~ 3 까지 5라인 밑으로 move

 

 

 

(4.4) Search

- /New,  n or N                     // 탐색 결과에서 n -> 정방향 탐색 N -> 역방향 탐색

- ?New,  n or N                     // /pattern -> 현재에서 정방향탐색

                                   // ?pattern -> 현재에서 역방향 탐색

 

 

 


(4.5) Search & Replace

- :%s/Old/New/g               // %s   : search    ,  /g   : gloval  문서전체의~

                       // old 를 찾아 new로 치환

- :5,10s/Old/New/g     // 5~ 10 라인 ~  "

 

EX) : %s/Hello/HELLO/g

     1,$ => 5,10s/Hello/HELLO/g

     search

     globally => %s/Hello/HELLO/ , %s/Hello/HELLO/g

 

EX) :5,10s/^/#/

    :5,10s/^#//

 

    :5,10s/^/    / (4 blank character)

 

 

 

(4.6) Undo

- u, U            //실행 취소

 

 

 

(4.7) Join Line

- J               // 아래 라인을 현재 라인으로 붙여 준다.

 

 

 

(4.8) Replace

- r, R            // r : 현재커서의 한문자를 치환 , R : 현재커서부터 치환상태로

 

 

 

(4.9) Save & Quit

- :w              // 저장

- :w filename     // filename으로 저장

- :w!             // 강제저장

- :q              // 종료

- :q!             // 강제 종료

- :wq             // 저장 후 종료

- :wq!(root Use)  // 강제 저장 종료

- :!CMD           // vi 편집기 에서 쉘 명령어 실행

 

[참고] Save & Quit

- :x

- :wq

- ZZ

 

 

 


(5). vi  편집기의 환경 설정

 

(5.1). vi 편집기 사용시 환경설정

# vi filename

.....

: set                              // 현재 setting 목록

: set all                          // 설정할수 있는 모든 목록

: set number  (or :set nu)        // 라인넘버 부여

: set nonumber (or :set nonu)      // 번호 없앰

 

[EX] vi 편집기의 기능(:set all)

+- 기능이름---+--- number    --> : set number

|            +--- nonumber -->  : set nonumber

+- 기능이름=               --> : set 기능이름=

 

 

 

(5.2). vi 편집기 환경파일

 

* ex editor  =>  vi editor  => vim editor (iMprove vi)

 ~/.exrc                      ~/.vimrc

 

# vi ~/.exrc

set nu showmode sm ai

 

or

 

# vi ~/.exrc

set number                 // 편집기의 라인번호

set showmode               // 편집기의 모드 표시

set showmatch              // 편집기 작업시 매칭되는 문자들을 표시한다.

set autoindent             // 자동 들여쓰기

 

 

[참고] set list, set ic

set list - Display invisible charaters, such as ^I for a Tab and as $ for end-of-line

set ic   - Instructs searches to ignore case


출처 : http://cafe.daum.net/bscsolaris

2008. 8. 7. 18:50

Chapter 5. Unix Basic Commands _ 아카이브/압축 관련 명령어

압축(Compress)

compress / uncompress CMD

gzip / gunzip CMD

 

아카이브(Archive)

tar CMD

cpio CMD

 

압축 + 아카이브

zip CMD

jar CMD

 


아카이브 vs 압축

아카이브는  묶음을 만드는 것이며 압축과는 다르다.


 


 

compress/uncompress CMD

___________________________

 

compress, uncompress, zcat - compress, uncompress  files  or display expanded files

 

[compress]

     The compress utility will attempt to reduce the size of  the

     named files by using adaptive Lempel-Ziv coding. Except when

     the output is to the standard  output,  each  file  will  be

    replaced  by  one  with  the extension .Z, while keeping the

     same ownership modes, change times and  modification  times.

     If  appending  the  .Z  to  the file pathname would make the

     pathname exceed 1023 bytes, the command  will  fail.  If  no

     files  are  specified, the standard input will be compressed

     to the standard output.

 

[uncompress]

     The uncompress utility will restore files to their  original

     state  after  they  have  been compressed using the compress

     utility. If no files are specified, the standard input  will

     be uncompressed to the standard output.

 

[zcat]

     The  zcat  utility  will  write  to  standard   output  the

    uncompressed  form  of files that have been compressed using

     compress. It is the equivalent of uncompress -c. Input files

     are not affected.

 

 

 

---- file1 -----

aaaaa                                  a(addr1,addr2,addr3,....)

bbbbb              ====Compress===>    b(addr1,addr2,addr3,....)

ccccc                                  .......

----------------

 

                      [그림] 압축의 원리

 

 


(압축에 대한 예1)

- 똑같은 페이지 수를 가지고 있는 두개의 파일을 압축하더라도 압축 효율은 서로 틀리다.

  이유는 반복되는 글자 수가 서로 틀리기 때문이다.

 

(압축에 대한 예2)

- 압축된 파일을 다시 압축하거나 바이너리 파일을 다시 압축하는 경우는 압축효율이 떨어

  질수 있다. 이유는 반복되는 글자가 많지 않고 글자 종류의 수가 증가 하기 때문이다.

 

  Compress File --- Compress ---> size(?)

  Binary File   --- Compress ---> size(?)

 

 

(파일 압축)

# compress file

file.Z

 

(파일 압축 확인)

# zcat file.Z

# uncompress -c file.Z

 

(파일 압축 해제)

# uncompress file.Z

file

 

 

[EX] compress 명령어 실습

# cd /test

# cp /etc/inet/inetd.conf file1

 

# compress file1

file1.Z

# ls -l (File Size)

 

# zcat file1.Z (0)

# cat file1.Z  (X)

 

# uncompress file1.Z

# ls -l (File Size)

 

 

 

 

 


gzip/gunzip CMD

____________________

 

gzip, gunzip, gzcat - compress or expand files

 

[gzip]

     Gzip reduces the size of the named  files  using  Lempel-Ziv

    coding  (LZ77).  Whenever possible, each file is replaced by

     one with the extension .gz, while keeping the same ownership

    modes,  access  and modification times.  (The default exten-

     sion is -gz for VMS, z for MSDOS, OS/2 FAT, Windows  NT  FAT

     and Atari.)  If no files are specified, or if a file name is

    "-", the standard input is compressed to the  standard  out-

     put.   Gzip will only attempt to compress regular files.  In

    particular, it will ignore symbolic links.

 

[gunzip]

     gunzip takes a  list  of  files  on  its  command  line  and

     replaces each file whose name ends with .gz, -gz, .z, -z, _z

     or .Z and which begins with the correct magic number with an

    uncompressed  file  without  the original extension.  gunzip

     also recognizes the special  extensions  .tgz  and  .taz  as

    shorthands   for  .tar.gz  and  .tar.Z  respectively.   When

    compressing, gzip  uses  the  .tgz  extension  if  necessary

     instead of truncating a file with a .tar extension.

 

[gzcat]

     gzcat is identical to gunzip -c. (On some systems, zcat  may

     be  installed  as  gzcat  to  preserve  the original link to

     compress.) gzcat uncompresses either a list of files on  the

    command   line   or  its  standard  input  and  writes  the

    uncompressed data on standard output.  gzcat will uncompress

     files that have the correct magic number whether they have a

     .gz suffix or not.

 

 

(파일 압축)

# gzip file

file.gz

 

(파일 압축 확인)

# gzcat  file.gz

or

# gunzip -c file.gz

 

(파일 압축 해제)

# gzip -d file.gz (-d : decompress)

file

or

# gunzip file.gz

file

 

 


[EX] gzip 명령어 실습

# cp /etc/inet/inetd.conf file2

# gzip file2

file2.gz

# ls -l     (파일의 크기 점검)

 

# gzcat file2.gz (0)

# cat file2.gz  (X)

 

# gzip -d file2.gz

file1

# ls -l     (파일의 크기 점검)

 

 

 

 

 

tar CMD

____________________

 

create tape archives and add or    extract  files

 

(명령어 형식)

# tar cvf file.tar file1 file2 file3   (c: create)

# tar tvf file.tar                     (t: contents)

# tar xvf file.tar                     (x: extract)

 

 

[참고] 테이프 백업 방법(Tape Device Backup)

# tar cvf /dev/rmt/0n /export/home

# tar cvf /dev/rmt/0n file1 file2 file3

 

 

[참고] 디렉토리 마이그레이션(Migration)

Directory Copy using tar CMD.

작업 내용:  /test1 => /test2

 

# cd /test1

# tar cvf - . | (cd /test2 ; tar xvf -)

 

 

[EX] tar 명령어 실습

(실습 준비)

# cd /test

# rm -r *

 

# cp /etc/passwd file1

# cp file1 file2

# cp file1 file3

# ls -l file*

 

(tar 명령어를 사용한 실습)

# tar cvf file.tar file1 file2 file3

# ls -l file*

 

# rm file1 file2 file3

# tar tvf file.tar

 

# tar xvf file.tar

# ls -l file*

 

(tar 명령어를 사용한 디렉토리 마이그레이션)

# mkdir -p /test1

# mkdir -p /test2

 

# cp /etc/default/* /test1

# ls /test1

 

# cd /test1

# tar cvf - . | (cd /test2 ; tar xvf -)

 

# ls /test1

# ls /test2

 

 

 

 

 

cpio CMD

____________________

 

copy file archives in and out

 

     The cpio command  copies  files  into  and  out  of  a  cpio

     archive. The cpio archive may span multiple volumes. The -i,

     -o, and -p options select the action to  be  performed.  The

    following  list describes each of the actions. These actions

     are mutually exclusive.

 

  Copy In Mode

     cpio -i (copy in) extracts files from  the  standard  input,

     which  is  assumed  to  be the product of a previous cpio -o

     command. Only files with names that match one  of  the  pat-

     terns are selected. See sh(1) and OPERANDS for more informa-

     tion about pattern. Extracted files are conditionally copied

     into  the  current  directory  tree,  based  on  the options

     described below. The permissions of the files will be  those

     of the previous cpio -o command. The owner and group will be

     the same as the current user, unless the current user is the

    super-user. If this is the case, owner and group will be the

     same as those resulting from the previous cpio  -o  command.

    Notice  that  if cpio -i tries to create a file that already

     exists and the existing file is  the  same  age  or  younger

    (newer),  cpio will output a warning message and not replace

     the file. The -u  option  can  be  used  to  unconditionally

     overwrite the existing file.

 

  Copy Out Mode

     cpio -o (copy out) reads a list of file path names from  the

    standard  input  and copies those files to the standard out-

     put, together with path name and status information  in  the

     form  of  a  cpio  archive. Output is padded to an 8192-byte

     boundary by default or  to  the  user-specified  block  size

     (with  the  -B  or  -C  options) or to some device-dependent

     block size where necessary (as with the CTC tape).

 

  Pass Mode

     cpio -p (pass) reads a list of  file  path  names  from  the

     standard input and conditionally copies those files into the

    destination directory tree, based on the  options  described

     below.

 

 

     -i    (copy in) Reads an archive from the standard input and

          conditionally  extracts  the files contained in it and

          places them into the current directory tree.

 

     -o    (copy out) Reads a list of file path  names  from  the

          standard  input and copies those files to the standard

          output in the form of a cpio archive.

 

     -p    (pass) Reads a list of file path names from the  stan-

          dard  input  and conditionally copies those files into

           the destination directory tree.

 

     -c    Reads or writes header information in ASCII  character

           form for portability. There are no UID or GID restric-

          tions associated with this  header  format.  Use  this

          option  between  SVR4-based  machines,  or  the -H odc

          option between unknown machines. The -c option implies

          the  use  of  expanded  device numbers, which are only

          supported on  SVR4-based  systems.  When  transferring

          files  between  SunOS  4  or  Interactive UNIX and the

          Solaris 2.6 Operating environment or  compatible  ver-

           sions, use -H odc.

 

     -v    Verbose. Prints a list of file and extended  attribute

          names. When used with the -t option, the table of con-

          tents looks like the output of an ls -l  command  (see

          ls(1)).

 

     -b    Reverses the order of the bytes within each word.  Use

           only with the -i option.

 

     -B    Blocks input/output 5120  bytes  to  the  record.  The

          default buffer size is 8192 bytes when this and the -C

          options are not used. -B does  not  apply  to  the  -p

 

     -d    Creates directories as needed.

 

     -m    Retains previous file modification time.  This  option

           is ineffective on directories that are being copied.

 

     -I file

          Reads the  contents  of  file  as  an  input  archive,

          instead  of the standard input. If file is a character

          special device, and the current medium has  been  com-

          pletely read, replace the medium and press <RETURN> to

           continue to the next medium. This option is used  only

           with the -i option.

 

     -O file

          Directs the output of cpio to  file,  instead  of  the

          standard output. If file is a character special device

           and the current medium is full, replace the medium and

           type a carriage return to continue to the next medium.

           Use only with the -o option.

 

cpio는 표준 입력으로부터 파일의 이름을 입력받고, 표준출력으로 목록명을 얻어서

하나 또는 복수개의 파일을 압축하는데 사용된다. cpio 3개의 다름 모드가 존재

한다.

 

Copy In   Mode : cpio -i, 표준 입력으로 들어온 파일들을 extract 한다.

Copy Out  Mode : cpio -o, 표준 입력으로 부터 파일을 얻어서 이들 파일을 가지고

                    그들의 pathname과 함께, 새로운 파일을 생성한다.

Pass Mode      : cpio -in, copy-out 모드와 같다. 다만 새로운 파일이 생기는 것이

                    아니라 디렉토리 구조를 그대로 copy 한다는 것만 다르다.

 

(명령어 형식 예)

# find . -print | cpio -o[aBcv] > file.list

# cpio -ivt < file.list

# cpio -i[cdlmv] < file.list

# find . -print | cpio -p[adlmuv] directory

 

[EX1] 현재 디렉토리를 tape Backup 

# find . -print | cpio -ocvB > /dev/rmt/0

 

[EX2] Tape의 목차를 출력

# cpio -iBtv < /dev/rmt/0

 

[EX3] Backup 받은 tape로부터 restore

# cpio -iBvd < /dev/rmt/0

 

[EX4] 특정 파일을 find 명령어로 출력하여 archive file restore

# find . -name 'file*' -print | cpio -ocvB > file.list

 

[EX5] 디렉토리 /export/home/user01 디렉토리를 /export/home/user02 backup

# cd /export/home/user01

# find . -print | cpio -pdmv /export/home/user02

 

[EX6] 현재 디렉토리 파일들을 새로운 파일(newfile)로 아키이빙

# ls | cpio -ocv > /test/newfile

 

[EX7] 디렉토리 안에서 파일 풀기

# cd /test

# cat newfile | cpio -icd "memo/a1" "memo/b*"



zip CMD

____________________

 

zip, zipcloak, zipnote, zipsplit - package  and  compress (archive) files

 

     zip is a compression and file packaging  utility  for  Unix,

     VMS,  MSDOS,  OS/2,  Windows NT, Minix, Atari and Macintosh,

     Amiga and Acorn RISC OS.

 

     It is analogous to a combination of the UNIX commands tar(1)

     and  compress(1)  and  is compatible with PKZIP (Phil Katz's

     ZIP for MSDOS systems).

 

# man zip

.....

     -r   Travel the directory structure recursively;  for  exam-

          ple:

 

              zip -r foo foo

 

          In this case, all the files and directories in foo  are

          saved  in  a zip archive named foo.zip, including files

          with names starting with ".", since the recursion  does

          not  use  the shell's file-name substitution mechanism.

          If you wish to include only a specific  subset  of  the

          files  in directory foo and its subdirectories, use the

          -i option  to  specify  the  pattern  of  files  to  be

          included.   You  should  not use -r with the name ".*",

          since that matches ".."  which will attempt to  zip  up

          the parent directory (probably not what was intended).

.....

 

# man unzip

.....

     -c   extract files to stdout/screen (``CRT'').  This  option

          is  similar  to  the  -p option except that the name of

          each file is printed as it is extracted, the -a  option

          is  allowed,  and  ASCII-EBCDIC conversion is automati-

          cally performed if appropriate.   This  option  is  not

          listed in the unzip usage screen.

.....

 

(파일 압축)

# zip file.zip file1 file2 file3

 

(파일 압축 확인)

# unzip -c file.zip

 

(파일 압축 해제)

# unzip  file.zip

 

[참고] 명령어 호환

Unix zip 명령어<-> Unix jar 명령어

Unix zip 명령어<-> Window zip 명령어




jar CMD

____________________

 

archive  tool for Java archives

 

# jar cvf file.jar file1 file2 file3

# jar tvf file.jar

# jar xvf file.jar

 

 

 

 

 

dd CMD

---------------------

 

convert and copy a file

 

     The dd utility copies the specified input file to the speci-

     fied  output  with  possible conversions. The standard input

     and output are used by default. The input and  output  block

     sizes  may  be  specified  to take advantage of raw physical

     I/O. Sizes are specified in bytes; a number may end with  k,

     b,  or  w  to  specify  multiplication  by  1024, 512, or 2,

    respectively. Numbers may also be separated by x to indicate

     multiplication.

 

     The dd utility reads the input one block at  a  time,  using

     the  specified input block size. dd then processes the block

     of data actually returned, which could be smaller  than  the

    requested  block  size. dd applies any conversions that have

     been specified and writes the resulting data to  the  output

     in blocks of the specified output block size.

 

 

# man dd

.....

     if=file

          Specifies  the  input  path.  Standard  input  is  the

           default.

 

     of=file

          Specifies the output  path.  Standard  output  is  the

          default.  If  the  seek=expr  conversion  is  not also

          specified, the output file will  be  truncated  before

          the  copy begins, unless conv=notrunc is specified. If

          seek=expr is specified, but conv=notrunc is  not,  the

          effect  of  the copy will be to preserve the blocks in

           the output file over which dd seeks, but no other por-

           tion  of  the  output  file will be preserved. (If the

           size of the seek plus the size of the  input  file  is

          less  than  the  previous size of the output file, the

          output file is shortened by the copy.)

 

     bs=n  Sets both input and output block  sizes  to  n  bytes,

          superseding ibs= and obs=. If no conversion other than

          sync, noerror, and notrunc is  specified,  each  input

          block  is  copied  to  the  output  as  a single block

           without aggregating short blocks.

 

     skip=n

          Skips n input blocks (using the specified input  block

          size)  before starting to copy. On seekable files, the

          implementation reads the blocks or seeks past them. On

           non-seekable  files,  the blocks are read and the data

           is discarded.

 

     seek=n

          Skips n blocks (using the specified output block size)

          from  beginning of output file before copying. On non-

          seekable files, existing blocks  are  read  and  space

          from  the current end-of-file to the specified offset,

           if any, is filled with null bytes. On seekable  files,

          the  implementation  seeks  to the specified offset or

          reads the blocks as described for non-seekable files.

 

     count=n

          Copies only n input blocks.

.....     

 

(명령어 형식)

# dd if=filename of=filename bs=n seek=n skip=n count=n

(if : Input File, of : Output File, bs : Block Size)

 

 

[EX1] 큰 파일 생성(Big File creation)

# dd if=/dev/zero of=/swap/swapfile bs=1024 count=102400

 

[EX2] VTOC/Super Block 삭제

# dd if=/dev/zero of=/dev/rdsk/c0t0d0s4 bs=512 count=1

# dd if=/dev/zero of=/dev/rdsk/c0t0d0s4 bs=512 count=32

# dd if=/dev/zero of=/dev/rdsk/c0t0d0s1 bs=512 skeep=11 count=1

 

[EX3] 디스크 마이그레이션(Disk Migration)

# dd if=/dev/dsk/c0t0d0s2 of=/dev/dsk/c0t1d0s2

# dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t1d0s2 bs=4096

# dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t1d0s2 bs=128k

 

[EX4] 테잎 장치에 백업

# dd if=/dev/rdsk/c0t0d0s7 of=/dev/rmt/0

# dd if=/dev/rmt/0 of=/dev/rmt/1

 

[참고문서] /root/docs_html/Reference/DiskMigration.txt


출처 : http://cafe.daum.net/bscsolaris

2008. 8. 7. 17:47

Chapter 5. Unix Basic Commands _ 링크 관련 명령어

ln CMD

__________

 

make hard or symbolic links to files

 

     The ln utility may be used to create  both  hard  links  and

    symbolic  links.  A  hard link is a pointer to a file and is

    indistinguishable from the  original  directory  entry.  Any

     changes to a file are effective independent of the name used

     to reference the file. Hard links may not span file  systems

     and may not refer to directories.

 

■ 하드 링크(Hard Link)

■ 심볼릭 링크(Symbolic Link, Soft Link)

 

 

(1) 하드 링크(Hard Link)

# ln file1 file2

- file1, file2의 용량은    같은가?

- file1, file2 inode number    같은가?

- file1을 편집하면 file2의 내용은 어떤가?

- "ls -li file*"하면 특이한 변화는 있는가?

- When Original   File Delete!!

- filesystem을 넘어서 링크를 걸수 있는가?

 

 

(2) 십볼릭 링크(Symbolic Link)

# ln -s  file1 file2

- file1, file2의 용량은    같은가?

- file1, file2 inode number    같은가?

- file1을 편집하면 file2의 내용은 어떤가?

- "ls -li file*"하면 특이한 변화는 있는가?

- When Original   File Delete!!

- filesystem을 넘어서 링크를 걸수 있는가?

 

 

(기본 설정 점검)

- 파일에 관련한 하드 링크는 1이다.

- 디렉토리 관련한 하드 링크는 2이다.

 

(실습 준비)

# mkdir /test

# cd /test

# rm -r *

 

(기본 설정 점검 실습)

# touch file1

# ls -l file1

-rw-r--r--   1 root     other          0  2  5 15:42 file1

Hard Link Count : 1

 

# mkdir dir1

# ls -l

drwxr-xr-x   2 root     other        512  1  8 20:47 dir1

Hard Link Count : 2

 

 

[EX] 하드 링크 실습

# echo 111 > file1

# cat file1

 

# ln file1 file2

# ls -l        (파일의 크기 점검, 링크 카운트)

# ls -li      (Inode 번호 점검)

# echo 2222 >> file2

# cat file2

 

# cat file1    (파일의 내용 확인)

 

# rm file1    (원본 파일(Original File)을 지우면!!)

# cat file2

 

 

[EX] 심볼릭 링크 실습

# ln -s file2 file3

# ls -l        (파일의 크기 점검, 링크 카운트 점검)

# ls -li      (Inode 번호 점검)

# echo 3333 >> file3

# cat file2    (파일의 내용 점검)

 

# rm file2    (원본 파일(Original File)을 지우면!!)

# cat file3

 

 

[참고] 일반 파일의 하드 링크 확인 방법(링크 카운트 값을 확인한다.)

file1 file2가 하드링크가 되어 있는지 확인 하는 방법

- ls 명령어의 -i 옵션을 사용하여 Inode 번호를 확인 한다.

         # ls -li file*

- find 명령어의 -inum 옵션을 사용한다.

         # find . -inum 450 -type f



심볼릭 vs 하드 링크

다른 파티션or 슬라이스를 넘어서 링크를 걸 수 있다.

하드링크에서는 모든게 원본 파일이 된다.



출처 : http://cafe.daum.net/bscsolaris

2008. 7. 19. 22:21

Chapter 4. Solaris 9 Installation

Chapter 4.  Solaris 9 Installation
___________________________________

솔라리스 10버전에 대한 설치는 다음을 참고 하십시요

■ Solaris 10  설치 가이드
- 817-0544.pdf(Solaris10 Installation Guide Basic Installation)
- 817-5506.pdf(Solaris 10 Installation Guide Custom JumpStart and Advanced
              Installation)


■ 솔라리스 8/9/10 버전 이미지를 다운로드는 다음사이트에서 받으시기 바랍니다.
Solaris 8/9/10 설치 이미지 제공
- http://www.vmware.com (VMWare Image)


1. 솔라리스 9 설치시 필요한 CD/DVD

Requirement CD for Solaris 9 Installation
 - 설치 CD(Installation CD)
 - 1번 CD (1 of 2 CD)
 - 2번 CD (2 of 2 CD)
 - 언어 CD(Language CD)
 or
 - DVD

[참고] 솔라리스 9 설치시 H/W 최소 사양
Hardware Requirements for Installation of the Solaris 9 OE(Operating Environment)
- A system based on an UltraSPARC/x86 processor
- 64 Mbytes of memory
- 2.3 Gbytes of disk space
- A keyboard and monitor
- CD-ROM / DVD-ROM or Installation Server

2. 솔라리스 설치 방법 종류

솔라리스 9 설치 유형(Solaris 9 Installation Type)
- Webstart Installation(Installation CD + 1 of 2 CD + 2 of 2 CD + Language CD)
- Interractive Installation(1 of 2 CD + 2 of 2 CD + Language CD)
- Custom Jumpstart Installation(Network Installation)

[참고] http://docs.sun.com Documentation
The Solaris 9 OE Installation and Upgrade Options
- Solaris suninstall Program
- Solaris Web Start Installation Software
- Custom JumpStart Procedure
- Solaris Web Start Flash Installation
- Standard Upgrade
- Solaris Live Upgrade Method



3. 솔라리스 설치 과정

솔라리스 9 설치과정을 다음과 같이 4가지 서비스로 구분한다.

솔라리스 9 설치 과정 구분(Solaris 9 Installation Process)

■ Boot Service
■ System Indentification Service   // host , ip , netmask . 등등
■ System Configuration Service    // filesystem layout , package 선택
■ Installation Servie

(1). Booting for Solaris Installation

(a). CD-ROM 부팅을 통해 설치하는 방법

- <STOP + A>
- ok boot cdrom               // 일조의 cmos mode와 같다.

or

- # init 0
- ok boot cdrom


(b). 네트워크 부팅을 통해 설치하는 방법

<STOP + A>
ok boot net - install


(2). Solaris 9 OE Installation Process        //   sparc 기준         

1. Select a Language : 5.Korean
2. Select a Locale   : 0.Korean EUC
3. 설치 안내      : F2_계속
4. 시스템 식별      : F2_계속
5. 네트워크 [X] 예   : F2_계속
6. DHCP 사용      : 아니오
7. 호스트 이름      : solarisXXX   (범위:200 ~ 214, 예: solais200)

--------------------------------------------------------
                solarisXXX(172.16.8.XXX)
--------------------------------------------------------
200 201 202 203 204 205
206 207 208 209 210 211
212 213 214 215 216 217
218 219 220 221 222 223
224 225 226 227 228 229
--------------------------------------------------------

8. IP       : 172.16.8.XXX (예: 172.16.8.205)
9. 서브넷      : 255.255.0.0
10. IPv6 사용      : 아니오
11. 기본경로      : 지정
12. 라우터 IP      : 172.16.0.1
13. 커버로스      : 아니오
14. 이름서비스      : none
15. 대륙 및 대양     : 아시아
16. 국가 및 지역     : 대한민국
17. 날짜 및 시간     : 시간확인(ROK)
18. F4_초기
19. F2_표준
20. 지역선택      : F2_계속
21. [X]64비트 지원   : F2_계속        // x86 플랫폼에는 없음
22. 소프트웨어 선택  : Entire Distribution plus OEM Support 64-bit
23. 디스크선택 [X]c0t0d0 : F2_계속
24. 데이터 보존      : F2_계속
25. 레이아웃      : F2_자동배열  (이 부분은 필요한 경우만)
26. 자동레이아웃     : [X]/ [X]swap : F2 (이 부분은 필요한 경우만)
27. 디스크레이아웃   : F4_사용자정의     (수동레이아웃을 선택한경우만)
28.
+------------------------------------------------------------+
|8G 기준)               Sparc / Intel(VMWare)                               |
+------------------------------------------------------------+
|Slice  Mount Pointer   Size                                                    |
+------------------------------------------------------------+
| 0 /  5000                                                                             |
| 1 swap  512                                                                        |
| 2 overlap  (Entire)                                                                |
| 3 /data1  500                                                                       |
| 4 /data2  500                                                                       |
| 5 /data3  500                                                                       |
| 6 /data4  500                                                                       |
| 7 /export/home (Free)                                                          |
+------------------------------------------------------------+

[참고] 실무에서 많이 사용되고 있는 파티션들 예제
/, /usr, /var, /tmp, /export/home(/user), /database, /oracle, /was

위와 같이 입력후 "F2_계속"
29. 원격파일시스템    : F2_계속
30. 프로파일          : F2_계속
31. [X]자동재부트         : F2_설치시작
32. root password 입력    : knit
33. 자동절전기능 사용여부 : n
34. 다음에 다시 질문여부  : n                     // x86 에는 없다.

35. 2번 CD 설치
36. 3번 CD(language) 설치


[참고] 인텔 플랫폼 설치 방식에 대해서는 http://cafe.daum.net/bscsolaris 참고
- Solaris  9 Installation on VMWare
- Solaris 10 Installation on VMWare


[참고] 자동절전기능

Sparc Platform Sun Solaris 설치시 자동절전기능을 설정한 경우(yes로 설정한 경우)
이 기능을 해제 시키 위해서는 다음과 같은 방법이 가능하다.

(1). Power Saving Function OFF

첫번째 방법)
/noautoshutdown 파일 생성하는 방법
  # touch  /noautoshutdown
두번째 방법)
/etc/power.conf 파일을 편집하는 방법
  # vi /etc/power.conf 편집
세번째 방법)
CDE 환경에서 "Desktop Control" 아이콘을 사용하는 방법
  - CDE환경에서
  - 패널에 있는 "Desktop Control" 아이콘을 클릭하고
  - 전원관리(Power Management) 아이콘을 클릭한다.(Yellow Icon)
  - 자동 절전 기능을 OFF 한다.

4. 파티션 정책과 파티션 용량

다음 예는 실무에 바로 적용할수 있는 예는 아니다. 하지만 파티션 정책과 파티션 용량
을 결정할때 한가지 참고 사항으로만 사용할수는 있다.

시스템 자원 사항
- Total Disk : 8G
- Total Mem  : 256MB


(1). 파티션 정책 (Partition Policy) 수립시 고려사항
- 소스(추가패키지)가 있는 위치를 나누어야 하는가?  예: /var/apache/htdocs
- 추가적인 패키지 설치 위치를 나누어야 하는가?  예: /oracle
- 데이터가 있는 위치를 나누어야 하는가?   예: /data1, /data2
- 로그 기록을 남기는 위치를 나누어야 하는가?  예: /data1/logs
- 기본적인 프로그램이 위치한곳을 나눌것인가?  예: /usr, /opt, /usr/local
- 운영체제의 /tmp, /var, /export/home을 나눌것인가? 예: /tmp, /var, /export/home
- 스토리지는 붙일것인가?
- NAS의 일부 파일시스템을 사용할것인가?
- RAID 구성을 할것인가?

일반적인 파티션 방법과 용량
/ 200 - 500M                  //      /  와 swap는 기본!!
swap    Mem * 2
 
          // 실 메모리용량의 두배
/usr    3G - 4G             // 대두분의 prog 가 설치됨
/var    200 - 500M
/tmp    200 - 300M

서버의 목적에 맞는 파티션 정책   // optional
/oracle
/data1
/data2
/was
/log


(2). 파티션 정책과 용량 예제

다음은 파티션 정책에 대한 하나의 예이다. 실무에 바로 적용할 수 있는 예는 아니다. 각
각의 서버의 목적에 맞는 사용자 정의가 필요하다.

[Web Server]
________________________________________________

0 /  1000
1 swap  512
2 overlap  8692 (전체용량)
3 /usr  2000
4 /tmp  500
5
6 /WAS  2000
7 /www  *
________________________________________________


[Anonymous FTP Server]
________________________________________________

0 /  1000
1 swap  512
2 overlap  8692 (전체용량)
3 /usr  2000
4 /tmp  500
5
6
7 /export/ftp *
________________________________________________


[Mail Server]
________________________________________________

0 /  1000
1 swap  512
2 overlap  8692 (전체용량)
3 /usr  2000
4 /tmp  500
5
6
7 /var  *
________________________________________________



5. 수업전에 알아 두어야 하는 사항들 또는 환경 설정 사항


(1). 유닉스의 디렉토리  구조

                     /
                     |
       +-------+------+-----+------+---------+-----------+--------+------
       |       |      |     |      |         |           |        |  ....
      etc     usr    tmp   var   home     export       work    work2
                                             |
                                            home
                                             |
                                         +---+---+
                                         |       |
                                       user01  user02

                               [그림] 유닉스 디렉토리 구조


(2). 기본 디렉토리의 역할

/  - 모든 파일시스템의 네임스페이스(Name space)이다.
                  모든 파일시스템의 마운트 포인터가 존재한다.
/usr  - 프로그램이 설치되는 디렉토리이다.(Bundle Packages, 정식적인~)
/opt  - 프로그램이 설치되는 디렉토리이다.(Unbundle Packages,  부가적인~) 
/etc  - 시스템 설정 파일이나 관리상에 필요한 파일이 존재하는 디렉토리이다.
    (사용자/그룹관리정보, 패스워드, 서비스 설정 파일, 시작스크립트등    일종의 제어판!!)
/dev  - 디바이스 디렉토리이다.
/export/home - 사용자의 홈디렉토리이다.

(3). 시스템 관리자의 역할

- 사용자 관리(User Administration)
- 프로그램 관리(Software Administration)
- 패치 관리(Patch Managing)
- 백업과 복구(Backup & Recovery)
- 하드웨어 관리(H/W Administration)
- 성능과 장애처리(Performance & System Fault Administration)
- 시스템 보안 관리(System Security)
- 관리자 지식 업데이트(Education)

(4). 솔라리스 GUI 환경 종류

- CDE(Common Desktop Environment)
- Openwindow
- GNOME(Including solaris9)
- Java Desktop Environment(Including solaris10)

[참고] CDE?
CDE는 Open Group에서 제정된 개방형시스템의 GUI 표준이다. Motif에 기반을 두고, HP,
IBM, 그리고 다른 회사들에서 나온 요소들을 가미하였으며, 원래는 COSE에 의해 관리되
었다. 대부분의 주요 유닉스 공급자들이 CDE를 지원한다. CDE는 또한 원격 프로그램 실
행과 자신의 작업공간에 있는 응용프로그램을 일시적으로 중지하거나 재개하는 등의 능
력을 제공한다. CDE라는 상표는 X/Open, 즉 Open Group에 의해 관리되어진다.

[참고] GNOME?
GNOME[그놈]은 유닉스 기반의 운영체계 사용자들을 위한 그래픽 사용자 인터페이스와 일
련의 컴퓨터 데스크탑 애플리케이션들이다. GNOME은 유닉스 기반의 운영체계를 프로그래
머가 아닌 사람들도 쉽게 사용할 수 있고, 일반적으로 윈도우 데스크탑 인터페이스와 그
것의 대부분의 보편적인 애플리케이션 들에 상응하도록 만드는데 목적이 있다. 실제로,
GNOME은 사용자들이 여러 개의 데스크탑 외관 중 하나를 선택할 수 있게 해주는데, 예를
들면 사용자 인터페이스를 윈도우나 맥OS처럼 보이도록 만들 수 있다. 게다가, GNOME은
워드프로세서, 스프레드시트, 데이터베이스 관리자, 프레젠테이션 개발도구, 웹브라우저
및 전자우편 프로그램 등, 윈도우의 오피스97 제품에 있는 것들과 같은 형태의 애플리케
이션들을 포함한다.

GNOME은 리처드 스톨먼에 의해 설립된 조직인 FSF의 후원 아래, 자원자들의 장시간에 걸
친 노력의 산물이다. 스톨먼과 FSF의 동료 회원들은 소프트웨어의 소스코드가 다른 사람
들에 의해 계속적으로 개선될 수 있도록 항상 공개되어야 한다고 여기고 있다. GNOME은
데스크탑 운영체계 시장이 어떤 한 회사에 의해 통제되지 않도록, 리눅스와 다른 유닉스
시스템들을 윈도우에 대한 존립 가능한 대안으로 만들기 위한 노력의 일부이다. GNU는
FSF의 운영체계와 일련의 응용프로그램들이다 (리눅스는, 리누스 토발즈가 GNU로부터 나
온 부가적인 운영체계 요소에 커널을 추가함으로써 개발된 운영체계이다).

GNOME은 GNOME 프로그램들과 다른 운영체계 플랫폼 프로그램들이 상호운용성을 가질 수
있도록 CORBA를 지원하는 ORB와 함께 나온다. GNOME은 또한 프로그래머들이 GNOME 사용
자 인터페이스를 사용하는 응용프로그램들을 개발하는데 사용할 수 있도록 위짓 라이브
러리를 포함한다. GNOME은 데스크탑 버전 외에도, 포켓용 PalmPilot 등을 위한 사용자
인터페이스와 일련의 응용프로그램도 나온다.


(5). 윈도우 클라이언트에서 유닉스 서버로 터미널 접속

[ Window XP ] -----> [ Solairs Server ]

시작 > 실행 > cmd > telnet 172.16.8.254 > 사용자ID/패스워드


(6) 참고 웹사이트(URL)

(6.1) 솔라리스에 관련한 썬 사이트 모음

Sun Site

- http://www.sun.com         (Main Site)
- http://www.sunfreeware.com (GNU Package Site)
- http://sunsolve.sun.com    (Patch Site)
- http://docs.sun.com        (Sun Manual Site)


(6.2) 솔라리스에 관련한 한국사이트 모음

Solaris Reference Site
- http://cafe.daum.net/bscsolaris
- http://cafe.daum.net/solagoing
- http://solaris.superuser.co.kr
- http://www.solarisschool.co.kr
- http://www.howtosolaris.com
- http://www.unix.co.kr
- http://stone.backrush.com
- http://cafe.naver.com/solatech
- http://cafe.naver.com/backupkorea
- http://www.unixsun.co.kr/
- http://cafe.naver.com/sunschool.cafe
- http://cafe.daum.net/osschool
- http://ndocs.com/
- http://ksun.co.kr


(7) 수업 전 환경 설정 사항

수업전에 환경에 관련한 사항들을 자동으로 설정해 주는 ENV_main.sh 스크립트를 실행 한다.


솔라리스 환경 설정(Solaris Environment Setting)

■ 콘쉘로 변경 (/sbin/sh -> /bin/ksh)
■ ENV_main.sh 스크립트 실행
   ENV_main.sh 스크립트는 다음과 같은 역할을 갖는다.
 ● ~/.profile 파일생성 및 설정
 ● ~/.kshrc 파일생성 및 설정
 ● ~/.exrc 파일생성 및 설정
 ● ~/.rhosts 파일생성 및 설정
 ● /etc/default/login 설정 변경
 ● /etc/ftpd/ftpusers 설정 변경
 ● /etc/sshd/sshd_config 파일 설정 변경

(a). ENV_main.sh 스크립트 실행
# dfshares 172.16.8.254
# mkdir /mnt/server
# mount 172.16.8.254:/root/shell /mnt/server
# cd /mnt/server
# ls
# ./ENV_main.sh

(b). root 사용자의 쉘을 ksh로 변경
# passwd -e       // 쉘 변경
Old shell: /sbin/sh
New shell: /bin/ksh    <----- "/bin/ksh" 입력

(c). 로그아웃/로그인
CDE 환경 패널(Pannel) > EXIT 아이콘 클릭 -> 로그아웃 -> 로그인

[참고] 현재 적용

# ksh
# .  /.profile
# .  /.kshrc
[/]#                   <----- 쉘 프롬프트 변경 확인


[참고] Intel Platform on VMWare
(a). http://www.daum.net/bscsolaris 에서 ENV.zip 파일 다운로드(MS Windows)
(b). 알FTP 프로그램을 사용하여 솔라리스 서버에 파일을 업로드 한다.
(c). ENV.zip 압축 해제 후 실행
 # unzip ENV.zip
 # chmod 755 ENV_main.sh
 # ./ENV_main.sh


(8). 제어 문자

썬 솔라리스에서 다음과 같은 제어문자(Control Charaters)들을 사용할수 있다.

Control Charaters

----------------------------------------------------------------------------------------
Ctrl + C Terminates the command currently running.
Ctrl + D Indicates end-of-file or exit.
Ctrl + U Erases all characters on the current command line.
Ctrl + W Erase the last word on the command line.
Ctrl + S Stops output to the screen
Ctrl + Q Restarts output to the screen after you have pressed Control-S

----------------------------------------------------------------------------------------

TIP .
ctrl + space    // 한영 전환

[실습1] <Ctrl + C>
# man ls
<Ctrl + C>

# find / -name core -type f
<Ctrl + C>

[실습2] <Ctrl + D>
1. 파일의 끝의 의미를 갖는다.
# mkdir /test
# cd /test

# cat > file1
Hello, Solaris
<Ctrl + D>
# cat file1

2. 현재 쉘을 종료하는 의미를 갖는다.
# telnet 172.16.8.254
Trying 172.16.8.254...
Connected to 172.16.8.254.
Escape character is '^]'.

SunOS 5.9

login: root             <----- ID  : root
Password:               <----- PASS:
Last login: Tue Mar 11 11:04:50 from solaris215
Sun Microsystems Inc.   SunOS 5.9       Generic January 2003

# hostname
# <Ctrl + D>


[실습3] <Ctrl + U>
명령어 라인 전체를 지워 주는 역할을 갖는다.
# find / -name core -type f <Ctrl + U>


[실습4] <Ctrl + W>
명령어 라인상에 마지막 단어를 지워주는 역할을 갖는다.
# find / -name core -type f <Ctrl + W> <Ctrl + W> <Ctrl + W>


[실습5] <Ctrl + S>, <Ctrl + Q>    // ctrl + s : 화면 출력 정지 , ctrl + q  : 화면정지 복귀
# du /
<Ctrl + S>
<Ctrl + Q>
<Ctrl + S>
<Ctrl + C>


(9). 수업에 사용되는 사용자

수업을 위한 사용자 추가

# admintool &
-------------------------------------
User Name   : user01
Login Shell : /bin/ksh
Password    : Normal Password
Home Dir.   : /export/home/user01
-------------------------------------


(10). CDE 환경 사용에 대한 설명

(a) 터미널 사용시 설명
- 한개의 터미널을 띄운다.
- 터미널의 (ㄱ)왼쪽 상단 "Exit" 아이콘,
           (ㄴ)오른쪽 상단 "Minimize/Maximize" 아이콘,
           (ㄷ)오른쪽 상단 "Icon Coversion" 아이콘

(b) CDE 환경에서 사용되는 아이콘 설명

CDE 환경의 패널 부분에 존재하는 아이콘
- Netscape Icon
- Calendar Icon
- Homedirectory Icon
- Text Node Icon
- MailBox Icon
- Screen Lock Icon
- Workspace Icon
- Exit Icon
- Printer Icon
- Application Icon(Desktop Control Icon)
- CPU_DISK Icon
- Help Icon
- Trash Icon


(11). 사용자의 쉘프롬프트

root 사용자 : #
일반 사용자 : $


출처 : http://cafe.daum.net/bscsolaris

2008. 7. 19. 21:30

Chapter 3. Solaris Introducing

Chapter 3.  Solaris Introducing
_________________________________

솔라리스 환경은 SunOS(5.x)와 ONC+(Open Network Computing) 제품, CDE GUI
(Graphical User Interface)로 구성이 된다. SunOS는 시스템 자원(System Resources)과 시
스템 동작을 위한 스케줄 프로그램등으로 구성이 된다. ONC+ 프로그램은 네트워크 서비스
즉 NIS(Network Information Services), NIS+(Network Information Service Plus),
NFS(Network Filesystem)와 같이 네트워크 상에서 자원을 공유하고 정보를 전달하는 서비
스 제품으로 구성된다. CDE 환경은 GUI 방식으로 되어 있으며 로그인 스크린이나 운영체제
의 거의 모든 기능을 접근하는데 사용한다.

솔라리스 이전 버전
- Solaris 1.x  &  Solaris 2.x
- SunOS 4.x    &  SunOS 5.x


(1). Solaris 9 버전이란?

■ 솔라리스 버전간의 상관관계
Solaris 2.6  =  SunOS 5.6  
Solaris 2.7  =  SunOS 5.7   = Solaris 7
Solaris 2.8  =  SunOS 5.8   = Solaris 8
Solaris 2.9  =  SunOS 5.9   = Solaris 9
Solaris 2.10 =  SunOS 5.10  = Solaris 10


(2). 솔라리스 플랫폼(Platform)

■ Sparc Platform
■ Intel Platform(x86 용)


(3). 대표적인 UNIX

■ Sun     Solaris
■ HP      HP-UX
■ IBM     AIX
■ Compaq  Tru64 (Include HP)
■ SGI     IRIX

[참고] 인텔 호환 PC에서 동작하는 유닉스
Solaris(X86), OpenServer, Unixware, NextStep, Minix
FreeBSD, NetBSD, OpenBSD
Linux(RedHat RHEL, SuSE Linux, Tubo Linux, Debian Linux 등)


(4). UNIX 시스템의 사용

KT      : 80 %
HanJun  : 50 %
KTF     : 33 %
COSCO   : 80 %
철도청  : 제어용 시스템
반도체  : 반도체 기기 테스트용 장비
CAD 서버: 디자인 프로그램 애뮬레이션 용도


(5). 최근 유닉스 시장

■ Unix 서버 시장(한국기준, 매출액 기준, 2007년 8월기준)
 (a). IBM
 (b). HP
 (c). SUN
■ X64 서버 시장(한국기준, 매출액 기준, 2007년 8월 기준)
 (a). HP
 (b). IBM
 (c). 삼성전자
 (d). DELL
 (e). SUN


(6). 솔라리스 9의 새로운 기능

솔라리스의 새로운 기능에 대해서는 다음 사이트를 참고하였다.
 - http://docs.sun.com/app/docs/doc/816-3925/6ma624fq7?a=view


(6.1). 솔라리스 9 버전 릴리즈
- 2002년 09월(http://docs.sun.com/app/docs/coll/768.6)
- 2002년 12월(http://docs.sun.com/app/docs/coll/768.7)
- 2003년 04월(http://docs.sun.com/app/docs/coll/768.8)
- 2003년 08월(http://docs.sun.com/app/docs/coll/768.9)
- 2003년 12월(http://docs.sun.com/app/docs/coll/768.10)
- 2004년 04월(http://docs.sun.com/app/docs/coll/768.11)
- 2004년 09월(http://docs.sun.com/app/docs/coll/768.12)
- 2005년 09월


(6.2). 중요 기능 추가 / 업데이트

■ Solaris 9 Resource Manager을 통한 시스템 자원 자원 개선
■  Linux와의 호환성 개선함(리눅스의 프로그램을 아무런 변경없이 실행 가능하게 됨)
■  개선된 보안성
 - Internet Key Exchange(많은 보안 네트워크 관리 가능)
 - Solaris Secure Shell(SSH) 내장
 - 안전한 LDAP 클라이언트(SSL/TLS 및 CRAM-MD5 암호화 기법 제공)
 - 강력한 암호화(최대 128비트 강력한 암호화 가능)
■  iPlanet Directory Server 5.1 내장
■  Solaris Volume Manager(RAID 구성 강화)
■  파일 시스템 개선(파일 시스템 입출력 기능 향상)
■  Solaris Live Upgrade 2.0 포함
■  Web Start Flash(플래쉬 설치 방식 제공)
■  최소 설치(필요한 패키지만 설치 가능)
■  Multiple Page Size Support
■  향상된 다중 스레드 라이브러리
■  Solaris 운영 환경을 위한 NetscapeTM 6.2.1 포함
■  Solaris 운영 환경을 위한 GNOME 2.0 Desktop 포함


[참고] SUN/IBM/HP 서버의 종류와 Linux 지원가능 시스템
/root/docs/Reference/UnixServerType.txt

출처 : http://cafe.daum.net/bscsolaris

2008. 7. 19. 18:18

Chapter 2. OS Overview

Chapter 2.  OS Overview
_________________________


1. 운영체제(OS)란?
 
운영체제(OS)는 사용자 H/W 에 대한 사용자 인터페이스 역할을 가진다. 운영체제의 핵심
(core)은 kernel이고 실제적인 H/W을 제어 하는 역할을 가진다. Shell은 명령어 해석기의
역할을 가지고 나머지 파일과 디렉토리 구조로 구성이 되어 있다.



2. 운영체제의 구조

-------------------------------------
USER
-------------------------------------
       Application(웹브라우저,편집기)   =>  ls, find, .. (명령어)
OS     Shell(sh,csh,ksh,tcsh,zsh,bash)  =>  ksh          (명령어해석기)
       Kernel(unix, genunix)            =>  unix         (커널)
-------------------------------------
H/W                                     =>  disk, monitor(디바이스)
-------------------------------------


컴퓨터의 구성은 하드웨어와 소프트웨어로 나눌수 있다. 하드웨어는 CPU, RAM, Disk 등이고
소프트웨어는 컴퓨터안에서 실행할 수 있는 프로그램을 말한다. 운영체제는 이런 하드웨어
와 소프트웨어를 직접 제어 가능하도록 하는 프로그램이다.


(1). 하드웨어(H/w)


■ CPU(Central Processing Unit)

중앙처리장치는 컴퓨터 하드웨어의 핵심으로서 기억장치로부터 기계어 코드(컴퓨터가 이해
할수 있는 기게어 코드)를 읽어 들여 실행하는 역할을 한다. 다시말하면 컴퓨터내의 모든
제어와 연산을 담당한다. 명령어의 해석과 자료의 연산, 비교 등의 처리를 제어하는 컴퓨
터 시스템의 핵심적인 장치이다. 중앙처리장치의 성능은 컴퓨터의 성능과 직결되며 CPU
내부의 구성에 따라 컴퓨터의 계열이 다양하게 구분된다. 컴퓨터 시스템 전체를 제어하는
장치로서, 다양한 입력장치로부터 자료를 받아서 처리한 후 그 결과를 출력장치로 보내는
일련의 과정을 제어하고 조정하는 일을 수행한다. 모든 컴퓨터의 작동과정이 중앙처리장치
의 제어를 받기 때문에 컴퓨터의 두뇌에 해당한다.

중대형 컴퓨터에서는 이를 중앙처리장치(central processing unit:CPU)라 하지만, 소형 컴
퓨터에서는 때로 마이크로프로세서(micro processor) 또는 줄여서 그냥 프로세서라 부르기
도 하는데, 명칭만 다를 뿐 기본적으로 동일한 기능을 수행한다.


■ RAM(Ramdom Access Memory)

램(RAM)은 일반적으로 메모리 혹은 주기억장치라고 부르는데 중앙처리장치에 의해 접근되
는 기계어 코드와 자료(혹은 데이터)를 저장한다. 주기억장치로 널리 사용되고있는 메
모리로로, Random Access Memory 의 약어이다. 플립플롭으로 만들어진 기억소자를 사용
한다. 기록과 해독의 두 회로가 있어서 정보의 기록, 해독이 가능하고 컴퓨터나 주변 단말
기기의 기억장치에 널리 쓰인다. 종류로는 전원이 연결된 상태에서 일정한 주기마다 리프
레시(refresh) 조작을 해주어야만 정보가 지워지지 않는 DRAM과 전원만 연결되어 있으면
정보가 지워지지 않는 SRAM이 있으며 고밀도 집적회로를 사용하여 소형, 대용량화되고 있
다.

SunOS 5.X은 가상 메모리 운영체제이다. RAM의 사용공간 보다 더 많은 메모리 공간을 사용
하는 프로그램을 실행시켰을 때 사용되는 것이 가상 메모리이다. 가상 메모리는 하드 디스
크에 있는 메모리 공간이며 실제 메모리의 연장 공간처럼 쓰이게 된다.

프로그램은 하드디스크에 저장되며 프로그램이 실행되면 메모리에 복사가 되고 활성화 된
프로그램 동안 프로그램의 일부분이 RAM에 복사횓된다. 작업이 끝날 때 까지 가상 메모리
에 남아 있게 된다.

프로그램이 종료 되면 가상 메모리공간을 다른 프로그램 실행시 덮어 쓰게 되고 이것의
관리를 운영체제가 한다. 만약 전원이 꺼지면 저장하고 있는 모든 가상 메모리의 내용은
없어지게 된다.


■ Hard Disk

하드 디스크는 자기적 매체 장치로서 파일, 디렉토리, 프로그램들등을 저장하는 장치이다.
자성체로 코팅된 원판형 알루미늄 기판에 프로그램이나 데이터를 영구 보관하기 위한 외부
기억장치 자료를 저장할 수 있도록 만든 보조기억장치이다. 디스크가 레코드판처럼 겹
쳐져 있는 것으로, 디스크 위에는 트랙이라고 하는 동심원이 그려져 있다. 이 동심원 안에
데이터를 전자적으로 기록하게 된다. 헤드는 트랙에 정보를 기록하거나 읽어 내는 역할을
한다.

자기디스크 장치가 처음 나타났을 때는 디스크를 사용자가 컴퓨터에 장착하여 사용하게
했다. 그러나 먼지에 오염되거나 사용자의 조작 실수로 자료가 파손되는 일이 잦아서 현
재와 같이 밀봉하는 형태로 바뀌었다. 하드디스크라는 말은 PC가 출현되었을 때 플로피디
스크(FDD)만 사용할 수 있었는데, 점차 용량이 큰 현재의 디스크가 사용되면서 플로피에
상대되는 말로 하드라는 수식어가 붙게 되었다.


■ I/O 장치

입력장치는 컴퓨터에 자료를 입력하기 위한 장치를 말하며, 인풋시스템(Input System)이라
고도 한다. 인간이 정보를 해석하고 기억하는 방식과는 달리 컴퓨터는 0과 1로 정보를 표
시하게 되어 있다. 사람들이 사용하는 문자, 도형, 목소리, 숫자 등의 자료를 읽어 들여
0과 1의 이진수 형태로 바꾸어 컴퓨터가 처리를 할 수 있도록 해주는 역할을 하는 것이 입
력장치이다. 입력장치로는 키보드, 마우스, 조이스틱, 터치스크린, 이미지 스캐너, 디지털
카메라, 광학 마크 판독기(OMR), 바코드 판독기(Bar Code Reader), 자기잉크문자판독기
(MICR)등이 있다.

출력장치는 컴퓨터에서 정보를 처리한 결과를 기계로부터 인간이 알 수 있는 언어(言語)로
변환해서 꺼내는 장치이다. 출력장치는 모니터, 프린터, 종이테이프, 카드천공기, 라인프
린터, 자기테이프등이 있다.
(2). 운영체제

SunOS 운영체제는 다음과 같은 3가지로 구성이 된다.
■ 커널(Kernel)
■ 쉘(Shell)
■ 디렉토리 구조(Directory Structure)


① 커널

커널은 SunOS 운영체제의 핵심 부분으로 컴퓨터의 물리적인 자원을 관리해 주는 역할을 가
지고 다음과 같은 기능등을 가진다.
■ CPU 기능 관리(CPU 스케줄링)
■ 메모리 관리 및 가상메모리 관리
■ 프로세스 관리
■ 파일시스템과 구조 관리
■ 디바이스 관리(주변 장치, 입출력 장치)
■ 기타

커널은 솔라리스가 부팅될 때 가장 먼저 읽혀진다. 솔라리스 커널은 unix, genunix로 구성
되어 있으며 커널을 제외한 다른 특성이 있는 모든 기능들을 모듈(Module) 형태로 제공하
고 있다.


② 쉘(Shell)

쉘은 명령어를 해석하는 부분으로서 사용자와 솔라리스 시스템을 연결시켜 주는 인터페이
스 역할을 한다. 즉 사용자가 입력한 명령어를 해석하여 커널이 이해할 수 있는 명령으로
번역하여 커널에게 넘겨 준다. 그러면 커널이 그것을 수행하고 수행된 결과 값을 쉘에게
다시 넘겨주게된다. 그러면 쉘은 사용자에게 명령어의 결과 값을 돌려 준다. 결국 사용자
의 명령을 해석하는 역할을 한다. 쉘은 이렇게 ㉮명령어를 해석하는 역할외에도 ㉯프로그
램을 할수 있는 특징을 가지고 있다. 쉘의 특성을 이용한 프로그램을 쉘프로그램 또는 쉘
스크립트라고 한다.

솔라리스에서는 6가지 쉘을 제공해 주고 있다. 기본 쉘(Basic Shell)과 추가적인 쉘이다.

솔라리스 9에서의 기본 쉘
  ■ Bourne Shell
  ■ C Shell
  ■ Korn Shell
솔라리스 9에서의 추가적인 쉘
  ■ Bash
  ■ Z Shell
  ■ TC Shell

솔라리스의 추가적인 쉘은 솔라리스 8에서 처음 내장이 되었으며 그 전까지는 기본 쉘 3가
지만 제공하고 있었다. 실제적으로 다른 디렉토리 안에서 많은 쉘의 이름이 존재하지만 실
제 이 기본 쉘과 추가적인 쉘에 링크 되어진 상태이다.

쉘의 역할을 정리하여 보면 다음과 같다.
① 입력을 읽고 해당 명령행을 분석한다.
② 특수 문자들을 평가한다.
③ 파이프, 리다이렉션, 백그라운드 프로세스를 설정한다.
④ 시그널을 처리한다.
⑤ 프로그램을 올바르게 실행시킨다.

다음은 쉘의 발전 과정에 대한 그림이다.

sh --------------> ksh --------------> zsh

         csh ------------------------> tcsh

                                       bash(sh + csh + ksh)

         [그림] 쉘의 발전 과정
출처 : http://cafe.daum.net/bscsolaris

2008. 7. 19. 18:15

Chapter 1. UNIX History

Chapter 1.  UNIX History
_________________________

Mutics => UNIX(AT&T, 1969년)
(1). System V 계열
(2). BSD(Berkeley Software Distribution)
(3). SVR4(System V Release 4)


[참고] 유닉스 역사 / 유닉스 소개


                             [유닉스의 역사]

1960년대 AT&T 벨연구소에서 개발한 Multics 라는 운영체제가 너무 복잡하여
운영체제의 필요성이 생기게 되었다. 1969년 AT&T Bell 연구소의 Ken Thompson과
C언어를 만든 Dennis Rithie에 의해 PDP-7를 사용하여 어셈블리로 개발 되었다.

초기의 유닉스 운영체제는 어셈블리(Assembly) 언어로 작성되어 Dennis Ritchie가
B언어를 개선한 C언어를 개발한 뒤 1973년에 C언어를 사용하여 유닉스를 다시 만
들것을 제한하였고 그리하여 유닉스의 90% 이상이 C로 다시 작성이 되고 나머지는
어셈블리 언어 및 스크립트로 작성되었다. 이로인해 다른 시스템에도 아주 쉽게
이식하여 사용할수 있게 되었다.

1976년도 AT&T는 외부의 여러 대학에 소스 코드와 매뉴얼을 배포하였으며 유닉스의
소스 코드를 받은 여러 연구소는 개량 판을 발표하였는데 그 중에서 가장 유명하고
활발한 활동을 하였던 것이 BSD(Berkely Software Distribution)이다.

1978년 UNIX V6(Version 6)라는 이름으로 일반인에게 공개되면서 IBM 370 컴퓨터에
이식하여 시험하였고 다른 많은 회사에서도 자사의 중대형 컴퓨터에 유닉스를 이식
하기 시작하였다.

BSD는 1978년도 버클리 대학의 빌 조이가 발표하여 1979년 가상 메모리 개념을 최초
로 도입했으며, 1980년에는 TCP/IP를 구현한 최초의 운영체제가 되었다.

AT&T의 벨 연구소도 유닉스를 꾸준히 개량하여 1983년 UNIX System V라는 이름으로
새 버전을 발표하였다.

썬은 BSD를 만든 빌 조이를 영입하여 1984년 BSD를 바탕으로 많은 독자적인 기능을
추가한 SunOS를 발표하였고 많은 유닉스 계열의 기술적인 공헌과 개선을 하였다.

유닉스의 원조이자 UNIX System V 계열의 대표인 AT&T와 BSD 계열의 선두 주자인 썬
은 UNIX System V와 SunOS를 근간으로 SVR4(System V Release 4)를 발표하였다.
SVR4는 1991년도 썬이 Solaris 2.X라는 상표명으로 발표를 한 이후에 많은 유닉스
제조회사들이 채택하여 유닉스의 기본이 되었다.



                             [유닉스의 소개]

유닉스는 1969년에 벨연구소에서 인터랙티브 시분할 시스템으로서 만든 것이 그 시초
가 된 운영체계이다. 켄 톰슨과 데니스 리치가 유닉스의 창시자로 알려져 있다. 유닉
스라는 이름은 그 이전의 시스템인 멀틱스에 기반을 두고 지은 일종의 말장난이었다.
1974년에 유닉스는 C 언어로 쓰여진 최초의 운영체계가 되었다. 유닉스는 여러 회사
들이나 대학 및 개인들에 의해 많은 확장판과 새로운 아이디어들이 다양한 버전의 유
닉스에 추가됨으로써, 대형 프리웨어 제품의 한 종류로 진화하였다. 유닉스는 앞서가
는 특정 컴퓨터 회사들에 의해 소유된 독점적인 운영체계가 아니었다는 것과, 또 그
것이 표준 프로그래밍 언어로 작성되고, 대중적인 많은 아이디어를 받아들였다는 이
유 때문에,누구에 의해서도 개선되고 강화될 수 있는 최초의 개방형 표준 운영체계가
되었다. 다양한 버전의 유닉스로부터 나온 C 언어와 쉘 인터페이스의 복합체는 IEEE의
찬조 하에서 POSIX로 표준화되었다. POSIX 인터페이스들은 번갈아 가며, X/Open 프로
그래밍 가이드 4.2 ("단일 유닉스 규격"과 "유닉스95"로 알려져있다)에 명기되었다.
단일 유닉스 규격의 버전2는 유닉스98로도 알려져 있다. 유닉스의 공식적인 등록상표
는 현재 산업표준기구인 오픈그룹이 소유하고 있으며, 유닉스 관련 제품들의 인증과
상표부여 등을 관장하고 있다.

유닉스 운영체계는 널리 판매된 썬마이크로시스템즈, 실리콘그래픽스, IBM, 그리고
그외 많은 회사들의 워크스테이션 제품들에서 사용된다. 유닉스 환경과 클라이언트/
서버 프로그램 모델은 인터넷 개발과 네트웍 중심의 컴퓨팅 국면을 새로이 하기 위한
중요한 요소였다. 유닉스에서 파생하여, 현재 무료 소프트웨어와 상용버전이 모두 존
재하는 리눅스는 독점 운영체계의 대안으로서 명성을 더해가고 있다.

출처 : http://cafe.daum.net/bscsolaris

2008. 7. 19. 18:12

solaris 알림

solaris 폴더내 모든 자료는

http://cafe.daum.net/bscsolaris

에서 퍼온 자료이며 개인적인 자료 정리용으로 쓰였습니다