Monday, August 3, 2015

Setup Samba4 AD DC ( CentOS 7 )

[root@server ~]# vim /etc/hosts

192.168.0.162   server.linuxroot.info   server

Disable SELinux and Firewall

[root@server ~]# vim /etc/sysconfig/selinux

From SELINUX=enforcing to SELINUX=disabled

[root@server ~]# systemctl stop firewalld.service

[root@server ~]# systemctl disable firewalld.service
 
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

Install all the required libraries and programs

[root@server ~]# yum install perl gcc libacl-devel libblkid-devel gnutls-devel readline-devel python-devel gdb pkgconfig krb5-workstation zlib-devel setroubleshoot-server libaio-devel setroubleshoot-plugins policycoreutils-python libsemanage-python setools-libs-python setools-libs popt-devel libpcap-devel sqlite-devel libidn-devel libxml2-devel libsepol-devel libattr-devel keyutils-libs-devel cyrus-sasl-devel cups-devel bind-utils libxslt docbook-style-xsl openldap-devel

Download the lastest samba 4 tar from https://www.samba.org/

[root@server ~]# wget https://download.samba.org/pub/samba/stable/samba-4.3.4.tar.gz

[root@server ~]# tar -xvf samba-4.3.4.tar.gz

[root@server ~]# cd samba-4.3.4/

Now configure,build and install Samba4.

By default, the Samba4 will be installed in /usr/local/samba/ directory.

[root@server samba-4.3.4]#./configure --enable-selftest --enable-debug --prefix=/opt/samba/ --sysconfdir=/etc/samba/ --includedir=/usr/include/samba4/ --bindir=/bin/ --sbindir=/sbin/ --mandir=/usr/share/man/


--prefix        : installation directory
--sysconfdir    : smb.conf should be places
--includedir    : includes the header files for C compilers
--bindir        : user executables
--sbindir       : system admin executables
--mandir        : man pages to be placed


'configure' finished successfully (1m56.738s)

[root@server samba-4.3.4]# make

'build' finished successfully (18m28.484s)

[root@server samba-4.3.4]# make install

'install' finished successfully (4m56.944s)

[root@server samba-4.3.4]# vim /etc/resolv.conf

domain    linuxroot.info
nameserver 192.168.0.162

[root@server samba-4.3.4]# samba-tool domain provision
Realm [LINUXROOT.INFO]: Press Enter
 Domain [LINUXROOT]: Press Enter
 Server Role (dc, member, standalone) [dc]: Press Enter
 DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: Press Enter
 DNS forwarder IP address (write 'none' to disable forwarding) [192.168.0.162]: 8.8.8.8
Administrator password: provide password
Retype password: re-type password
Looking up IPv4 addresses
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up share.ldb
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=linuxroot,DC=info
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=linuxroot,DC=info
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 /opt/samba/private/krb5.conf
Once the above files are installed, your Samba4 server will be ready to use
Server Role:           active directory domain controller
Hostname:              server
NetBIOS Domain:        LINUXROOT
DNS Domain:            linuxroot.info
DOMAIN SID:            S-1-5-21-1623651871-590293421-3205222097


[root@server samba-4.3.4]# cp -p /etc/krb5.conf /etc/krb5.conf.orig

[root@server samba-4.3.4]# cp -p /opt/samba/private/krb5.conf /etc/
cp: overwrite ‘/etc/krb5.conf’? y

Now make an init script for Samba4 to start the service automatically at boot time.

[root@server samba-4.3.4]# vim  /etc/rc.d/init.d/samba4
#!/bin/bash
#
# samba4        This shell script takes care of starting and stopping
#               samba4 daemons.
#
# chkconfig: - 58 74
# description: Samba 4.0 will be the next version of the Samba suite
# and incorporates all the technology found in both the Samba4 alpha
# series and the stable 3.x series. The primary additional features
# over Samba 3.6 are support for the Active Directory logon protocols
# used by Windows 2000 and above.

### BEGIN INIT INFO
# Provides: samba4

# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $syslog $named
# Should-Stop: $syslog $named
# Short-Description: start and stop samba4
# Description: Samba 4.0 will be the next version of the Samba suite
# and incorporates all the technology found in both the Samba4 alpha
# series and the stable 3.x series. The primary additional features
# over Samba 3.6 are support for the Active Directory logon protocols
# used by Windows 2000 and above.
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

prog=samba
prog_dir=/sbin/
lockfile=/var/lock/subsys/$prog

start() {
        [ "$NETWORKING" = "no" ] && exit 1
#       [ -x /usr/sbin/ntpd ] || exit 5
                # Start daemons.
                echo -n $"Starting samba4: "
                daemon $prog_dir/$prog -D
        RETVAL=$?
                echo
        [ $RETVAL -eq 0 ] && touch $lockfile
        return $RETVAL
}

stop() {
        [ "$EUID" != "0" ] && exit 4
                echo -n $"Shutting down samba4: "
        killproc $prog_dir/$prog
        RETVAL=$?
                echo
        [ $RETVAL -eq 0 ] && rm -f $lockfile
        return $RETVAL
}

# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
status)
        status $prog
        ;;
restart)
        stop
        start
        ;;
reload)
        echo "Not implemented yet."
        exit 3
        ;;
*)
        echo $"Usage: $0 {start|stop|status|restart|reload}"
        exit 2
esac

[root@server samba-4.3.4]# chmod +x /etc/rc.d/init.d/samba4

[root@server samba-4.3.4]# chkconfig --add /etc/rc.d/init.d/samba4

[root@server samba-4.3.4]# chkconfig samba4 on

[root@server samba-4.3.4]# service samba4 start
Starting samba4 (via systemctl):                           [ OK ]





No comments:

Post a Comment