Create: 2014/09/30
LastUpdate: 2014/10/01
≪ メニューに戻るLastUpdate: 2014/10/01
CentOS6.5 + Samba4 でActiveDeretoryのドメインコントローラ(DC)を構築してみました。
手順は、以下のサイトを参考にしました。
ActiveDiretory サーバの構成情報は以下のとおり。
- OS: CentOS6.5
- ホスト名: samba.blue21.local
- IPアドレス: 192.168.1.85
- DNSドメイン: blue21.local
- ActiveDirectoryドメイン: BLUE21
1.時刻同期の設定
ActiveDirectory のドメインコントローラで認証を行う場合、サーバとクライアントで時刻がずれていると、認証に失敗します。
サーバ側を ntp で時刻同期します。
yum で ntp パッケージをインストールします。
# yum -y install ntpインターネット上の NTPサーバ(ntp.nict.jp)と時刻同期するように /etc/ntp.conf を修正します。
# For more information about this file, see the man pages # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. #restrict default kod nomodify notrap nopeer noquery #restrict -6 default kod nomodify notrap nopeer noquery restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict -6 ::1 # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server ntp.nict.jp #broadcast 192.168.1.255 autokey # broadcast server #broadcastclient # broadcast client #broadcast 224.0.1.1 autokey # multicast server #multicastclient 224.0.1.1 # multicast client #manycastserver 239.255.254.254 # manycast server #manycastclient 239.255.254.254 autokey # manycast client # Enable public key cryptography. #crypto includefile /etc/ntp/crypto/pw # Key file containing the keys and key identifiers used when operating # with symmetric key cryptography. keys /etc/ntp/keys # Specify the key identifiers which are trusted. #trustedkey 4 8 42 # Specify the key identifier to use with the ntpdc utility. #requestkey 8 # Specify the key identifier to use with the ntpq utility. #controlkey 8 # Enable writing of statistics records. #statistics clockstats cryptostats loopstats peerstatsntp を起動し、自動起動 を ON にします。
# service ntpd start # chkconfig ntpd on1回、ntpdate を使って手動で時刻合わせをし、 ntpq で 同期状態を確認します。
# ntpdate -b -s ntp.nict.jp # ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *ntp-b3.nict.go. .NICT. 1 u 13 64 1 8.600 0.308 0.002
2.samba のインストール
今回は、必要なものを全て、yum でインストールします。
まず、epel レポジトリを追加します。
# yum -y install http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/i386/epel-release-6-8.noarch.rpm/etc/yum.repo.d/epel.repo を修正します。
[epel] の enabled を 1 にして、デフォルトで epel レポジトリを有効にします。
vi /etc/yum.repos.d/epel.reposamba は、wing-repo を利用して yum でインストールします。
wing-repo は個人が自宅サーバで運営しているレポジトリのようです。
以下の内容でyum のレポジトリを追加します。
- [ファイル名] /etc/yum.repos.d/EL6.wing.repo
[wing] name=EL $releasever - $basearch - wing Repository baseurl=http://wing-repo.net/wing/$releasever/$basearch/ enabled=1 gpgcheck=0 priority=2 [wing-source] name=EL $releasever - $basearch - wing source Repository baseurl=http://wing-repo.net/wing/$releasever/SRPMS/ enabled=1 gpgcheck=0 priority=2以下のようにして samba4 をインストールします。
# yum -y install samba4 samba4-client ldb-tools krb5-workstationインストールされた samba4 のバージョンは以下のとおり。
# rpm -aq | grep samba samba4-python-4.0.22-1.el6_23.wing.i686 samba4-libs-4.0.22-1.el6_23.wing.i686 samba4-dc-libs-4.0.22-1.el6_23.wing.i686 samba4-client-4.0.22-1.el6_23.wing.i686 samba4-dc-4.0.22-1.el6_23.wing.i686 samba4-common-4.0.22-1.el6_23.wing.i686 samba4-4.0.22-1.el6_23.wing.i686
3.samba の初期設定
DCの新規ドメインとしてセットアップします。
以下のように samba-tool コマンドを実行します。
samba4 は、DNS を内蔵しています。[DNS backend] では、samba4 のDNSを使うように設定します。
samba4のDNSで名前解決できなかった場合、[DNS Forwarder IP address] に指定したDNSサーバで名前解決を行います。
DNSフォワードが不要であれば "none" と入力します。
# samba-tool domain provision Realm: blue21.local [ENTER] Domain [blue21]: [ENTER] Server Role (dc, member, standalone) [dc]: [ENTER] DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: [ENTER] DNS forwarder IP address (write 'none' to disable forwarding) [192.168.1.xxx]: 192.168.1.xxx Administrator password: パスワード [ENTER] Retype password: パスワード [ENTER] Looking up IPv4 addresses Looking up IPv6 addresses 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=blue21,DC=local Adding configuration container Setting up sam.ldb schema Setting up sam.ldb configuration data Setting up display specifiers Modifying 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=blue21,DC=local Creating DomainDnsZones and ForestDnsZones partitions Populating DomainDnsZones and ForestDnsZones partitions Setting up sam.ldb rootDSE marking as synchronized Fixing provision GUIDs A Kerberos configuration suitable for Samba 4 has been generated at /var/lib/samba/private/krb5.conf Once the above files are installed, your Samba4 server will be ready to use Server Role: active directory domain controller Hostname: samba NetBIOS Domain: BLUE21 DNS Domain: blue21.local DOMAIN SID: S-1-5-21-3642782196-885023004-4129973541samba の設定ファイル(/etc/samba/smb.conf) を以下のように修正します。
[global] の printing は、samba 起動時に CUPS のエラーがでないようにします。
[profiles] は、 「移動プロファイル」機能を試したいので、データを格納する場所を定義しています。移動プロファイルの設定は、「 [CentOS6][samba4] Windows の RSAT から samba4 の Activedirectory を管理する」で行います。
# Global parameters [global] workgroup = BLUE21 realm = BLUE21.LOCAL netbios name = SAMBA server role = active directory domain controller dns forwarder = 192.168.1.xxx printing = bsd [netlogon] path = /var/lib/samba/sysvol/blue21.local/scripts read only = No [sysvol] path = /var/lib/samba/sysvol read only = No [profiles] path = /var/lib/samba/profiles blowseble = no read only = no移動プロファイル用のディレクトリを作成します。
# mkdir -p /var/lib/samba/profiles # chmod 1777 /var/lib/samba/profilesActiveDirectory が利用する Kerberos認証の設定ファイル(/etc/krb5.conf) を以下のように修正します。
[logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = BLUE21.LOCAL dns_lookup_realm = false dns_lookup_kdc = true ticket_lifetime = 24h renew_lifetime = 7d forwardable = true [realms] BLUE21.LOCAL = { kdc = samba.blue21.local } [domain_realm] .example.com = BLUE21.LOCAL example.com = BLUE21.LOCALActiveDirectory にするサーバをDNS登録していないので、hosts に登録しておきます。
以下のように /etc/hosts を修正します。
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.85 samba.blue21.local
samba を起動して、自動起動を ON にします。# service samba start # chkconfig samba onKerberos 認証が成功するか確認します。
以下のように、administrator ユーザでログインしてみます。
# kinit administrator@BLUE21.LOCAL Password for administrator@BLUE21.LOCAL: Warning: Your password will expire in 41 days on Tue Nov 11 10:37:19 2014ログインに成功すれば、以下のように Kerberosチケットを確認できます。
# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: administrator@BLUE21.LOCAL Valid starting Expires Service principal 09/30/14 10:43:59 09/30/14 20:43:59 krbtgt/BLUE21.LOCAL@BLUE21.LOCAL renew until 10/07/14 10:43:51 [root@samba ~]# samba-tool dns query 127.0.0.1 blue21.local @ A -U administrator Password for [BLUE21\administrator]: Name=, Records=1, Children=0 A: 192.168.1.85 (flags=600000f0, serial=1, ttl=900) Name=_msdcs, Records=0, Children=0 Name=_sites, Records=0, Children=1 Name=_tcp, Records=0, Children=4 Name=_udp, Records=0, Children=2 Name=DomainDnsZones, Records=0, Children=2 Name=ForestDnsZones, Records=0, Children=2 Name=samba, Records=1, Children=0 A: 192.168.1.85 (flags=f0, serial=1, ttl=900)
4.機能レベルの変更
ActiveDirectory の機能レベルを確認すると、以下のとおり。
"Windows2003" です。
# samba-tool domain level show Domain and forest function level for domain 'DC=blue21,DC=local' Forest function level: (Windows) 2003 Domain function level: (Windows) 2003 Lowest function level of a DC: (Windows) 2008 R2機能レベルを "Windows 2008 R2" に変更して、確認します。
# samba-tool domain level raise --domain-level 2008_R2 --forest-level 2008_R2 Domain function level changed! Forest function level changed! All changes applied successfully! # samba-tool domain level show Domain and forest function level for domain 'DC=blue21,DC=local' Forest function level: (Windows) 2008 R2 Domain function level: (Windows) 2008 R2 Lowest function level of a DC: (Windows) 2008 R2
5.ユーザ追加
テスト用に一般ユーザ(test_user01)を追加します。
以下のように samba-tool コマンドを実行します。
# samba-tool user add test_user01 New Password: [パスワード][ENTER] Retype Password: [パスワード][ENTER] User 'test_user01' created successfully