samba-4.2がリリースされた。
本家様 https://wiki.samba.org/index.php/Main_Page

samba-4.2は、旧来と同様にwindowsファイル共有機能を提供する他
ActiveDirectoryドメインコントローラの機能を持つことができる。
注意:samba-4.xだからADの構築が必要という訳ではない。従来のファイル共有機能のみの利用もできます。

ここではCentOS 7 に samba-4.2.xをインストールして

について記したいと思う
*samba-4.2.xへの更新samba42/update

方針

まだCentOS 7 向けのsamba4-dcパッケージがリリースされていないので、コンパイルして用意します。
ActiveDirectoryのドメイン名は sybyl.local として、c.sybyl.localActiveDirectoryドメインコントローラとする。
またこのサーバは、chaperone.jpのDNS機能も持つ。
2015y03m01d_092055334.png
*シングルドメインで構築なら、こちらを参考にsamba42/DNSbackend

下準備

CentOS 7 を最小構成で構築後、開発環境をインストール

[root@c ~]# yum groupinstall development

加えてsambaのコンパイルに必要なパッケージをインストールしますsamba42/install_packages
sybyl.localchaperone.jp向けのDNSも事前に構築しますbind
ActiveDirectoryドメインコントローラとなるc.sybyl.localの/etc/hostsファイルは下記の様に調整します

