[AIX 네트워크 관리 17] TCP/IP (11) LDAP·NIS_LDAP 이름 풀이와 DHCP 개요·서버 구조
https://archive.horanglab.com/posts/aix-net-tcpip-11
핵심 정리
- LDAP(IBM SecureWay 스키마):
ibm-HostTable객체 클래스에 호스트 이름→주소를 저장합니다. 서버에 접미사(예:cn=hosts)를 더하고hosts2ldif로/etc/hosts에서 LDIF를 만들어ldif2db로 넣습니다. 클라이언트는/etc/resolv.ldap을 만들고 NSORDER·netsvc.conf·irs.conf에 ldap을 넣습니다. 이 ldap 방식은 사용 중단 예정이며 nis_ldap을 권장합니다. - NIS_LDAP(RFC 2307): 사용자·그룹, 호스트, 서비스, 프로토콜, 네트워크, netgroup을 모두 지원합니다. 서버는
mksecldap -s -a cn=admin -p 암호 -S rfc2307aix(기본 접미사cn=aixdata, 로컬 사용자 이전을 막으려면-u NONE), NIS 데이터는nistoldif로 옮깁니다. 클라이언트는mksecldap -c -a … -h 서버가 ldap.cfg를 쓰고 secldapclntd를 시작하며 netsvc.conf·irs.conf에 nis_ldap을 넣습니다. LDAP 사용자 로그인은/etc/security/user의SYSTEM=LDAP registry=LDAP(chuser -R LDAP …). - DHCP: 클라이언트(dhcpcd)가 discover를 브로드캐스트 → 서버가 offer → 클라이언트가 고른 서버에 request → ack로 임대(lease)가 시작됩니다. 임대 시간의 절반에 renew, 응답이 없으면 rebind, 끝까지 갱신하지 못하면 인터페이스를 내리고 다시 시작합니다. 서버는 network, class, vendor, client ID 키로 주소와 옵션을 고르며, 다른 네트워크의 클라이언트에는 BOOTP 릴레이 에이전트가 필요합니다.
- AIX DHCP 서버는 데이터베이스(
db_file.dhcpo, 클라이언트 상태 FREE·BOUND·EXPIRED·RELEASED·RESERVED·BAD, 체크포인트 파일), RFC 2131 프로토콜 엔진, 스레드(SRC 요청·신호 처리 main, dadmin, garbage, 기본 10개의 패킷 처리기)로 이루어집니다. SIGHUP은 데이터베이스 새로 고침, SIGTERM은 정상 종료입니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1에서 ldap 방식이 사용 중단 예정으로 바뀜) |
| 원문 | Networks and communication management — 5.3판 162169쪽, 6.1판 208215쪽 |
| 파일 | /etc/resolv.ldap, /etc/netsvc.conf, /etc/irs.conf, /etc/security/ldap/ldap.cfg, /etc/security/user, /etc/slapd32.conf, /etc/db_file.cr, /etc/db_file.crbk, /etc/db_file.chkpt |
| 관련 명령어 | hosts2ldif, ldif2db, mksecldap, nistoldif, chuser, secldapclntd, dhcpcd, dhcpsd, dadmin, lssrc |
LDAP(Lightweight Directory Access Protocol)는 디렉터리의 정보에 접근하고 갱신하는 방법을 정한 공개 업계 표준입니다.
LDAP 스키마는 데이터를 정리하는 규칙을 정합니다. IBM SecureWay Directory 스키마의 일부인 ibm-HostTable 객체 클래스에 네트워크의 모든 호스트에 대한 이름→인터넷 주소 대응 정보를 저장할 수 있습니다.
ibm-HostTable 객체 클래스는 다음과 같이 정의되어 있습니다.
Object Class name: ibm-HostTable
Description: Host Table entry which has a collection of hostname to
IP address mappings.
OID: TBD
RDN: ipAddress
Superior object class: top
Required Attributes: host, ipAddress
Optional Attributes: ibm-hostAlias, ipAddressType, description
속성 정의는 다음과 같습니다.
Attribute Name: ipAddress
Description: IP Address of the hostname in the Host Table
OID: TBD
Syntax: caseIgnoreString
Length: 256
Single Valued: Yes
Attribute Name: ibm-hostAlias
Description: Alias of the hostname in the Host Table
OID: TBD
Syntax: caseIgnoreString
Length: 256
Single Valued: Multi-valued
Attribute Name: ipAddressType
Description: Address Family of the IP Address (1=IPv4, 2=IPv6)
OID: TBD
Syntax: Integer
Length: 11
Single Valued: Yes
Attribute Name: host
Description: The hostname of a computer system.
OID: 1.13.18.0.2.4.486
Syntax: caseIgnoreString
Length: 256
Single Valued: Multi-valued
Attribute Name: description
Description: Comments that provide a description of a directory object entry.
OID: 2.5.4.13
Syntax: caseIgnoreString
Length: 1024
Single Valued: Multi-valued
다음 절차로 이름→인터넷 주소 대응 호스트 정보를 저장하도록 IBM SecureWay Directory 스키마를 따르는 LDAP 서버를 구성합니다.
- LDAP 서버에 접미사(suffix)를 더합니다. 접미사는 hosts 데이터베이스의 시작점입니다. 예: "cn=hosts". 웹 기반 IBM SecureWay Directory Server Administration 도구로 할 수 있습니다.
- LDIF(LDAP Data Interchange Format) 파일을 만듭니다. 손으로 만들거나,
/etc/hosts파일로 LDIF 파일을 만드는hosts2ldif명령으로 만들 수 있습니다. 자세한 내용은 hosts2ldif 명령을 봅니다. LDIF 파일의 예입니다.
dn: cn=hosts
objectclass: top
objectclass: container
cn: hosts
dn: ipAddress=1.1.1.1, cn=hosts
host: test
ipAddress: 1.1.1.1
objectclass: ibm-HostTable
ipAddressType: 1
ibm-hostAlias: e-test
ibm-hostAlias: test.austin.ibm.com
description: first ethernet interface
dn: ipAddress=fe80::dead, cn=hosts
host: test
ipAddress: fe80::dead
objectclass: ibm-HostTable
ipAddressType: 2
ibm-hostAlias: test-ll
ibm-hostAlias: test-ll.austin.ibm.com
description: v6 link level interface
- LDAP 서버에 LDIF 파일의 hosts 디렉터리 데이터를 들여옵니다.
ldif2db명령이나 웹 기반 IBM SecureWay Directory Server Administration 도구로 할 수 있습니다.
LDAP 방식으로 LDAP 서버의 hosts 데이터베이스에 접근하도록 클라이언트를 구성하는 단계는 다음과 같습니다.
/etc/resolv.ldap파일을 만듭니다. 자세한 설명과resolv.ldap파일 예는 Files Reference의 resolv.ldap File Format for TCP/IP를 봅니다.- NSORDER 환경 변수,
/etc/netsvc.conf파일,/etc/irs.conf파일 가운데 하나로 기본 이름 풀이 순서를 바꿉니다. 자세한 내용은 Files Reference의 netsvc.conf File Format for TCP/IP나 irs.conf File Format for TCP/IP를 봅니다.
ldap 방식은 아직 지원하지만 사용 중단 예정(deprecated)입니다. 기존 ldap 방식은 IBM SecureWay Directory 스키마와 함께 동작하고, nis_ldap(NIS_LDAP)은 RFC 2307 스키마와 함께 동작합니다. ldap 방식 대신 nis_ldap 방식을 쓰기를 권합니다. nis_ldap 이름 풀이는 다음 절 "NIS_LDAP 이름 풀이 계획과 구성(RFC 2307 스키마)"을 봅니다.
참고: 6.1판 PDF에서는 다음 LDAP 스키마 예가 앞 절(DNS 계획) 끝에 잘못 붙어 있어, 이 글에서는 LDAP 절로 옮겨 실었습니다. container와 hosts 객체 클래스에 필요한 속성(requires)과 허용하는 속성(allows)을 보여 줍니다.
objectclass container
requires
objectclass,
cn
objectclass hosts
requires
objectclass,
hname
allows
addr
halias,
comment
영어 원문
Planning and configuring for LDAP name resolution (IBM SecureWay Directory schema)
The Lightweight Directory Access Protocol (LDAP) is an open industry standard that defines a method for accessing and updating information in a directory.
An LDAP schema defines the rules for ordering data. The ibm-HostTable object class, part of the IBM SecureWay Directory schema, can be used to store the name-to-Internet-address mapping information for every host on the network.
The ibm-HostTable object class is defined as follows:
Object Class name: ibm-HostTable
Description: Host Table entry which has a collection of hostname to
IP address mappings.
OID: TBD
RDN: ipAddress
Superior object class: top
Required Attributes: host, ipAddress
Optional Attributes: ibm-hostAlias, ipAddressType, description
The attribute definitions follow:
(30줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
Use the following procedure to configure the LDAP server compliant with the IBM SecureWay Directory schema, for storing the name-to-Internet-address mapping host information.
Add a suffix on the LDAP server. The suffix is the starting point of the hosts database. For example, "cn=hosts". This can done using the web-based IBM SecureWay Directory Server Administration tool.
Create an LDAP Data Interchange Format (LDIF) file. This can be done manually or with the hosts2ldif command, which creates a LDIF file from the
/etc/hostsfile. See the hosts2ldif Command for more information. The following is a sample LDIF file:
(20줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
- Import the hosts directory data from the LDIF file on the LDAP server. This can be done with the ldif2db command or through the web-based IBM SecureWay Directory Server Administration tool.
To configure the client to access the hosts database on the LDAP server, using the LDAP mechanism, follow these steps:
Create the
/etc/resolv.ldapfile. See the resolv.ldap File Format for TCP/IP in the Files Reference for more information and a detailed example of aresolv.ldapfile.Change the default name resolution through the NSORDER environment variable, the
/etc/netsvc.conffile, or the/etc/irs.conffile. See the netsvc.conf File Format for TCP/IP or the irs.conf File Format for TCP/IP in the Files Reference for more information.
Although still supported, the use of ldap mechanism is deprecated. This existing ldap mechanism works with IBM SecureWay Directory Schema, while nis_ldap (NIS_LDAP) works with the RFC 2307 schema. Use of the nis_ldap mechanism instead of the ldap mechanism is recommended. For information on nis_ldap name resolution, see “Planning and configuring NIS_LDAP name resolution (RFC 2307 schema).”
NIS_LDAP 이름 풀이 계획과 구성(RFC 2307 스키마)
AIX 5.2에는 NIS_LDAP이라는 새 이름 풀이 방식이 있습니다.
기존 LDAP 방식과 새 NIS_LDAP 방식의 차이는 LDAP 스키마(개체를 설명하려고 속성을 어떻게 묶을지 정하는 속성과 객체 클래스의 모음)에 있습니다. 기존 LDAP 방식은 IBM SecureWay Directory 스키마를 따르는 LDAP 서버와 함께 동작하며 호스트 이름 서비스만 지원합니다. NIS_LDAP 방식은 RFC 2307 스키마를 따르는 LDAP 서버와 함께 동작하며 모든 NIS 서비스, 곧 사용자와 그룹, 호스트, 서비스, 프로토콜, 네트워크, netgroup을 지원합니다. RFC 2307은 사용자와 그룹을 포함한 네트워크 정보 서비스를 설명하는 데 쓸 수 있는 속성과 객체 클래스의 모음을 정의합니다.
LDAP 서버 구성하기
LDAP 서버를 구성하려면 LDAP 서버를 설정하고 필요한 데이터를 서버로 옮겨야 합니다.
mksecldap명령으로 서버를 설정합니다.nis_ldap방식은 RFC 2307 스키마에서만 동작합니다. LDAP 서버를 설정할 때mksecldap명령은-S rfc2307이나-S rfc2307aix옵션으로 불러야 합니다(IBM SecureWay Directory 스키마를 지정하는-S aix옵션이 아님). 기본으로mksecldap명령은 로컬 시스템에 정의된 사용자와 그룹을 LDAP 서버로 옮깁니다. 이 이전을 막으려면-u NONE옵션을 씁니다.
mksecldap -s -a cn=admin -p adminpwd -S rfc2307aix
이 명령은 관리자 DN이 cn=admin이고 암호가 adminpwd인 LDAP 서버를 설정합니다. 기본 접미사 cn=aixdata도 LDAP 서버 구성 파일 /etc/slapd32.conf에 더해집니다. 기본으로 mksecldap 명령은 로컬 시스템에 정의된 사용자와 그룹을 LDAP 서버로 옮깁니다. 이 이전을 막으려면 -u NONE 옵션을 씁니다. 그러면 로컬 사용자와 그룹이 LDAP 서버로 옮겨지지 않으므로 나중에 NIS 사용자와 그룹만 더할 수 있습니다.
mksecldap -s -a cn=admin -p adminpwd -u NONE
mksecldap 명령에 관한 자세한 내용은 Commands Reference 3권의 명령 설명을 봅니다.
- NIS 데이터를 옮깁니다. NIS 서버에서
nistoldif명령으로 NIS 맵을 LDAP 서버로 옮깁니다.nistoldif명령은 평면 파일의 데이터를 옮기는 데도 쓸 수 있습니다. LDAP 서버로 옮겨야 할 NIS 데이터가 있는 시스템에서nistoldif명령을 실행합니다.
nistoldif -h server1.ibm.com -a cn=admin -p adminpwd -d cn=aixdata
이 명령은 로컬 시스템의 NIS 맵을 LDAP 서버 server1.ibm.com으로 옮깁니다. NIS 데이터는 cn=aixdata DN 아래에 놓입니다. 어느 시스템에서든 nistoldif 명령으로 평면 파일의 데이터를 LDAP 서버로 옮길 수도 있습니다. NIS 서버에 없는 맵에는 평면 파일을 씁니다. nistoldif 명령에 관한 자세한 내용은 Commands Reference 4권의 명령 설명을 봅니다.
참고: 이름은 LDAP 서버의 cn 속성으로 나타냅니다. RFC 2307이 정의한 cn 속성은 대소문자를 구분하지 않습니다. 대소문자만 다른 이름은 서버에서 합쳐집니다. 일치 비교도 대소문자를 구분하지 않으므로 TCP, tcp, Tcp 가운데 무엇으로 찾든 TCP의 프로토콜 항목이 나옵니다.
LDAP 클라이언트 구성하기
LDAP 서버의 이름에 접근하도록 LDAP 클라이언트를 구성하려면 클라이언트 설정 옵션으로 mksecldap 명령을 실행합니다.
mksecldap명령은 LDAP 서버 이름, 포트, admindn, 암호, basedn을/etc/security/ldap/ldap.cfg파일에 저장하며, secldapclntd 데몬이 시작할 때 이 파일을 읽습니다. 설정이 성공하면mksecldap명령이 secldapclntd 데몬을 자동으로 시작합니다. 자세한 내용은 Files Reference의/etc/security/ldap/ldap.cfg파일과 Commands Reference 5권의 secldapclntd 데몬을 봅니다.mksecldap명령은 이름 풀이가 LDAP으로 가도록/etc/netsvc.conf파일과/etc/irs.conf파일에nis_ldap방식을 더합니다. NSORDER 환경 변수를 손으로nis_ldap으로 설정해NIS_LDAP이름 풀이를 쓸 수도 있습니다.
mksecldap -c -a cn=admin -p adminpwd -h server1.ibm.com
이 명령은 로컬 시스템이 LDAP 서버 server1.ibm.com을 쓰도록 설정합니다. 이 클라이언트가 서버에 인증하려면 LDAP 서버 관리자 DN과 암호를 줘야 합니다. 이름 풀이가 NIS_LDAP으로 이루어지도록 /etc/netsvc.conf와 /etc/irs.conf 파일이 갱신됩니다. 자세한 내용은 Files Reference의 /etc/netsvc.conf나 /etc/irs.conf 파일 형식을 봅니다.
- 사용자와 그룹의 이름 풀이는
/etc/netsvc.conf나/etc/irs.conf파일이 아니라/etc/security/user파일로 제어합니다. LDAP 사용자가 AIX 시스템에 로그인하게 하려면 그 클라이언트 시스템의/etc/security/user파일에서 사용자의SYSTEM과registry변수를LDAP으로 설정합니다.chuser명령으로 할 수 있습니다.
chuser -R LDAP SYSTEM=LDAP registry=LDAP foo
모든 LDAP 사용자가 시스템에 로그인하도록 구성할 수도 있습니다. /etc/security/user 파일을 편집해 root 스탠자에 registry = files를 넣고, default 스탠자에 SYSTEM = LDAP과 registry = LDAP을 넣습니다. 사용자 인증에 관한 자세한 내용은 Security의 Light Directory Access Protocol을 봅니다. RFC 2307 Netgroup 인증을 켜는 방법은 Network Information Services (NIS and NIS+) Guide의 "Migrating from NIS and NIS+ to RFC 2307-compliant LDAP services"를 봅니다.
영어 원문
Planning and configuring NIS_LDAP name resolution (RFC 2307 schema)
AIX 5.2 offers a new naming mechanism called NIS_LDAP.
The difference between the existing LDAP mechanism and the new NIS_LDAP mechanism is in the LDAP schema (the set of attributes and object classes that determine how attributes are grouped together for describing an entity). The existing LDAP mechanism works with the IBM SecureWay Directory schema compliant LDAP server and it supports only the host naming service. The NIS_LDAP mechanism works with the RFC 2307 schema compliant LDAP server, and it supports all the NIS services: users and groups, hosts, services, protocols, networks, and netgroup. RFC 2307 defines a set of attributes and object classes that can be used to describe network information services, including users and groups.
- To configure the LDAP server, you will need to set up the LDAP server and migrate the required data to the server.
- Use the mksecldap command to set up a server. The
nis_ldapmechanism works only with the RFC 2307 schema. While setting up the LDAP server, the mksecldap command should be invoked with either the-S rfc2307or-S rfc2307aixoption (not the-S aixoption, which specifies the IBM SecureWay Directory schema). By default, the mksecldap command migrates users and groups defined on the local system to the LDAP server. If you want to disable this migration, use the-u NONEoption.
mksecldap -s -a cn=admin -p adminpwd -S rfc2307aix
This sets up an LDAP server with administrator DN being cn=admin and password being adminpwd. The default suffix, cn=aixdata, is also added to the /etc/slapd32.conf file, the LDAP server configuration file. By default, the mksecldap command migrates users and groups defined on the local system to the LDAP server. If you want to disable this migration, use the -u NONE option, which prevents the migration of local users and groups to the LDAP server, so that you can only add NIS users and groups later.
mksecldap -s -a cn=admin -p adminpwd -u NONE
For more information on the mksecldap command, see the command description in Commands Reference, Volume 3.
- Migrate the NIS data. Use the nistoldif command from the NIS server to migrate the NIS maps to the LDAP server. The nistoldif command can also be used to migrate data from flat files. Run the nistoldif command on a system that contains NIS data that needs to be migrated to the LDAP server.
nistoldif -h server1.ibm.com -a cn=admin -p adminpwd -d cn=aixdata
This migrates the NIS maps from the local system to the LDAP server, server1.ibm.com. The NIS data is placed under the cn=aixdata DN. You can also run the nistoldif command to migrate data from flat files on any system to the LDAP server. The flat files will be used for any maps missing from the NIS server. For more information on the nistoldif command, see the command description in Commands Reference, Volume 4.
Note: Names are represented by the cn attribute of the LDAP server. The cn attribute defined by RFC 2307 is not case-sensitive. Names that differ only by case will be merged on the server. Matches are also not case-sensitive. Searching for TCP, tcp, or Tcp would all return the protocol entry for TCP.
- To configure the LDAP client to access names from the LDAP server, run the mksecldap command with client setup options.
The mksecldap command saves the LDAP server name, port, admindn, password, and basedn to the
/etc/security/ldap/ldap.cfgfile, which is read by the secldapclntd daemon at its startup time. The mksecldap command starts the secldapclntd daemon automatically, if the setup is successful. See the/etc/security/ldap/ldap.cfgfile in Files Reference and the secldapclntd daemon in the Commands Reference, Volume 5 for more information.The mksecldap command adds
nis_ldapmechanism to the/etc/netsvc.conffile and the/etc/irs.conffile so that name resolution can be directed to LDAP. You can also manually set the NSORDER environment variable tonis_ldapto use theNIS_LDAPname resolution.
mksecldap -c -a cn=admin -p adminpwd -h server1.ibm.com
This sets up the local system to use the server1.ibm.com LDAP server. The LDAP server administrator DN and password must be supplied for this client to authenticate to the server. The /etc/netsvc.conf and the /etc/irs.conf files are updated so that the naming resolution is resolved through NIS_LDAP. See the /etc/netsvc.conf file format for TCP/IP or the /etc/irs.conf file format for TCP/IP in the Files Reference for more information.
- Naming resolution for users and groups is not controlled by the
/etc/netsvc.confor/etc/irs.conffiles. Rather it is through the/etc/security/userfile. To enable a LDAP user to login to an AIX system, set the user'sSYSTEMandregistryvariables toLDAPin the/etc/security/userfile of that client system. You can run the chuser command to do this.
chuser -R LDAP SYSTEM=LDAP registry=LDAP foo
You can configure your system to allow all LDAP users to login to a system. To do so, edit the /etc/security/user file. Add registry = files to the root stanza. Then add SYSTEM = LDAP and registry = LDAP to the default stanza. For more information on user authentication, refer to Light Directory Access Protocol in Security. For information on enabling RFC 2307 Netgroup authentication, see "Migrating from NIS and NIS+ to RFC 2307-compliant LDAP services" in Network Information Services (NIS and NIS+) Guide.
TCP/IP 주소와 매개변수 할당 - DHCP
TCP/IP는 주소가 구성된 기계 사이의 통신을 가능하게 합니다. 네트워크 관리자가 떠안는 부담 가운데 하나는 네트워크의 모든 기계에 주소를 주고 매개변수를 나눠 주는 일입니다. 보통은 관리자가 사용자마다 구성을 알려 주고 사용자가 자기 기계를 구성합니다. 그러나 잘못된 구성과 오해 때문에 생기는 지원 요청을 관리자가 하나하나 처리해야 합니다. DHCP(Dynamic Host Configuration Protocol)는 최종 사용자를 이 구성 문제에서 떼어 내고 네트워크 구성을 한곳에서 관리하는 방법을 네트워크 관리자에게 줍니다.
DHCP는 네트워크의 클라이언트 기계가 서버에서 IP 주소와 다른 구성 매개변수를 얻게 하는 응용 계층 프로토콜입니다. 클라이언트의 데몬과 서버의 데몬이 패킷을 주고받아 정보를 얻습니다. 요즘 대부분의 운영 체제는 기본 패키지에 DHCP 클라이언트를 제공합니다.
주소를 얻으려고 DHCP 클라이언트 데몬(dhcpcd)은 DHCP discover 메시지를 브로드캐스트하고, 서버가 이를 받아 처리합니다(중복성을 위해 네트워크에 서버를 여럿 구성할 수 있습니다). 그 클라이언트에 줄 빈 주소가 있으면 DHCP offer 메시지를 만듭니다. 이 메시지에는 그 클라이언트에 알맞은 IP 주소와 다른 옵션이 들어 있습니다. 클라이언트는 서버의 DHCP offer를 받아 저장하고 다른 offer를 기다립니다. 가장 좋은 offer를 고르면 어느 서버의 offer를 원하는지 지정한 DHCP request를 브로드캐스트합니다.
구성된 모든 DHCP 서버가 request를 받습니다. 각 서버는 자기가 요청된 서버인지 확인하고, 아니면 그 클라이언트에 할당해 둔 주소를 풉니다. 요청된 서버는 주소를 할당됨으로 표시하고 DHCP acknowledgment(ack)를 돌려주며, 이때 트랜잭션이 끝납니다. 클라이언트는 서버가 정한 기간(임대, lease) 동안 주소를 가집니다.
임대 시간의 절반이 지나면 클라이언트는 임대 시간을 늘리려고 서버에 renew 패킷을 보냅니다. 서버가 갱신해 주려면 DHCP ack를 보냅니다. 현재 주소를 소유한 서버에서 응답을 받지 못하면, 예를 들어 서버가 다른 네트워크로 옮겨졌을 때를 대비해 서버에 닿으려고 DHCP rebind 패킷을 브로드캐스트합니다. 임대 시간이 다 지나도록 주소를 갱신하지 못하면 인터페이스를 내리고 과정을 처음부터 다시 시작합니다. 이 주기 덕분에 네트워크의 여러 클라이언트에 같은 주소가 할당되지 않습니다.
DHCP 서버는 키(key)를 바탕으로 주소를 줍니다. 흔한 키 네 가지는 network, class, vendor, client ID입니다. 서버는 이 키로 주소와, 클라이언트에 돌려줄 구성 옵션 묶음을 얻습니다.
| 키 | 설명 |
|---|---|
| network | 패킷이 어느 네트워크 세그먼트에서 왔는지 나타냅니다. network 키로 서버는 주소 데이터베이스를 확인하고 네트워크 세그먼트별로 주소를 줄 수 있습니다. |
| class | 클라이언트가 완전히 구성할 수 있습니다. 주소와 옵션을 지정할 수 있습니다. 네트워크에서 기계의 역할이나 관리 목적으로 기계를 어떻게 묶는지를 나타내는 데 쓸 수 있습니다. 예를 들어 네트워크 관리자는 NetBIOS 클라이언트용 옵션이 든 netbios 클래스나, 특정 프린터에 접근해야 하는 회계 부서 기계를 나타내는 accounting 클래스를 만들 수 있습니다. |
| vendor | 하드웨어·소프트웨어 플랫폼(예: Microsoft Windows 95 클라이언트, OS/2 Warp 클라이언트)으로 클라이언트를 식별하는 데 도움을 줍니다. |
| client ID | 기계의 호스트 이름이나 MAC(medium access control) 계층 주소로 클라이언트를 식별합니다. client ID는 dhcpcd 데몬의 구성 파일에 지정합니다. 서버는 client ID로 특정 클라이언트에 옵션을 주거나, 특정 클라이언트가 어떤 매개변수도 받지 못하게 할 수 있습니다. |
구성에서 이 키를 하나만 쓰거나 조합해 쓸 수 있습니다. 클라이언트가 여러 키를 주고 여러 주소를 할당할 수 있으면 하나만 고르며, 옵션 묶음은 고른 키에서 먼저 가져옵니다. 키와 주소 선택에 관한 자세한 내용은 DHCP 구성(다음 편)을 봅니다.
클라이언트의 첫 브로드캐스트가 로컬 네트워크를 벗어나려면 릴레이 에이전트가 필요합니다. 이 에이전트를 BOOTP 릴레이 에이전트라고 합니다. 릴레이 에이전트는 DHCP와 BOOTP 패킷의 전달 에이전트 역할을 합니다.
영어 원문
TCP/IP address and parameter assignment - Dynamic Host Configuration Protocol
Transmission Control Protocol/Internet Protocol (TCP/IP) enables communication between machines with configured addresses. Part of the burden a network administrator must face is address assignment and parameter distribution for all machines on the network. Commonly, this is a process in which the administrator dictates the configuration to each user, allowing the user to configure his own machine. However, misconfigurations and misunderstandings can generate service calls that the administrator must deal with individually. The Dynamic Host Configuration Protocol (DHCP) gives the network administrator a method to remove the end user from this configuration problem and maintain the network configuration in a centralized location.
DHCP is an application-layer protocol that allows a client machine on the network, to get an IP address and other configuration parameters from the server. It gets information by exchanging packets between a daemon on the client and another on the server. Most operating systems now provide a DHCP client in their base package.
To obtain an address, the DHCP client daemon (dhcpcd) broadcasts a DHCP discover message, which is received by the server and processed. (Multiple servers can be configured on the network for redundancy.) If a free address is available for that client, a DHCP offer message is created, This message contains an IP address and other options that are appropriate for that client. The client receives the server DHCP offer and stores it while waiting for other offers. When the client chooses the best offer, it broadcasts a DHCP request that specifies which server offer it wants.
All configured DHCP servers receive the request. Each checks to see if it is the requested server. If not, the server frees the address assigned to that client. The requested server marks the address as assigned and returns a DHCP acknowledgment, at which time, the transaction is complete. The client has an address for the period of time (lease) designated by the server.
When half of the lease time is used, the client sends the server a renew packet to extend the lease time. If the server is willing to renew, it sends a DHCP acknowledgment. If the client does not get a response from the server that owns its current address, it broadcasts a DHCP rebind packet to reach the server if,
for example, the server has been moved from one network to another. If the client has not renewed its address after the full lease time, the interface is brought down and the process starts over. This cycle prevents multiple clients on a network from being assigned the same address.
The DHCP server assigns addresses based on keys. Four common keys are network, class, vendor, and client ID. The server uses these keys to get an address and a set of configuration options to return to the client.
network
Identifies which network segment the packet came from. The network key allows the server to check its address database and assign an address by network segment.
class Is completely client configurable. It can specify an address and options. This key can be used to denote machine function in the network or to describe how machines are grouped for administrative purposes. For example, the network administrator might want to create a netbios class that contains options for NetBIOS clients or an accounting class that represents Accounting department machines that need access to a specific printer.
vendor
Helps identify the client by its hardware/software platform (for example, a Microsoft Windows 95 client or an OS/2 Warp client).
client ID
Identifies the client either through the machine host name or its medium access control (MAC) layer address. The client ID is specified in the configuration file of the dhcpcd daemon. Also, the client ID can be used by the server to pass options to a specific client or prohibit a particular client from receiving any parameters.
These keys can be used by the configuration either singularly or in combinations. If multiple keys are provided by the client and multiple addresses can be assigned, only one is chosen, and the option set is derived from the chosen key first. For more detailed information about the selection of keys and addresses, see DHCP configuration.
A relay agent is needed so initial broadcasts from the client can leave the local network. This agent is called the BOOTP relay agent. The relay agents act as forwarding agents for DHCP and BOOTP packets.
DHCP 서버
AIX에서 DHCP 서버는 크게 세 부분으로 나뉩니다.
DHCP 서버의 주요 구성 요소는 데이터베이스, 프로토콜 엔진, 그리고 각자 구성 정보를 가진 서비스 스레드 묶음입니다.
DHCP 데이터베이스
db_file.dhcpo 데이터베이스는 클라이언트와 주소를 추적하고 접근을 제어하는 데 씁니다(예: 어떤 네트워크에서는 특정 클라이언트를 허용하고 다른 네트워크에서는 허용하지 않거나, 특정 네트워크에서 BOOTP 클라이언트를 막는 일).
옵션도 데이터베이스에 저장해 꺼내 클라이언트에 줍니다. 데이터베이스는 동적으로 적재할 수 있는 객체로 구현되어 있어 서버를 쉽게 올리고 관리할 수 있습니다.
구성 파일의 정보로 데이터베이스를 준비하고 일관성을 검증합니다. 체크포인트 파일 묶음이 데이터베이스 갱신을 처리하고 주 저장 파일에 쓰는 부담을 줄입니다. 데이터베이스에는 주소와 옵션 풀도 들어 있지만 이것들은 정적이며 DHCP 구성(다음 편)에서 다룹니다.
주 저장 파일과 그 백업은 편집할 수 있는 평면 ASCII 파일입니다. 데이터베이스 주 저장 파일의 형식은 다음과 같습니다.
DF01
" CLIENT ID " " 0.0.0.0 " State LeaseTimeStart LeaseTimeDuration LeaseTimeEnd
" Server IP Address " " Class ID " " Vendor ID " " Hostname " " Domain Name "
" CLIENT ID " " 0.0.0.0 " State LeaseTimeStart LeaseTimeDuration LeaseTimeEnd
" Server IP Address " " Class ID " " Vendor ID " " Host Name " " Domain Name "
...
첫 줄은 파일의 버전 식별자 DF01c입니다. 그다음 줄들은 클라이언트 레코드 정의 줄입니다. 서버는 둘째 줄부터 파일 끝까지 읽습니다(따옴표 안의 매개변수는 따옴표로 감싸야 합니다).
| 필드 | 설명 |
|---|---|
"CLIENT ID" |
클라이언트가 서버에 자기를 나타내는 데 쓰는 ID |
"0.0.0.0" |
지금 할당된 IP 주소(원문은 DHCP 서버에 할당된 주소라고 적음). 할당된 주소가 없으면 "0.0.0.0"입니다. |
| State | 클라이언트의 현재 상태. 허용되는 상태 묶음은 DHCP 프로토콜 엔진에 있고, 상태는 DHCP 데이터베이스에서 유지합니다. 상태 옆의 숫자가 그 값입니다(아래 표). |
| LeaseTimeStart | 현재 임대의 시작(1970년 1월 1일부터 지난 초) |
| LeaseTimeDuration | 임대 기간(초) |
| LeaseTimeEnd | LeaseTimeStart와 같은 형식이며 임대의 끝을 나타냅니다. 일부 구성 옵션은 임대 시작과 끝에 다른 값을 쓰며, 이 값은 구성 파일 옵션으로 덮어쓸 수 있습니다. DHCP 서버 파일의 db_file 데이터베이스 구문을 봅니다. |
| "Server IP Address" | 이 레코드를 소유한 DHCP 서버의 IP 주소 |
| "Class ID" "Vendor ID" "Host Name" "Domain Name" | 서버가 어떤 옵션을 보낼지 정하는 데 쓰는 값(따옴표 문자열로 저장). DHCP 서버가 시작할 때 이 클라이언트들의 옵션 목록을 미리 만들 수 있어 성능이 좋아집니다. |
클라이언트 상태
| 상태 | 설명 |
|---|---|
| (1) FREE | 쓸 수 있는 주소를 나타냅니다. 보통 클라이언트는 주소가 할당되지 않았을 때만 이 상태입니다. dadmin과 lssrc 출력은 이 상태를 Free로 보고합니다. |
| (2) BOUND | 클라이언트와 주소가 묶여 있고 클라이언트가 얼마 동안 이 주소를 할당받았음을 나타냅니다. dadmin과 lssrc 출력은 Leased로 보고합니다. |
| (3) EXPIRED | 클라이언트와 주소가 묶여 있지만, 해제한 주소처럼 정보용일 뿐입니다. 다만 expired 상태는 임대를 만료되게 둔 클라이언트를 나타냅니다. 만료된 주소는 쓸 수 있으며, 빈 주소가 모두 바닥난 뒤, 해제한 주소를 다시 주기 전에 다시 할당됩니다. dadmin과 lssrc 출력은 Expired로 보고합니다. |
| (4) RELEASED | 클라이언트와 주소가 정보용으로만 묶여 있음을 나타냅니다. DHCP 프로토콜은 DHCP 서버가 나중을 위해(주로 예전에 그 주소를 받은 클라이언트에 같은 주소를 다시 주려고) 자기가 서비스한 클라이언트 정보를 유지하라고 제안합니다. 이 상태는 클라이언트가 주소를 해제했음을 나타냅니다. 다른 주소가 없으면 이 주소를 다른 클라이언트가 쓸 수 있습니다. dadmin과 lssrc 출력은 Released로 보고합니다. |
| (5) RESERVED | 클라이언트와 주소가 느슨하게 묶여 있음을 나타냅니다. 클라이언트가 DHCP discover를 보내고 DHCP 서버가 응답했지만, 클라이언트가 아직 그 주소에 대한 DHCP request로 응답하지 않았습니다. dadmin과 lssrc 출력은 Reserved로 보고합니다. |
| (6) BAD | DHCP 서버가 나눠 주지 않았는데 네트워크에서 쓰이는 주소를 나타냅니다. 클라이언트가 거부한 주소도 이 상태입니다. 클라이언트에는 해당하지 않습니다. dadmin과 lssrc 출력은 각각 Used와 Bad로 보고합니다. |
DHCP 체크포인트 파일
체크포인트 파일의 구문은 정해져 있지 않습니다.
서버가 멈추거나, 종료해야 해서 데이터베이스를 정상적으로 닫지 못하면, 서버는 체크포인트와 백업 파일을 처리해 올바른 데이터베이스를 다시 만들 수 있습니다. 서버가 멈출 때 체크포인트 파일에 쓰이던 클라이언트는 잃습니다. 기본 파일은 다음과 같습니다.
| 파일 | 쓰임 |
|---|---|
/etc/db_file.cr |
일반 데이터베이스 동작 |
/etc/db_file.crbk |
데이터베이스 백업 |
/etc/db_file.chkpt, /etc/db_file.chkpt2 |
번갈아 쓰는 체크포인트 파일 |
DHCP 서버는 스레드로 동작합니다. 높은 처리량을 유지하려고 데이터베이스 작업(저장 작업 포함)을 스레드 효율적으로 합니다. 저장을 요청하면 기존 체크포인트 파일을 다음 체크포인트 파일로 돌리고, 기존 데이터베이스 파일을 백업 파일로 복사하고, 새 저장 파일을 만듭니다. 그다음 클라이언트 레코드마다 기록하고, 그 클라이언트가 새 체크포인트 파일에 기록해야 함을 나타내는 비트를 바꿉니다. 모든 클라이언트 레코드를 기록하면 저장을 닫고 백업과 옛 체크포인트 파일을 지웁니다. 그동안에도 클라이언트를 처리할 수 있으며, 클라이언트 레코드가 저장되었는지에 따라 데이터베이스 변경이 새 저장 파일이나 새 체크포인트 파일로 갑니다.
DHCP 프로토콜 엔진
DHCP 프로토콜 엔진은 RFC 2131을 지원하며 여전히 RFC 1541과 호환됩니다(서버는 RFC 2132에 정의된 옵션도 처리할 수 있습니다). 프로토콜 엔진은 데이터베이스로 클라이언트에 어떤 정보를 돌려줄지 정합니다.
주소 풀의 구성에는 각 기계의 상태에 영향을 주는 구성 옵션이 있습니다. 예를 들어 DHCP 서버는 주소를 나눠 주기 전에 ping을 보냅니다. 서버가 응답을 기다리는 시간은 이제 주소 풀마다 구성할 수 있습니다.
DHCP 스레드 작업
DHCP 서버의 마지막 부분은 서버가 계속 돌아가게 하는 작업 묶음입니다. DHCP 서버는 스레드로 동작하므로, 이 작업들은 가끔 일을 해서 모든 것이 맞게 돌아가게 하는 스레드로 설정되어 있습니다.
첫 번째 스레드인 main 스레드는 SRC 요청(startsrc, stopsrc, lssrc, traceson, refresh 등)을 처리합니다. 이 스레드는 모든 스레드에 영향을 주는 작업을 조정하고 신호를 처리합니다. 예를 들면 다음과 같습니다.
- SIGHUP(-1)은 구성 파일의 모든 데이터베이스를 새로 고칩니다.
- SIGTERM(-15)은 서버를 정상적으로 멈춥니다.
다음 스레드인 dadmin 스레드는 dadmin 클라이언트 프로그램과 DHCP 서버 사이를 잇습니다. dadmin 도구로 상태를 얻고, 데이터베이스 파일을 손으로 편집하지 않고 데이터베이스를 고칠 수 있습니다. 이전 버전의 DHCP 서버는 상태 요청이 실행 중이면 어떤 클라이언트도 주소를 얻지 못했습니다. dadmin과 src 스레드가 더해져 서버는 서비스 요청을 처리하면서도 클라이언트 요청을 처리할 수 있습니다.
다음 스레드는 garbage 스레드로, 주기적으로 데이터베이스를 정리하고, 데이터베이스를 저장하고, 주소가 없는 클라이언트를 없애고, 너무 오래 예약 상태에 있는 예약 주소를 지우는 타이머를 실행합니다. 이 타이머들은 모두 구성할 수 있습니다(DHCP 구성 참고). 나머지 스레드는 패킷 처리기입니다. 그 수는 구성할 수 있으며 기본은 10입니다. 각 패킷 처리기는 DHCP 클라이언트의 요청 하나를 처리할 수 있습니다. 필요한 패킷 처리기 수는 부하와 기계에 따라 어느 정도 다릅니다. 기계를 DHCP 말고 다른 서비스에도 쓴다면 스레드 500개를 띄우는 것은 현명하지 않습니다.
영어 원문
DHCP servers
In the AIX operating system, the DHCP server has been segmented into three main pieces.
The main components of the DHCP server are a database, a protocol engine, and a set of service threads, each with its own configuration information.
DHCP database
The db_file.dhcpo database is used to track clients and addresses and for access control (for example, allowing certain clients on some networks but not others, or disabling BOOTP clients on a particular network).
Options are also stored in the database for retrieval and delivery to clients. The database is implemented as a dynamically loadable object, which allows for easy server upgrade and maintenance.
Using the information in the configuration file, the database is primed and verified for consistency. A set of checkpoint files handles updates to the database and reduces the overhead of writes to the main storage file. The database also contains the address and option pools, but these are static and are discussed in DHCP configuration.
The main storage file and its back up are flat ASCII files that can be edited. The format for the database main storage files are:
DF01
" CLIENT ID " " 0.0.0.0 " State LeaseTimeStart LeaseTimeDuration LeaseTimeEnd
" Server IP Address " " Class ID " " Vendor ID " " Hostname " " Domain Name "
" CLIENT ID " " 0.0.0.0 " State LeaseTimeStart LeaseTimeDuration LeaseTimeEnd
" Server IP Address " " Class ID " " Vendor ID " " Host Name " " Domain Name "
...
The first line is a version identifier for the file: DF01c. The lines that follow are client record definition lines. The server reads from the second line to the end of the file. (The parameters in quotes must be enclosed in quotes.)
"CLIENT ID" The ID the client uses to represent itself to the server. "0.0.0.0" is the IP address currently assigned to the DHCP server. If no address has been assigned, it is "0.0.0.0".
State The current state of the client. The DHCP protocol engine contains the allowable set, and the states are maintained in the DHCP database. The number next to State represents its value. The states can be:
(1) FREE
Represents addresses that are available for use. In general, clients do not have this state unless they have no address assigned. dadmin and the output from lssrc report this state as Free.
(2) BOUND
Indicates client and address are tied and that the client has been assigned this address for some amount of time. dadmin and the output from lssrc report this state as Leased.
(3) EXPIRED
Indicates the client and address are tied together, but only for informational purposes, in a similar manner to released addresses. The expired state, however, represents clients that let their leases expire. An expired address is available for use and is reassigned after all free addresses are unavailable and before released addresses are reassigned. dadmin and the output from lssrc report this state as Expired.
(4) RELEASED
Indicates the client and address are tied for informational purposes only. The DHCP protocol suggests that DHCP servers maintain information about the clients it has served for future reference (mainly to try giving the same address to that client that has been assigned that address in the past). This state indicates that the client has released the address. The address is available for use by other clients, if no other addresses are available. dadmin and the output from lssrc report this as Released.
(5) RESERVED
Indicates client and address are tied, but loosely. The client has issued a DHCP discover message and the DHCP server has responded, but the client has not yet responded with a DHCP request for that address. dadmin and the output from lssrc report this state as Reserved.
(6) BAD
Represents an address that is in use in the network but has not been handed out by the DHCP server. This state also represents addresses that clients have rejected. This state does not apply to clients. dadmin and the output from lssrc report this state as Used and Bad, respectively.
LeaseTimeStart Is the start of the current lease time (in the number of seconds since January 1, 1970).
LeaseTimeDuration Represents the duration of the lease (in seconds).
LeaseTimeEnd Uses the same format as LeaseTimeStart, but it represents the end of the lease. Some configuration options use different values for the start and end of a lease and these values can be overridden by configuration file options. See DHCP server file syntax for db_file database.
"Server IP Address"
Is the IP address of the DHCP server that owns this record.
"Class ID" "Vendor ID" "Host Name" "Domain Name"
Values that the server uses to determine which options are sent to the server (stored as quoted strings). These parameters increase performance because option lists can be pregenerated for these clients when the DHCP server starts up.
DHCP checkpoint files:
The syntax for the checkpoint files is not specified.
If the server crashes or you have to shut down and cannot do a normal closing of the database, the server can process the checkpoint and backup files to reconstruct a valid database. The client that is being written to the checkpoint file when the server crashes is lost. The default files are: /etc/db_file.cr normal database operation /etc/db_file.crbk backups for the database /etc/db_file.chkpt and /etc/db_file.chkpt2 rotating checkpoint files
The DHCP server is threaded. To maintain high throughput, database operations (including save operations) are thread-efficient. When a save is requested, the existing checkpoint file is rotated to the next checkpoint file, the existing database file is copied to the backup file, and the new save file is created. Each client record is then logged and a bit is toggled to indicate that the client should use the new checkpoint file for logging. When all client records are recorded, the save is closed, and the backup and old checkpoint files are deleted. Clients can still be processed and, depending on whether the client record has been saved, database changes go into a new save file or to a new checkpoint file.
The DHCP protocol engine
The DHCP protocol engine supports RFC 2131 and is still compatible with RFC 1541. (The server can also process options as defined in RFC 2132.) The protocol engine uses the database to determine what information is returned to the client.
The configuration of the address pools have some configuration options that affect the state of each machine. For example, the DHCP server pings addresses before it hands them out. The amount of time the server waits for a response is now configurable for each address pool.
DHCP threaded operations
The last piece of the DHCP server is actually a set of operations that are used to keep things running. Because the DHCP server is threaded, these operations are actually set up as threads that occasionally do things to make sure everything is together.
The first thread, the main thread, handles the SRC requests (such as startsrc, stopsrc, lssrc, traceson, and refresh). This thread also coordinates all operations that affect all threads and handles signals. For example,
A SIGHUP (-1) causes a refresh of all databases in the configuration file.
A SIGTERM (-15) will cause the server to gracefully stop.
The next thread, the dadmin thread, interfaces with dadmin client program and the DHCP server. The dadmin tool can be used to get status as well as modify the database to avoid editing the database files manually. Previous versions of the DHCP server prevented any clients from getting addresses if a status request was running. With the addition of the dadmin and src threads, the server can handle service requests and still handle client requests.
The next thread is the garbage thread, which runs timers that periodically clean the database, save the database, purge clients that do not have addresses, and remove reserved addresses that have been in reserve state for too long. All these timers are configurable (see “DHCP configuration”). The other threads are packet processors. The number of these is configurable; the default is 10. Each of these can handle a request from a DHCP client. The number of packet processors required is somewhat load- and machine-dependent. If the machine is used for other services than DHCP, it is not wise to start up 500 threads.