Samba as AD domain controller
Quick AD recap
LDAP- users ; groups ; servers/computers ; services ; application-data- Domain is
a unit of administration, having atleast one domain controller , most likely two(replicated) and might also have other sub domains which form trees and forests - Samba 4 has been in development for 10 years and was released in 2012
- The old daemons
smb,nmbandwinbindstill work and support the domain member role just as same as Samba 3 - There is a new daemon simply called
sambawhich supports the Active Directory Domain Controller role -
New command line administration tool called
sabma-toolandswatis no longer supported - Samba 4 as a Domain Controller needs to provide three services
LDAPservice ( to store and access info )DNSservices ( to locate servers )Kerberos( authentication )
Samba 4 commonly used ports
Traditional file server role
- 135 TCP Service location service for
RPCor Remote Procedure Call - 137 TCP
NetBIOS name resolution,NetLogon - 138 UDP
NetBIOS Datagram service
LDAP
- 389 TCP
LDAP - 686 TCP LDAP over SSL ( this is called
LDAPSsomethimes ) - 3268 TCP LDAP global catalog searches
- 3268 TCP LDAP global catalog searches over
Kerberos
- 88 TCP kerberos version 5
- 88 UDP kerberos version 5
- 464 TCP kerberos set/change password
- 464 UDP kerberos set/change password
DNS
- 53 TCP DNS
- 53 UDP DNS
Building Samba 4 from scratch
- Have the nameserver pointed to the server’s IP
- Then a bunch of packages have to be installed
- Choose kerberos realm, servername ( this server after adding it into it’s own hosts file ) , administrative server (same machine)
- git clone the samba code
- There’s a
configurescript and this script will make amakefilefor us to build samba! - The source code is not specific to
linuxor anything else! ./configure --help- notable options like
with winbind,with ads,--prefixoption defines where to install samba to like/usr/bin/sambaetc. - example run
./configure --enable-selftest; it’ll run a lot of tests for system configuration! - this will then generate a
makefileand to use that make file to install the program, simply type inmakeonce that’s done, domake install - You might want to add the samba programs to your search path like this ` PATH = $PATH:/usr/local/samba/sbin:/usr/local/samba/bin` in a startup script like bashrc / profile etc.
- This will
NOTand I repeat NOT be hooked into init
Provisioning a Domain!
- We’re going to use
samba-toolwhich is a great complex tool and it’s help is here atsamba-tool --help - Then if you want to see more detailed information about a particular section / command like say
userfor user management, dosamba-tool user --help - Similarly keep going down like this
samba-tool user add --helpto show more detailed information about a particular option - To simply make a domain
samba-tool domain provisionthen give- REALM
- Domain NAme ( this is the
netBIOSdomain name, not the DNS name ) - Server role would be
dcfor a domain controller - DNS server ( can be bind yay! ) , even Samba has an internal DNS server
- DNs forwarder IP ( if needed ) or is usually the same server itself
- Set an
Administratorpassword , this is important - Ensure the current date and time via NTP
- ( side note
samba -vprints the samba version )
- To run it, simply
sambaand again, no message is a good message. - To see where we’re listening on from samba
lsof -i | grep '^samba.*IPv4' - To verify, one can
- Verify smb shares
- Verigy kerberos and see if you can get the
TGT
- Then create a samba user like this
samba-tool user add Vishal 'password-forVishal' - You can list the users like
samba-tool user list
Join a windows machine and administer the domain
- Point the machine to the correct DNS server ( which is the domain controller itself )
- My Computer > Right Click > Advanced system Settings > Computer Name Tab > Change > Choose computer name > Choose Domain and enter the domain name
- then supply the account credentials for an account which has the privilages to join things to a domain!
- Restart the computer
- To administer tool, we can use
samba-toolorRemote Server Admiinistration Toolwhich is a free tool from MS - Then Control Panel > Programs and Features > Turn Windows features on or off > enable Remote Server Administration Tools
- To test, add a user from the Remote Server Administration Tool and list the users from samba-tool