LoginSignup
2
11

More than 1 year has passed since last update.

Ubuntu 20.04 でSamba AD DCを構成する

Last updated at Posted at 2021-07-25

本環境

  • VPS
    • さくらVPS 1Gプラン
  • OS
    • Ubuntu 20.04 LTS

1. sambaとKerberos5をインストール

$ sudo apt install samba krb5-user krb5-config winbind libpam-winbind libnss-winbind -y

2. Kerberosの設定

スクリーンショット 2021-07-24 23.24.04.png

スクリーンショット 2021-07-24 23.24.44.png

スクリーンショット 2021-07-24 23.25.24.png

3. 設定する上で邪魔になるソフトを停止

$ sudo systemctl stop samba-ad-dc.service
$ sudo systemctl stop nmbd.service
$ sudo systemctl stop winbind.service

4. デフォルトのsambaの設定ファイル名変更

$ sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.initial

5. sambaの設定ファイルを新規作成

sudo samba-tool domain provision --use-rfc2307 --interactive

###設定内容

Realm [VS.SAKURA.NE.JP]:  SUGISOFT.LOCAL                
Domain [SUGISOFT]:  (未入力で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) [127.0.0.53]: 8.8.8.8
Administrator password: Password123
Retype password: Password123

6. Kerberosのファイル名変更

$ sudo mv /etc/krb5.conf /etc/krb5.conf.initial

7. シンボリックリンクを作成

$ sudo ln -s /var/lib/samba/private/krb5.conf /etc/

8. マスキングの解除

$ sudo systemctl unmask samba-ad-dc.service

9. システム起動時に自動的に立ち上がるサービスとして登録

$ sudo systemctl enable samba-ad-dc.service

10. sambaを起動

$ sudo systemctl start samba-ad-dc.service

ここでエラーが発生する人が多いと思いますので別で解決方法を書きましたので参考に

ここからは動作確認作業

1. ドメインレベルの確認

$ sudo samba-tool domain level show

結果

Domain and forest function level for domain 'DC=sugisoft,DC=local'

Forest function level: (Windows) 2008 R2
Domain function level: (Windows) 2008 R2
Lowest function level of a DC: (Windows) 2008 R2

2. 動作確認

通信確認

ping -c3 sugisoft.local

正常値(例)

$ ping -c3 sugisoft.local
PING sugisoft.local() 56 data bytes
64 bytes from  icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from  icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from  icmp_seq=3 ttl=64 time=0.040 ms

--- sugisoft.local ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2046ms
rtt min/avg/max/mdev = 0.026/0.034/0.040/0.006 ms

ドメイン名検索 1

host sugisoft.local

正常値(例) 1

sugisoft.local has address 
sugisoft.local has IPv6 address

ドメイン名検索 2

host -t SRV _kerberos._udp.sugisoft.local

正常値(例) 2

_kerberos._udp.sugisoft.local has SRV record 0 100 88 ik1-442-53089.sugisoft.local.

ドメイン名検索 3

host -t SRV _ldap._tcp.sugisoft.local

正常値(例) 3

_ldap._tcp.sugisoft.local has SRV record 0 100 389 ik1-442-53089.sugisoft.local.

3. Kinitでログインテスト

kinit administrator@SUGISOFT.LOCAL

正常値

Warning: Your password will expire in 41 days on Sat 04 Sep 2021 11:35:58 PM JST

※ 「あなたのパスワードは41日後に無効になります。」と言っています。

4. ケルベロス認証のチケットを確認

klist

正常値(例)

Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: administrator@SUGISOFT.LOCAL

Valid starting       Expires              Service principal
07/25/2021 01:16:24  07/25/2021 11:16:24  krbtgt/SUGISOFT.LOCAL@SUGISOFT.LOCAL
	renew until 07/26/2021 01:16:20
2
11
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
11