2012年10月19日金曜日

Samba4 RC3をDCとしてセットアップ

環境

CentOS6.3環境にSamba4をAD DCとしてセットアップする手順をまとめる。

SNTP対応xntpdの設定


CentOS6のxntpdは、sntpに対応していないため、CentOS6のxntpdパッケージをもとに、xntpd-4.2.6をsntp対応のxntpdパッケージとして再ビルドする。

パッケージングの手順は省略...

作成したxntpのパッケージをインストールする。
# rpm -Uhv ntp*rpm

/etc/ntp.confに以下を追加

server 127.127.1.1
fudge 127.127.1.1  stratum 12
ntpsigndsocket /var/run/ntp_signd/
restrict default mssntp

ntpdを再起動
# /sbin/service ntpd restart

Bind9.8のインストール

DLZに対応したbind-9.8.3-P2パッケージをインストール
  • bind-9.8.3-P2.el6.x86_64.rpm
  • bind-libs-9.8.3-P2.el6.x86_64.rpm
  • bind-license-9.8.3-P2.el6.noarch.rpm
  • bind-utils-9.8.3-P2.el6.x86_64.rpm

Samba4のセットアップ

samba4パッケージに必要な次のパッケージをインストール

# yum install xinetd  

最初にsamba3パッケージ関連を削除

# rpm -e samba-client samba-common samba-winbind-clients libsmbclient --nodeps

samba4パッケージ一式をインストール。

Samba4のprovisioning


# /usr/bin/samba-tool domain provision
Realm [EXAMPLE.COM]: 
Domain [EXAMPLE]: 
Server Role (dc, member, standalone) [dc]: 
DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: BIND9_DLZ
Administrator password: 
Retype password: 
Looking up IPv4 addresses
More than one IPv4 address found. Using 192.168.2.8
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up share.ldb
Setting up secrets.ldb
Setting up the registry
Setting up the privileges database
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
Adding DomainDN: DC=example,DC=com
Adding configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up well known security principals
Setting up sam.ldb users and groups
Setting up self join
Adding DNS accounts
Creating CN=MicrosoftDNS,CN=System,DC=example,DC=com
Creating DomainDnsZones and ForestDnsZones partitions
Populating DomainDnsZones and ForestDnsZones partitions
See /etc/samba/named.conf for an example configuration include file for BIND
and /etc/samba/named.txt for further documentation required for secure DNS updates
Setting up sam.ldb rootDSE marking as synchronized
Fixing provision GUIDs
A Kerberos configuration suitable for Samba 4 has been generated at /etc/samba/krb5.conf
Once the above files are installed, your Samba4 server will be ready to use
Server Role:           active directory domain controller
Hostname:              samba4
NetBIOS Domain:        EXAMPLE
DNS Domain:            example.com
DOMAIN SID:            S-1-5-21-858491299-1320590862-3958657269
A phpLDAPadmin configuration file suitable for administering the Samba 4 LDAP server has been created in /etc/samba/phpldapadmin-config.php.

Bindの設定

/etc/samba/named.txtに記載されている設定などをDNSに行う。

DLZ機能を利用可能とするための設定を /etc/named.confに追加する。
include "/etc/samba/named.conf";

Bind9.8.3を利用しているので、 /etc/named.confのoptionsセクションに、以下の設定を追加。

tkey-gssapi-keytab "/etc/samba/dns.keytab";

namedがファイルを読み込めるように、次のコマンドを実行

# chgrp named /etc/samba/dns.keytab
# chmod g+r /etc/samba/dns.keytab


namedが127.0.0.1以外のインターフェースもLISTENする用に、次の設定を /etc/named.confから削除
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };

namedを再起動
# /sbin/service named start

/var/log/messagesに次のように、DLZドライバの読み込みが行われている。

Oct 19 21:03:09 samba4 named[27126]: Loading 'AD DNS Zone' using driver dlopen
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: started for DN DC=example,DC=com
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: starting configure
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: configured writeable zone 'example.com'
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: configured writeable zone '_msdcs.example.com'

samba4を起動

sambaサービスを起動する。

# /sbin/service samba start

確認のため、別サーバーからアクセスしてみる。

$ smbclient -L samba4
Enter yasuma's password: 
Anonymous login successful
Domain=[EXAMPLE] OS=[Unix] Server=[Samba 4.0.0rc3]

Sharename       Type      Comment
---------       ----      -------
netlogon        Disk      
sysvol          Disk      
IPC$            IPC       IPC Service (Samba 4.0.0rc3)
Anonymous login successful
Domain=[EXAMPLE] OS=[Unix] Server=[Samba 4.0.0rc3]

Server               Comment
---------            -------

Workgroup            Master
---------            -------

DNSの確認のため、SRVレコードを確認してみる。

# dig @127.0.0.1 _ldap._tcp.example.com SRV

/etc/resolv.confを次の設定に変更する。

domain example.com
nameserver 192.168.2.8 (DCのIPアドレス)

Kerberosの設定

provisioning時に作成された/etc/samba/krb5.confをOSの/etc/krb5.confにコピーする。

# cp /etc/samba/krb5.conf /etc/krb5.conf

Kerberosの設定が正しいか次のコマンドで確認する。
  • レルム(EXAMPLE.COM)の部分は、大文字
  • パスワードはsamba4のprovisioning時に設定したものを入力する。

# kinit administrator@EXAMPLE.COM
Password for administrator@EXAMPLE.COM: 
Warning: Your password will expire in 41 days on Fri Nov 30 20:52:00 2012

正常にチケットが取得できていれば、次のklistコマンドでチケットが表示される。
# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: administrator@EXAMPLE.COM

Valid starting     Expires            Service principal
10/19/12 21:17:22  10/20/12 07:17:22  krbtgt/EXAMPLE.COM@EXAMPLE.COM
renew until 10/20/12 21:17:18

DNSの動的更新の確認

DNSのTSIG/GSSを利用した動的更新が動作することを確認するため、次のコマンドを実行して、正常にDNSの更新が行われることを確認する。

# /usr/sbin/samba_dnsupdate --verbose --all-names 
IPs: ['fe80::a00:27ff:fe8d:c1f0%eth1', 'fe80::a00:27ff:fea2:fee8%eth0', '192.168.2.8', '10.0.2.15']
Calling nsupdate for A example.com 192.168.2.8
Outgoing update query:

以上で、Samba4が正常にドメインコントローラーとしてセットアップ完了しているはず。

Samba4に必要なパッケージ

Bind 9.8以降(DLZ対応)

http://wiki.samba.org/index.php/Samba4/HOWTO#Step_7:_Configure_DNS

SNTP対応xntpd

MS-SNTP対応が必要とのこと。
http://www.whitemiceconsulting.com/2010/12/configuration-of-ntp-for-samba4.html

パッケージを用意する方法はこちら。
http://wiki.samba.org/index.php/Samba4/HOWTO#Step_10:_Configure_NTP_.28Optional.29