[root@c ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain
192.168.0.3 c.sybyl.local  c
192.168.0.3 c.chaperone.jp c
[root@c ~]#

またCentOS 7ではNetworkManagerが基本なので /etc/resolv.conf は直接編集せず、nmtui画面でresolv.confを調整します
2015y03m01d_094627334.png
再起動、もしくはNetworkManagerを再起動して調整を反映させる。再起動後の/etc/resolv.confは下記になります

[root@c ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search sybyl.local chaperone.jp
nameserver 192.168.0.3
nameserver 192.168.0.1
[root@c ~]#

Step 1: Download Samba

ソースを取得します。

[root@c ~]# mkdir -p /opt/src && cd /opt/src
[root@c src]# wget https://download.samba.org/pub/samba/stable/samba-4.2.0.tar.gz

*RC版(Release Candidate)です。production releaseではありません

Step 2: Compile Samba

[root@c src]# gzip -cd samba-4.2.0.tar.gz | tar xf - && cd samba-4.2.0
[root@c samba-4.2.0]# export PATH=/bin:/usr/bin:/usr/sbin:/sbin
[root@c samba-4.2.0]# ./configure  --prefix=/opt/samba --enable-selftest --with-utmp --with-ads \
                                      --with-systemd
[root@c samba-4.2.0]# time ( make -j3 ; make quicktest ) | tee -a make.log
(略)
FAILED (2 failures, 0 errors and 0 unexpected successes in 2 testsuites)
(略)

*FreeIPAと連携するなら--with-system-mitkrb5が必要みたい。CentOS 7のsystemctl対応に--with-systemdを付与
samba3.base.attr(plugin_s4_dc)samba3.base.chkpath(plugin_s4_dc)でエラーが発生するがそのまま継続

Step 3: Install Samba

[root@c samba-4.2.0]# make install
[root@c samba-4.2.0]# ( cd /lib64 ; ln -s /opt/samba/lib/libnss_* .)
[root@c samba-4.2.0]# ( cd /lib64/security ; ln -s /opt/samba/lib/security/* . )

あと、yum install/updateでsamba関係がインストールされないように /etc/yum.conf を調整する
パスの影響は無視して、ファイル名が被るものは

/lib64/security/pam_smbpass.so   --> samba-common
/lib64/libnss_winbind.so.2       --> samba-winbind-clients
/lib64/libnss_wins.so.2          --> samba-winbind-clients
/lib64/security/pam_winbind.so   --> samba-winbind-clients

なので、基本 samba-common と samba-winbind-clients をyum updateの際に適用されないようにする

[root@c ~]# vi /etc/yum.conf
[main]
   exclude=samba-common samba-winbind-clients
[root@c ~]#

Step 4: Provision Samba

BIND DNSとの連携との連携はBIND9_DLZ形式を採用します。
*samba内蔵のDNSを使用するなら、samba42/DNSbackend参照

[root@c ~]# /opt/samba/bin/samba-tool domain provision --use-rfc2307 --interactive
Realm [SYBYL.LOCAL]:
 Domain [SYBYL]:
 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
(中略)
A Kerberos configuration suitable for Samba 4 has been generated at /opt/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:              c
NetBIOS Domain:        SYBYL
DNS Domain:            sybyl.local
DOMAIN SID:            S-1-5-21-2967541039-1109231915-279230396
 
[root@c ~]#

*他の引数はsamba-tool domain provision --help を参照
再度provisionを行うなら、設定ファイルらを予め削除してから行う事

[root@c ~]# rm -rf /opt/samba/private/*
[root@c ~]# rm -rf /opt/samba/etc/smb.conf

Step 5: Starting Samba

シングルモードでテスト実行を行う

[root@c ~]# /opt/samba/sbin/samba -i -M single
samba version 4.2.0 started.
Copyright Andrew Tridgell and the Samba Team 1992-2014
samba: using 'single' process model
Attempting to autogenerate TLS self-signed keys for https for hostname 'C.sybyl.local'
TLS self-signed keys generated OK
/opt/samba/sbin/samba_dnsupdate: Traceback (most recent call last):
/opt/samba/sbin/samba_dnsupdate:   File "/opt/samba/sbin/samba_dnsupdate", line 615, in <module>
/opt/samba/sbin/samba_dnsupdate:     get_credentials(lp)
/opt/samba/sbin/samba_dnsupdate:   File "/opt/samba/sbin/samba_dnsupdate", line 126, in get_credentials
/opt/samba/sbin/samba_dnsupdate:     raise e
/opt/samba/sbin/samba_dnsupdate: RuntimeError: kinit for C$@SYBYL.LOCAL failed (Cannot contact any KDC (略
/opt/samba/sbin/samba_dnsupdate:
../source4/dsdb/dns/dns_update.c:294: Failed DNS update - NT_STATUS_ACCESS_DENIED

Failed DNS updateと言われるが、まだBIND DNSの調整前でsybyl.localドメインが存在してないので。

Step 6: Testing Samba

BIND DNSが未調整だけど、このまま少々動作確認をします。別ターミナルを立ち上げて下記の接続テストを行います。

[root@c ~]# /opt/samba/bin/smbclient //c.sybyl.local/netlogon -Uadministrator
Enter administrator's password:
Domain=[SYBYL] OS=[Windows 6.1] Server=[Samba 4.2.0]
smb: \> ls
  .                                   D        0  Sun Mar  8 18:19:27 2015
  ..                                  D        0  Sun Mar  8 18:19:54 2015
 
                26201600 blocks of size 1024. 11640104 blocks available
smb: \> quit
[root@c ~]#

とnetlogon共有ドライブにアクセスできた。次にsmbclientからも確認すると、

[root@c ~]# /opt/samba/bin/smbclient -L c -U%
Domain=[SYBYL] OS=[Windows 6.1] Server=[Samba 4.2.0]
 
        Sharename       Type      Comment
        ---------       ----      -------
        netlogon        Disk
        sysvol          Disk
        IPC$            IPC       IPC Service (Samba 4.2.0)
Domain=[SYBYL] OS=[Windows 6.1] Server=[Samba 4.2.0]
 
        Server               Comment
        ---------            -------
 
        Workgroup            Master
        ---------            -------
[root@c ~]#

と見えている。正しく稼働しているみたい。Step 5: Starting Sambaでシングルモードでテスト実行している sambaデーモンを [Control+C]で停止させます。

(中略)
/opt/samba/sbin/samba_dnsupdate:
../source4/dsdb/dns/dns_update.c:294: Failed DNS update - NT_STATUS_ACCESS_DENIED
^C
[root@c ~]#

Step 7: Configure DNS

BIND DNSに sybyl.local ゾーンを追加します
まずは使用するBIND DNSのバージョンに合わて設定ファイルを調整して

[root@c ~]# vi /opt/samba/private/named.conf
dlz "AD DNS Zone" {
    # For BIND 9.8.x
    # database "dlopen /opt/samba/lib/bind9/dlz_bind9.so";
 
    # For BIND 9.9.x
    database "dlopen /opt/samba/lib/bind9/dlz_bind9_9.so";   # BIND 9.9.xを使用するのでこれを有効に
 
    # For BIND 9.10.x
    # database "dlopen /opt/samba/lib/bind9/dlz_bind9_10.so";
};
[root@c ~]#

このファイルをBIND DNSの設定ファイル(/etc/named.conf)に組み入れます。

[root@c ~]# echo "include \"/opt/samba/private/named.conf\";" >> /etc/named.conf

そして、provision時に示された/opt/samba/private/named.txtに従いoptions枠にkeytabを付け加える

[root@c ~]# vi /etc/named.conf
options {
(中略)
    tkey-gssapi-keytab "/opt/samba/private/dns.keytab";
};
(中略)
[root@c ~]#

その上で named を再起動させ、再び samba をシングルモードで起動してみる

[root@c ~]# systemctl restart named
[root@c ~]# /opt/samba/sbin/samba -i -M single
samba version 4.2.0 started.
Copyright Andrew Tridgell and the Samba Team 1992-2014
samba: using 'single' process model

と今度はStep 5: Starting Sambaと比べてエラーは表示されなくなる。
この状態で ADドメインコントローラ のDNS機能をチェックする。また別ターミナルを立ち上げて

[root@c ~]# host -t SRV _ldap._tcp.sybyl.local.
_ldap._tcp.sybyl.local has SRV record 0 100 389 c.sybyl.local.
[root@c ~]# host -t SRV _kerberos._udp.sybyl.local.
_kerberos._udp.sybyl.local has SRV record 0 100 88 c.sybyl.local.
[root@c ~]# host -t A c.sybyl.local
c.sybyl.local has address 192.168.0.3
[root@c ~]#

と検索できることを確認した。sambaデーモンを [Control+C]で停止させます。

Step 8: Configure Kerberos

provisionコマンドで作成された krb5.conf を /etc/krb5.conf と差し替えてsambaの動的DNS更新をテストします。

[root@c ~]# mv /etc/krb5.conf /etc/krb5.conf_
[root@c ~]# cp /opt/samba/private/krb5.conf /etc/krb5.conf
[root@c ~]# cat /etc/krb5.conf
[libdefaults]
        default_realm = SYBYL.LOCAL
        dns_lookup_realm = false
        dns_lookup_kdc = true
[root@c ~]#

そして、再びsambaをシングルモードで起動します。

[root@c ~]# /opt/samba/sbin/samba -i -M single
samba version 4.2.0 started.
Copyright Andrew Tridgell and the Samba Team 1992-2014
samba: using 'single' process model

別ターミナルで kinit によるkerberosチケット受領後に動的更新を行ってみる

[root@c ~]# kinit administrator@SYBYL.LOCAL
Password for administrator@SYBYL.LOCAL:
Warning: Your password will expire in 41 days on 2015年04月19日 18時19分49秒
[root@c ~]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: administrator@SYBYL.LOCAL
 
Valid starting       Expires              Service principal
2015-03-08T18:29:04  2015-03-09T04:29:04  krbtgt/SYBYL.LOCAL@SYBYL.LOCAL
        renew until 2015-03-09T18:29:00
[root@c ~]#
[root@c ~]# nsupdate -g
> update add c200.sybyl.local 100 in a 192.168.0.200
> send
> quit
[root@c ~]# nslookup c200
Server:         192.168.0.3
Address:        192.168.0.3#53
 
Name:   c200.sybyl.local
Address: 192.168.0.200
 
[root@c ~]# nsupdate -g
> update delete c200.sybyl.local
> send
> quit
[root@c ~]# nslookup c200
Server:         192.168.0.3
Address:        192.168.0.3#53
 
** server can't find c200: NXDOMAIN
 
[root@c ~]#

追加も削除も問題なく行われた。sambaデーモンは [Control+C]で停止させます。

Step 9: Configure NTP

CentOS 7の時計合わせはchronyが基本みたい。
っが、正直使い方が分からない....なので、これを外してntpを使うことにした

[root@c ~]# systemctl stop chronyd
[root@c ~]# yum remove chrony
[root@c ~]# yum install ntp
[root@c ~]# systemctl enable ntpd ntpdate

として、設定は下記にのようにした

[root@c ~]# echo "ntp1.jst.mfeed.ad.jp" > /etc/ntp/step-tickers
[root@c ~]# cat << _EOT_ >/etc/ntp.conf
server ntp1.jst.mfeed.ad.jp
driftfile /var/lib/ntp/drift
logfile /var/log/ntpd.log
ntpsigndsocket /opt/samba/var/lib/ntp_signd/
restrict default   mssntp
restrict 192.168.0.0    mask 255.255.255.0    nomodify notrap mssntp
restrict ntp1.jst.mfeed.ad.jp mask 255.255.255.255 nomodify notrap noquery
restrict 127.0.0.1
broadcastdelay 0.008
keys /etc/ntp/keys
_EOT_
[root@c ~]# systemctl start ntpdate
[root@c ~]# systemctl start ntpd

Step 10: Configure smb.conf

一応、Step 4: Provision Sambaの際にテンプレートが /opt/samba/etc/smb.conf に用意されますが調整を加えます。

# Global parameters
[global]
        workgroup = SYBYL
        realm = SYBYL.LOCAL
        netbios name = C
        server role = active directory domain controller
        server services = s3fs, rpc, nbt, wrepl, ldap, cldap, kdc, drepl, winbindd, ntp_signd, kcc, dnsupdate
        idmap_ldb:use rfc2307 = yes
 
        nsupdate command = /opt/bind/bin/nsupdate -g
        printing = bsd
        log level=1
        syslog = 0
        log file = /var/log/samba.log
        utmp = yes
[netlogon]
        path = /opt/samba/var/locks/sysvol/sybyl.local/scripts
        read only = No
 
[sysvol]
        path = /opt/samba/var/locks/sysvol
        read only = No
[export]
        path = /export
        writable = no
[homes]
        browseable = no
        read only = no
        create mask = 0644
        directory mask = 0755

*[homes]なら\\cでログインユーザのホームディレクトリが見える。
2015y03m05d_014453592.png
[home]でpath = /home/%Uなら何も表示されず、
2015y03m05d_014823625.png
\\c\home\でホームディレクトリが見える
2015y03m05d_014808984.png

ここでは[homes]]を使ってます。winbind経由だと規定で /home/<ドメイン名>/<ユーザ> と置かれる。それはそれでいいのだが、、、

Step 11: Configure samba.service

configureの際、--with-systemdとフラグを付けたのだが、、、あれぇ?対応するスクリプトはあるのだが、日付がおかしいなぁ...

[root@c samba-4.2.0]# find . -name *.service -exec ls -l {} \;
-rw-rw-r-- 1 root root 306 10月  1 18:16 ./ctdb/config/ctdb.service
-rw-rw-r-- 1 root root 286 10月  1 18:16 ./packaging/systemd/nmb.service
-rw-rw-r-- 1 root root 306 10月  1 18:16 ./packaging/systemd/samba.service
-rw-rw-r-- 1 root root 332 10月  1 18:16 ./packaging/systemd/smb.service
-rw-rw-r-- 1 root root 315 10月  1 18:16 ./packaging/systemd/winbind.service
[root@c samba-4.2.0]#

まあいいsamba.sysconfigは、/etc/sysconfig/sambaとして、samba.serviceは下記のようにした。

[root@c samba-4.2.0]# cd ./packaging/systemd
[root@c systemd]# cp samba.sysconfig /etc/sysconfig/samba
[root@c systemd]# cp samba.service /etc/systemd/system
[root@c systemd]# vi /etc/systemd/system/samba.service
[Unit]
Description=Samba AD Daemon
After=syslog.target network.target
[Service]
Type=notify
NotifyAccess=all
PIDFile=/opt/samba/var/run/samba.pid
LimitNOFILE=16384
EnvironmentFile=-/etc/sysconfig/samba
ExecStart=/opt/samba/sbin/samba $SAMBAOPTIONS
ExecReload=/usr/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@c systemd]#

留意 PIDFile は、/opt/samba/var/run/samba.pid とした。
*DNS backendをSAMBA_INTERNALにした際、Type=forkingでないと正常起動しなかった事がある

その後、新しいUnitなのでsystemdで読み込んで起動時に起動させるように手配後、起動する。

[root@c systemd]# systemctl daemon-reload
[root@c systemd]# systemctl list-unit-files --type=service | grep samba
 
samba.service                               disabled
 
[root@c systemd]# systemctl enable samba.service
[root@c systemd]# systemctl start samba.service

これでインストールと起動は完了。次はユーザ作成

最新の60件
2026-07-20 2026-07-18 2026-07-17 2026-07-16 2026-07-08 2026-07-07 2026-07-06 2026-07-04 2026-07-02 2026-06-27 2026-06-25 2026-06-24 2026-06-21 2026-06-17 2026-06-14 2026-06-13 2026-06-09 2026-06-08 2026-06-06 2026-06-05 2026-06-04 2026-06-03 2026-05-31 2026-05-26 2026-05-23 2026-05-22 2026-05-21 2026-05-20 2026-05-19 2026-05-18 2026-05-12 2026-05-11 2026-05-08 2026-05-06 2026-05-05 2026-05-03

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-05-31 (日) 11:37:49