Advertisement
Drthrax74

SAMBA4

Aug 12th, 2020 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 11.48 KB | None | 0 0
  1. #######################################################################################################################
  2. #########################
  3. # Routeur ASUS - MERLIN #
  4. #########################
  5. #
  6. # Ajout d'entrée dans le DNS du routeur pour une meilleur résolution depuis le réseau physique
  7. #
  8. # nano /jffs/configs/dnsmasq.conf.add ; service restart_dnsmasq
  9. #
  10. ####################################
  11. # FQDN: SLDEBIAN01.MONDOMAIN.LOCAL #
  12. # Distribution: Debian 10          #
  13. ####################################
  14.  
  15. address=/SLDEBIAN01.mondomain.local/192.168.1.2
  16. address=/SLDEBIAN01.mondomain/192.168.1.2
  17. address=/SLDEBIAN01/192.168.1.2
  18.  
  19.  
  20. nslookup SLDEBIAN01.mondomain.local
  21. nslookup SLDEBIAN01.mondomain
  22. nslookup SLDEBIAN01
  23.  
  24. Résultat : 192.168.1.2
  25.  
  26. #######################################################################################################################
  27.  
  28. # Etape 1  : Préparer votre machine Debian9
  29. # Liens    : https://dev.tranquil.it/samba/fr/samba_config_server/debian/server_prepare_debian.html
  30.  
  31.  
  32. # Etape 2  : Installer et configurer Samba-AD sur Debian9
  33. # Liens    : https://dev.tranquil.it/samba/fr/samba_config_server/debian/server_install_samba_debian.html
  34.  
  35.  
  36. # Etape 3  : Installer et configurer Bind-DLZ pour Samba-AD
  37. # Liens    : https://dev.tranquil.it/samba/fr/samba_config_server/debian/server_install_binddlz_debian.html
  38.  
  39. #
  40. # Etape 4A : Installer et configurer NTP pour Samba-AD sur Debian9 (Première Partie)
  41. # Liens    : https://dev.tranquil.it/samba/fr/samba_config_server/debian/server_install_ntp_debian.html
  42. #          : Maintenant, nous allons pouvoir installer Samba en mode Active Directory. Ca avance, c’est bien !! (Partie 4B)
  43.  
  44.  
  45. # Etape 4B : Installer et configurer Samba-AD sur Debian9
  46. # Liens    : https://dev.tranquil.it/samba/fr/samba_config_server/debian/server_install_samba_debian.html#server-install-samba-debian
  47.  
  48.  
  49. # Etape 4C : Installer et configurer NTP pour Samba-AD sur Debian9 (Seconde Partie)
  50. # Liens    : https://dev.tranquil.it/samba/fr/samba_config_server/debian/server_install_ntp_debian.html#forcer-une-resynchronisation-sur-un-poste-windows
  51.  
  52.  
  53.  
  54.  
  55. #######################################################################################################################
  56.  
  57. ###########################################
  58. # Etape 0 : Ajout de paquet indispensable #
  59. ###########################################
  60. apt install -y bash-completion sudo net-tools  qemu-guest-agent wget curl gnupg  git iperf3 tasksel ; systemctl restart qemu-guest-agent
  61. apt update --fix-missing
  62.  
  63. ################################################################
  64. # Actions supplémentaires : Paquet | SSH EN ROOT | Sudoer Marc #
  65. ################################################################
  66. apt install gnupg wget curl -y ;
  67. sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config ;/etc/init.d/ssh restart
  68. nano /etc/sudoers
  69. #marc    ALL=(ALL) NOPASSWD:ALL
  70.  
  71.  
  72.  
  73.  
  74. ############################################
  75. # Etape 1 - Préparer votre machine Debian9 #
  76. ############################################
  77. nano /etc/network/interfaces ; systemctl restart networking ; systemctl reboot
  78.  
  79. source /etc/network/interfaces.d/*
  80. auto lo
  81. iface lo inet loopback
  82. #Configuration interface ens18 (ethernet)
  83. auto ens18
  84. iface ens18 inet static
  85. address 192.168.1.2
  86. netmask 255.255.255.0
  87. network 192.168.1.0
  88. broadcast 192.168.1.255
  89. gateway 192.168.1.1
  90. dns-nameservers 192.168.1.1
  91.  
  92.  
  93. echo "SLDEBIAN01.mondomain.local" > /etc/hostname ;  cat /etc/hostname
  94.  
  95. echo "#IPV4
  96. 127.0.0.1       localhost
  97. 192.168.1.2     sldebian01.mondomain.local      sldebian01
  98. #
  99. #IPV6
  100. ::1     localhost ip6-localhost ip6-loopback
  101. ff02::1 ip6-allnodes
  102. ff02::2 ip6-allrouters" > /etc/hosts
  103.  
  104.  
  105.  
  106. dpkg-reconfigure tzdata  ; timedatectl status
  107. # - Local time      : mer. 2020-08-12 14:14:38 CEST
  108. # - Universal time  : mer. 2020-08-12 12:14:38 UTC
  109. # - RTC time        : mer. 2020-08-12 12:14:39
  110. # - Time zone       : Europe/Paris (CEST, +0200)
  111. # - System clock syn: yes
  112. # - NTP service     : inactive
  113. # - RTC in local TZ : no
  114.  
  115. dpkg-reconfigure locales ; localectl status
  116. # - system Locale    : LANG=fr_FR.UTF-8
  117. # - VC Keymap       : n/a
  118. # - X11 Layout      : fr
  119. # - X11 Model       : pc105
  120. # - X11 Variant     : latin9
  121.  
  122.  
  123. systemctl stop avahi-daemon.service avahi-daemon.socket ; systemctl disable avahi-daemon.service avahi-daemon.socket ;
  124. apt-get update -y ; apt-get install -y wget sudo screen nmap telnet tcpdump rsync net-tools dnsutils htop apt-transport-https vim ;
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. ##########################################################
  136. # Etape 2 - Installer et configurer Samba-AD sur Debian9 #
  137. ##########################################################
  138.  
  139.  
  140. wget -O tissamba-pubkey.gpg  http://samba.tranquil.it/tissamba-pubkey.gpg ; apt-key add tissamba-pubkey.gpg ; rm tissamba-pubkey.gpg ;
  141.  
  142. # Version 4.10
  143. echo "deb https://samba.tranquil.it/debian/samba-4.10/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/tissamba.list ;
  144.  
  145. # Version 4.11 (NON UTILISER)
  146. echo "deb https://samba.tranquil.it/debian/samba-4.11/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/tissamba.list ;
  147.  
  148.  
  149. export DEBIAN_FRONTEND=noninteractive ;
  150. apt-get update ; apt-get install -y samba winbind libnss-winbind krb5-user smbclient ldb-tools python3-crypto ; unset DEBIAN_FRONTEND
  151.  
  152.  
  153. echo "[libdefaults]
  154. default_realm = MONDOMAIN.LOCAL
  155. dns_lookup_kdc = true
  156. dns_lookup_realm = false" > /etc/krb5.conf
  157.  
  158. rm -f /etc/samba/smb.conf ;
  159. samba-tool domain provision --realm=MONDOMAIN.LOCAL --domain MONDOMAIN --server-role=dc ;
  160.  
  161.  
  162. # Reset account administrator (samba)
  163. samba-tool user setpassword administrator ;
  164.  
  165. #Resolv
  166. echo "search mondomain.local
  167. nameserver 127.0.0.1
  168. " > /etc/resolv.conf ; cat /etc/resolv.conf ;
  169.  
  170. rm -f /var/lib/samba/private/krb5.conf ; ln -s /etc/krb5.conf /var/lib/samba/private/krb5.conf
  171.  
  172. systemctl unmask samba-ad-dc ; systemctl enable samba-ad-dc ; systemctl disable samba winbind nmbd smbd ; systemctl mask samba winbind nmbd smbd ; systemctl reboot
  173.  
  174. kinit administrator
  175. #Warning: Your password will expire in 41 days on mer. 23 sept. 2020 11:58:04 CEST
  176.  
  177. klist
  178. # Valid starting       Expires              Service principal
  179. # 12/08/2020 14:27:51  13/08/2020 00:27:51  krbtgt/MONDOMAIN.LOCAL@MONDOMAIN.LOCAL
  180. # renew until 13/08/2020 14:27:48
  181.  
  182. dig @localhost google.fr
  183. dig @localhost MONDOMAIN.LOCAL
  184. dig -t SRV @localhost _ldap._tcp.MONDOMAIN.LOCAL
  185.  
  186. ####################################
  187. # Joindre un Ordinateur au domaine #
  188. ####################################
  189.  
  190. # Domaine   : Domain
  191. # User      : administrator
  192. # pass      : *****
  193. # Résultat : Réussi
  194.  
  195.  
  196. #################################
  197. # Installation des paquets RSAT #
  198. #################################
  199. #
  200. # Guide : https://dev.tranquil.it/samba/fr/samba_config_server/samba_install_RSAT.html#samba-install-rsat
  201. #
  202. # Powershell : Get-WindowsCapability -Online | ? Name -like 'RSAT*'|Where {$_.State -eq 'NotPresent'} |foreach {Add-WindowsCapability -online -name $_.Name}
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210. ############################################################
  211. # Etape 3 - Installer et configurer Bind-DLZ pour Samba-AD #
  212. ############################################################
  213. apt-get install -y bind9
  214.  
  215. nano /etc/bind/named.conf.options
  216. options
  217.   {
  218.   directory "/var/cache/bind";
  219.   allow-query {any;};
  220.   listen-on-v6 {any;};
  221.   dnssec-validation no;
  222.   auth-nxdomain no;
  223.   minimal-responses yes;
  224.   forwarders { 192.168.1.1;};
  225.   tkey-gssapi-keytab "/var/lib/samba/bind-dns/dns.keytab";
  226.   };
  227.  
  228.  
  229. nano /etc/bind/named.conf.local
  230. dlz "mondomain.local" {database "dlopen /usr/lib/x86_64-linux-gnu/samba/bind9/dlz_bind9_10.so";};
  231.  
  232. nano /etc/default/bind9
  233. # run resolvconf?
  234. RESOLVCONF=no
  235. # startup options for the server
  236. OPTIONS="-4 -u bind"
  237.  
  238.  
  239. nano /etc/samba/smb.conf
  240. [global]
  241. server services = -dns
  242. # dns forwarder =
  243.  
  244. ###################
  245. # Dossier Partage #
  246. ###################
  247. mkdir /var/lib/samba/bind-dns ; mkdir /var/lib/samba/bind-dns/dns
  248. samba_upgradedns --dns-backend=BIND9_DLZ
  249. systemctl restart samba-ad-dc
  250. systemctl restart bind9
  251.  
  252. netstat -tapn | grep 53
  253. dig @localhost google.fr
  254. dig @localhost mondomain.local
  255. dig -t SRV @localhost _ldap._tcp.mondomain.local
  256.  
  257. #######################################################################################################################
  258.  
  259.  
  260. ####################################################################
  261. # Etape 4A - Installer et configurer NTP pour Samba-AD sur Debian9 #
  262. #####################################################################
  263.  
  264. apt-get install -y ntpdate ntp
  265. ntpdate -bu pool.ntp.org
  266.  
  267. nano /etc/ntp.conf
  268. ntpsigndsocket /var/lib/samba/ntp_signd
  269. restrict default mssntp
  270. chgrp ntp /var/lib/samba/ntp_signd
  271. systemctl restart ntp
  272.  
  273.  
  274.  
  275.  
  276.  
  277. ################################################################
  278. # Etape 4C - Forcer une resynchronisation sur un poste windows #
  279. ################################################################
  280. #Lancer la Synchronisation :
  281. w32tm /resync /nowait
  282.  
  283. #En cas de problème
  284. w32tm /config /syncfromflags:domhier
  285. w32tm /config /update
  286. w32tm /resync /nowait
  287.  
  288. #Débuguer le client NTP sur windows
  289. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v FileLogSize /t reg_dword /d 16777216 /f
  290. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v FileLogName /t reg_sz /d "c:\w32time_debug.txt" /f
  291. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v FileLogEntries /t reg_sz /d "0-300" /f
  292. reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v FileLogSize /f
  293. reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v FileLogName /f
  294. reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v FileLogEntries /f
  295.  
  296.  
  297. #Mode Nt5DS
  298. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v Type /t reg_sz /d "Nt5DS" /f
  299. reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v Type /f
  300.  
  301.  
  302. #Mode NTP
  303. #net time /setsntp:sldebian01.mondomain.local
  304. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v Type /t reg_sz /d "NTP" /f
  305. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v ntpserver /t reg_sz /d "sldebian01.mondomain.local" /f
  306. reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v Type /f
  307. reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v ntpserver /f
  308.  
  309.  
  310.  
  311. #Le service NTP semble ne pas prendre en compte votre configuration ntp.conf
  312. rm -f /var/lib/ntp/ntp.conf.dhcp
  313.  
  314. #Vérifier le fonctionnement
  315. w32tm /monitor
  316.  
  317. #SLDEBIAN01.mondomain.local *** PDC ***[192.168.1.2:123]:              le domaine par défaut...
  318. #    ICMP: 0ms retard
  319. #    NTP: erreur ERROR_TIMEOUT - Aucune réponse du serveur dans 1000ms
  320.  
  321. #Vérifier partage Samba:
  322. testparm -s
  323.  
  324.  
  325.  
  326.  
  327.  
  328. #######################################################
  329. # ETEINDRE LES MACHINES ET REBOOT LE ROUTEUR PHYSIQUES#
  330. #######################################################
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340. ################
  341. # Expérimental #
  342. ################
  343. w32tm /config /update /manualpeerlist:"MON_AD,0x8" /syncfromflags:MANUAL,DOMHIER
  344.  
  345. net stop w32time
  346. net start w32time
  347.  
  348. w32tm /config /syncfromflags:DOMHIER /update
  349. w32tm /resync /nowait
  350. net stop w32time
  351. net start w32time
  352.  
  353. w32tm /monitor
  354. ########
  355. # LDAP #
  356. ########
  357. https://www.linuxbabe.com/ubuntu/install-configure-openldap-server-ubuntu-16-04
  358.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement