.. Reminder for header structure:        
  Parts (H1)          : #################### with overline
  Chapters (H2)       : ******************** with overline
  Sections (H3)       : ====================
  Subsections (H4)    : --------------------
  Subsubsections (H5) : ^^^^^^^^^^^^^^^^^^^^
  Paragraphs (H6)     : """""""""""""""""""""

.. |date| date::

.. meta::
  :description: Preparing your Debian host
  :keywords: Debian, install, documentation

.. _server_prepare_debian:

**************************
Preparing your Debian host
**************************

.. include:: samba_config_server-dns_suffix_explained.rst.inc

.. _install_base_debian:

Install the server
==================

To install a new Debian 64bit (physical or virtual machine) without GUI and **only with the SSH service installed** (**minimal** type installation), refer to this `documentation <https://www.howtoforge.com/tutorial/debian-minimal-server/>`_.

.. note::

  We recommend the installation of Samba-AD on Linux (Debian / RedHat10 and derived distributions), configured according to the `ANSSI Recommendations for configuring a GNU / Linux system <https://www.ssi.gouv.fr/uploads/2015/10/NP_Linux_Configuration.pdf>`_.

Configuring the network functions of your server
================================================

.. hint:: If you have a corporate proxy.

  To add the proxy to install DEB packages, create the file :file:`/etc/apt/apt.conf.d/90proxy` by adapting it to your context (proxy server name and connection port):

  .. code-block:: bash

    Acquire::https::proxy "http://proxy:3128";
    Acquire::http::proxy "http://proxy:3128";

To configure the proxy for the different commands of the root user, add the following lines at the end of :file:`/root/.bashrc`:

.. code-block:: bash

  export http_proxy=http://proxy.mydomain.lan:3128
  export https_proxy=http://proxy.mydomain.lan:3128
  export ftp_proxy=http://proxy.mydomain.lan:3128
  #export no_proxy=.lan,.local

To apply immediately this modification, do:

.. code-block:: bash

  source /root/.bashrc

.. to do:: explanation of /etc/hosts and /etc/hostname configuration

.. include:: samba_config_server-conf_dns.rst.inc

Configuring the IP address
--------------------------

* Edit :file:`/etc/network/interfaces` and set a static IP address:

  .. code-block:: bash

    # /etc/network/interfaces
    auto eth0
    iface eth0 inet static
      address 192.168.0.11/24
      gateway 192.168.0.254

.. attention::

  Since Debian version 9, the interfaces are no longer automatically called *ethX* but *wpsX* for wifi and *ensX* for ethernet.
  To find named interfaces like the previous versions, follow `this tutorial <https://memo-linux.com/debian-9-retrouver-les-noms-des-interfaces-reseaux-eth/>`_, or see `this article <https://lists.ubuntu.com/archives/ubuntu-devel/2015-May/038761.html>`_ or `this other article <https://www.p3ter.fr/debian-ubuntu-eth0-c-est-fini.html>`_.

* Apply the network configuration by rebooting the machine with a :command:`reboot`:

  .. code-block:: bash

    reboot

Finalizing your basic configuration
===================================

* After the reboot, set the system language to English to make it easier to find problems in the logs:

  .. code-block:: bash

    apt update
    apt install locales-all -y
    update-locale LANG=en_US.UTF-8
    localectl

* Disable avahi-daemon (:abbr:`mDNS (Multicast DNS)` protocol / bonjour):

  .. code-block:: bash

    systemctl stop avahi-daemon.service avahi-daemon.socket
    systemctl disable avahi-daemon.service avahi-daemon.socket

* Update Debian and install the necessary administration tools:

  .. code-block:: bash

    apt-get update -y
    apt-get install -y wget sudo screen nmap telnet tcpdump rsync net-tools dnsutils htop apt-transport-https vim gnupg lsb-release

You can now go to the next step and :ref:`install Samba-AD on your Debian <server_install_samba_debian>`.
