目次
文書の過去の版を表示しています。
SambaによるActiveDirectory構築
リポジトリの設定
Fedora 19でSamba AD DCを有効化したパッケージの作成方法は、Samba AD DCパッケージの再構築を参照。
パッケージ作成が面倒という方は、以下のリポジトリからインストールできます。
$ sudo vi /etc/yum.repos.d/mgc.repo
[mgc] name=Fedora $releasever - $basearch Monster's Garage Repository failovermethod=priority baseurl=http://monsters-g.com/pub/fedora/$releasever/$basearch/ enabled=0 gpgcheck=0 priority=2 [mgc-source] name=Fedora $releasever - $basearch Monster's Garage Source Repository failovermethod=priority baseurl=http://monsters-g.com/pub/fedora/$releasever/SRPMS/ enabled=0 gpgcheck=0 priority=2
※内容や保守の保障はありませんのでご了承ください。要望が多い場合は検討します。
※x86_64版のみの配布となります。
パッケージインストール
$ sudo yum install samba samba-dc samba-client --enablerepo=mgc
CUPSプリントサーバーを利用する場合
$ sudo yum install cups
samba-toolを動作させるのに必要(BIND9_DLZ時)
$ sudo yum install tdb-tools
killallをインストール
$ sudo yum install psmisc
kinitをインストール
$ sudo yum install krb5-workstation
Sambaの設定
設定ファイルのバックアップ
$ sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.org
または
$ sudo rm /etc/samba/smb.conf
※smb.confを移動 or 削除しないとsamba-toolで下記のエラーが発生する。
設定ファイルの作成
$ sudo rm /etc/samba/smb.conf
※再設定を行う場合はsmb.confを削除してから行う。
$ sudo samba-tool domain provision --use-rfc2307 --interactive
Realm [FIREBALL.LOCAL]: <- Enterを入力 Domain [FIREBALL]: <- 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.254]: 202.224.32.1 <- プロバイダDNSサーバーのIPを入力 Administrator password: <- パスワードを入力(英数記号の組み合わせで7文字以上) Retype password: <- 確認用パスワードを入力 Looking up IPv4 addresses Looking up IPv6 addresses No IPv6 address will be assigned 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=fireball,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=fireball,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 Setting up fake yp server settings Once the above files are installed, your Samba4 server will be ready to use Server Role: active directory domain controller Hostname: blue-dc NetBIOS Domain: FIREBALL DNS Domain: fireball.local DOMAIN SID: S-1-5-21-450207414-3644643225-592770093
bindの設定(SAMBA_INTERNALの場合は不要)
Sambaの設定を追加
$ sudo vi /etc/named.conf
options { ... tkey-gssapi-keytab "/var/lib/samba/private/dns.keytab"; ... }; include "/var/lib/samba/private/named.conf";
dlzの設定
Fedora 19ではbind-9.9.3なので、9.9用の設定に修正する。(標準では9.8用に設定されている)
※再設定を行う場合は修正し直す必要がある。
$ sudo vi /var/lib/samba/private/named.conf
# # This configures dynamically loadable zones (DLZ) from AD schema # Uncomment only single database line, depending on your BIND version # dlz "AD DNS Zone" { # For BIND 9.8.0 # database "dlopen /usr/lib64/samba/bind9/dlz_bind9.so"; # For BIND 9.9.0 database "dlopen /usr/lib64/samba/bind9/dlz_bind9_9.so"; };
パーミッション設定
bindによる設定ファイルの読み込みを許可する。
$ sudo chgrp named /var/lib/samba/private $ sudo chmod 750 /var/lib/samba/private
※これを忘れるとbindが起動しないので注意!!
※Sambaパッケージをアップデート後にも必要!!
設定の反映
bindを再起動する。
$ sudo systemctl restart named.service
Kerberosクライアントのデフォルト設定
設定ファイルのバックアップ
$ sudo cp /etc/krb5.conf /etc/krb5.conf.org
設定ファイルの編集
$ sudo vi /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 = FIREBALL.LOCAL <- dns_lookup_realm = false <- 追記 dns_lookup_kdc = true <- ticket_lifetime = 24h renew_lifetime = 7d forwardable = true rdns = false [realms] # EXAMPLE.COM = { # kdc = kerberos.example.com # admin_server = kerberos.example.com # } FIREBALL.LOCAL = { <- kdc = blue-dc.fireball.local <- 追記 } <- [domain_realm] # .example.com = EXAMPLE.COM # example.com = EXAMPLE.COM .fireball.local = FIREBALL.LOCAL <- 追記 fireball.local = FIREBALL.LOCAL <-
Samba AD DCの起動確認
$ sudo samba -i -M single --debuglevel=3 samba version 4.1.0 started. Copyright Andrew Tridgell and the Samba Team 1992-2013 samba: using 'single' process model
サービス定義ファイルの作成
$ sudo vi /lib/systemd/system/samba.service
[Unit] Description=Samba Active Directory Domain Controller Daemon After=syslog.target network.target named.service [Service] Type=forking PIDFile=/run/samba.pid LimitNOFILE=16384 EnvironmentFile=-/etc/sysconfig/samba ExecStart=/usr/sbin/samba $SAMBAOPTIONS ExecReload=/usr/bin/kill -HUP $MAINPID ExecStop=/usr/bin/killall samba [Install] WantedBy=multi-user.target
サービス自動起動設定
$ sudo systemctl enable samba.service
サービス起動
$ sudo systemctl start samba.service
ファイヤーウォールの設定
$ sudo firewall-cmd --permanent --add-service=kerberos $ sudo firewall-cmd --permanent --add-service=kpasswd $ sudo firewall-cmd --permanent --add-service=samba $ sudo firewall-cmd --permanent --add-service=ldap $ sudo firewall-cmd --permanent --add-service=ldaps $ sudo firewall-cmd --permanent --add-port=1024-65535/tcp $ sudo firewall-cmd --permanent --add-port=3268/tcp $ sudo firewall-cmd --permanent --add-port=3269/tcp $ sudo firewall-cmd --reload
Samba AD DCの動作確認
サービス起動確認
スタンダードプロセスモードで起動していることを確認する。
$ sudo systemctl status samba.service
samba.service - Samba Active Directory Domain Controller Daemon Loaded: loaded (/usr/lib/systemd/system/samba.service; enabled) Active: active (running) since 水 2013-10-09 04:27:15 JST; 2min 52s ago Process: 1071 ExecStart=/usr/sbin/samba $SAMBAOPTIONS (code=exited, status=0/SUCCESS) Main PID: 1141 (samba) CGroup: name=systemd:/system/samba.service ├─1141 /usr/sbin/samba ├─1144 /usr/sbin/samba ├─1145 /usr/sbin/samba ├─1146 /usr/sbin/samba ├─1147 /usr/sbin/samba ├─1148 /usr/sbin/samba ├─1149 /usr/sbin/samba ├─1150 /usr/sbin/smbd --option=server role check:inhibit=yes --foreground ├─1151 /usr/sbin/samba ├─1152 /usr/sbin/samba ├─1153 /usr/sbin/samba ├─1154 /usr/sbin/samba ├─1155 /usr/sbin/samba ├─1156 /usr/sbin/samba └─1159 /usr/sbin/smbd --option=server role check:inhibit=yes --foreground
ActiveDirectoryに必要な共有を提供しているか確認
$ smbclient -L localhost -U%
Domain=[FIREBALL] OS=[Unix] Server=[Samba 4.1.0] Sharename Type Comment --------- ---- ------- netlogon Disk sysvol Disk IPC$ IPC IPC Service (Samba 4.1.0) Domain=[FIREBALL] OS=[Unix] Server=[Samba 4.0.9] Server Comment --------- ------- Workgroup Master --------- -------
認証の確認
$ smbclient //localhost/netlogon -U Administrator -c 'ls'
Enter Administrator's password: Domain=[FIREBALL] OS=[Unix] Server=[Samba 4.1.0] . D 0 Tue Oct 8 23:33:08 2013 .. D 0 Tue Oct 8 23:33:12 2013 63813 blocks of size 4194304. 59979 blocks available
DNSの動作確認
$ host -t SRV _ldap._tcp.fireball.local
_ldap._tcp.fireball.local has SRV record 0 100 389 blue-dc.fireball.local.
$ host -t SRV _kerberos._udp.fireball.local
_kerberos._udp.fireball.local has SRV record 0 100 88 blue-dc.fireball.local.
$ host -t A blue-dc.fireball.local
blue-dc.fireball.local has address 172.16.78.10
※hostコマンドはbind-utilsパッケージに含まれている。
Kerberosの動作確認
$ kinit administrator@FIREBALL.LOCAL Password for administrator@FIREBALL.LOCAL: <- パスワードを入力 Warning: Your password will expire in 41 days on 2013年11月20日 01時23分51秒