2013年5月16日木曜日

Ubuntu で Samba4 を試してみる

Samba4 を試してみました。

$ lsb_release -d
Description:    Ubuntu 13.04

■ 雛形の dc0 を作成
$ sudo lxc-create -n dc0 -t ubuntu -- -S ~/.ssh/id_rsa.pub

■ 必要に応じて (lxc.network.link 等を変更)
$ sudo vi /var/lib/lxc/dc0/config

$ sudo vi /var/lib/lxc/dc0/rootfs/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address 198.51.100.20
  netmask 255.255.255.0
  gateway 198.51.100.1
  dns-nameservers 127.0.0.1 8.8.8.8
  dns-search samba4.local

iface eth0 inet6 static
  address fdb2:99c7:174a:2::14
  netmask 64
  gateway fdb2:99c7:174a:2::1
__END__

$ sudo lxc-start -n dc0 -d

$ sudo lxc-ls --fancy --active
NAME  STATE    IPV4           IPV6                  AUTOSTART
-------------------------------------------------------------
dc0   RUNNING  198.51.100.20  fdb2:99c7:174a:2::14  NO

$ ssh ubuntu@fdb2:99c7:174a:2::14

■ 以下、dc0 での作業

$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt-get install wget build-essential python python-dev libacl1-dev -y
$ wget http://ftp.samba.org/pub/samba/stable/samba-4.0.6.tar.gz
$ tar xzf samba-4.*.tar.gz && cd samba-4.*/
$ ./configure --bindir=/usr/local/bin --sbindir=/usr/local/sbin && make
$ sudo make install

$ samba -b | grep version
Samba version: 4.0.6

$ sudo tee /etc/init/samba4.conf <<'__END__'
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
expect fork
pre-start script
    case "$UPSTART_EVENTS" in
        *net-device-up*) sleep 5 ;;
    esac
end script
exec /usr/local/sbin/samba -D
__END__

※ IPv6 アドレスの設定がある場合、うまく起動できなかったので、sleep で
遅延させています。

$ sudo poweroff

■ 以下、ホスト OS での作業
■ dc0 を雛形に dc1 を作成 (必要に応じて、dc2 以降も複製、設定を実施)
$ sudo lxc-clone -o dc0 -n dc1

■ ネットワーク設定
$ sudo vi /var/lib/lxc/dc1/rootfs/etc/network/interfaces

■ dc1 起動
$ sudo lxc-start -n dc1 -d
$ sudo lxc-ls --fancy --active
NAME  STATE    IPV4                          IPV6                  AUTOSTART
----------------------------------------------------------------------------
dc1   RUNNING  198.51.100.21                 fdb2:99c7:174a:2::15  NO

■ 以下、dc1 での作業
$ sudo samba-tool domain provision
Realm: samba4.local
 Domain [samba4]:
 Server Role (dc, member, standalone) [dc]:
 DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]:
 DNS forwarder IP address (write 'none' to disable forwarding) [127.0.0.1]: 8.8.8.8
Administrator password: P@$$w0rd
Retype password: P@$$w0rd

$ sudo initctl start samba4
samba4 start/running, process 21277

■ 確認
$ smbclient -L localhost -U%
Domain=[SAMBA4] OS=[Unix] Server=[Samba 4.0.6]

        Sharename       Type      Comment
        ---------       ----      -------
        netlogon        Disk
        sysvol          Disk
        IPC$            IPC       IPC Service (Samba 4.0.6)
Domain=[SAMBA4] OS=[Unix] Server=[Samba 4.0.6]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------

$ smbclient //localhost/netlogon -U administrator
Enter administrator's password:
Domain=[SAMBA4] OS=[Unix] Server=[Samba 4.0.6]
smb: \> quit

■ パスワードポリシーの変更
$ sudo samba-tool domain passwordsettings set --complexity=off --min-pwd-length=4 --min-pwd-age=0

$ sudo samba-tool domain passwordsettings show
Password informations for domain 'DC=samba4,DC=local'

Password complexity: off
Store plaintext passwords: off
Password history length: 24
Minimum password length: 4
Minimum password age (days): 0
Maximum password age (days): 42

■ ドメイン・フォレストの機能レベルの確認 (初期)
$ sudo samba-tool domain level show
Domain and forest function level for domain 'DC=samba4,DC=local'

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

■ ドメイン・フォレストの機能レベルを上げる
$ sudo samba-tool domain level raise --domain-level 2008_R2 --forest-level 2008_R2

■ ドメイン・フォレストの機能レベルの確認
$ sudo samba-tool domain level show
Domain and forest function level for domain 'DC=samba4,DC=local'

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

■ FSMO を移動
$ sudo samba-tool fsmo transfer --role all

■ FSMO の確認
$ sudo samba-tool fsmo show

■ ldapsearch で確認
$ sudo apt-get install ldap-utils
$ ldapsearch -xWLLL -h ::1 -D cn=Administrator,cn=Users,dc=samba4,dc=local -b dc=samba4,dc=local cn=Administrator




#### (作成中...)


参考
  • http://www.jadota.com/2013/01/installing-samba4-on-ubuntu-12-04/
  • http://sheepdogjam.cocolog-nifty.com/blog/2013/02/raspberrypi-sam.html
  • https://wiki.samba.org/index.php/Samba4/InitScript
  • http://www.ilovex.co.jp/Division/ITD/archives/2008/12/windows_linux.html
  • http://upstart.ubuntu.com/cookbook/

0 件のコメント: