linux:samba:samba_activedirectory_setup

文書の過去の版を表示しています。


SambaによるActiveDirectory構築

$ sudo dnf install samba samba-client samba-dc

wbinfoを使えるように以下もインストールしておくとよい。

$ sudo dnf install samba-winbind-clients

CUPSプリントサーバーを利用する場合

$ sudo yum install cups

killallをインストール

$ sudo yum install psmisc

kinitをインストール

$ sudo yum install krb5-workstation
$ sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.org
$ 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
$ sudo vi /etc/named.conf
options {
    ...
    tkey-gssapi-keytab "/var/lib/samba/private/dns.keytab";
    ...
};

include "/var/lib/samba/private/named.conf";

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
$ 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  <-
$ 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 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

スタンダードプロセスモードで起動していることを確認する。

$ 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

ポートのlisten状況を確認するには以下のコマンドを実行する。

$ sudo netstat -tulpn | egrep "samba|smbd|nmbd|winbind"
tcp        0      0 0.0.0.0:3268            0.0.0.0:*               LISTEN      1042/samba
tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      1042/samba
tcp        0      0 0.0.0.0:135             0.0.0.0:*               LISTEN      1039/samba
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      1044/smbd
tcp        0      0 0.0.0.0:464             0.0.0.0:*               LISTEN      1045/samba
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1051/samba
tcp        0      0 0.0.0.0:88              0.0.0.0:*               LISTEN      1045/samba
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      1044/smbd
tcp        0      0 0.0.0.0:1024            0.0.0.0:*               LISTEN      1039/samba
tcp6       0      0 :::139                  :::*                    LISTEN      1044/smbd
tcp6       0      0 :::445                  :::*                    LISTEN      1044/smbd
udp        0      0 192.168.1.10:137        0.0.0.0:*                           1040/samba
udp        0      0 192.168.1.255:137       0.0.0.0:*                           1040/samba
udp        0      0 0.0.0.0:137             0.0.0.0:*                           1040/samba
udp        0      0 192.168.1.10:138        0.0.0.0:*                           1040/samba
udp        0      0 192.168.1.255:138       0.0.0.0:*                           1040/samba
udp        0      0 0.0.0.0:138             0.0.0.0:*                           1040/samba
udp        0      0 192.168.1.10:389        0.0.0.0:*                           1043/samba
udp        0      0 0.0.0.0:389             0.0.0.0:*                           1043/samba
udp        0      0 192.168.1.10:464        0.0.0.0:*                           1045/samba
udp        0      0 0.0.0.0:464             0.0.0.0:*                           1045/samba
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1051/samba
udp        0      0 192.168.1.10:88         0.0.0.0:*                           1045/samba
udp        0      0 0.0.0.0:88              0.0.0.0:*                           1045/samba
$ 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
$ 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パッケージに含まれている。

$ kinit administrator@FIREBALL.LOCAL
Password for administrator@FIREBALL.LOCAL: <- パスワードを入力
Warning: Your password will expire in 41 days on 2013年11月20日 01時23分51秒
  • linux/samba/samba_activedirectory_setup.1546694346.txt.gz
  • 最終更新: 2019/05/18 02:23
  • (外部編集)