« Raspbian Commandes » : différence entre les versions

(37 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
=== Redémarrer ===
=== Redémarrer ===
<pre>
<syntaxhighlight lang="bash" line copy>
sudo reboot
sudo reboot
</pre>
</syntaxhighlight>
 
=== Arrêt ===
=== Arrêt ===
<pre>
<syntaxhighlight lang="bash" line copy>
sudo shutdown -h now
sudo shutdown -h now
</pre>
</syntaxhighlight>
 
=== Firewall ===
=== Firewall ===
<syntaxhighlight lang="bash" line copy>
# Créer /etc/init.d/firewall
# Afin de l'ajouter aux scripts appelés au démarrage :
# Ajouter une entête dans le fichier
#!/bin/sh
### BEGIN INIT INFO
# Provides:          firewall rules
# Required-Start:    $remote_fs $syslog
# Required-Stop:    $remote_fs $syslog
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Firewall deamon
# Description:      Enable service provided by daemon.
### END INIT INFO
</syntaxhighlight>


#<=> stop & start /etc/init.d/firewall
<syntaxhighlight lang="bash" line copy>
<span style="color: red;font-weight:bold;">sudo update-rc.d firewall defaults</span>
# Sauvegarde
démarrer un deamon -> http://manpages.ubuntu.com/manpages/trusty/fr/man8/update-rc.d.8.html
sudo systemctl enable firewall
</syntaxhighlight>
 
<syntaxhighlight lang="bash" line copy>
"Relance
sudo update-rc.d firewall defaults
</syntaxhighlight>
démarrer un deamon -> http://manpages.ubuntu.com/manpages/trusty/fr/man8/update-rc.d.8.html
 
<syntaxhighlight lang="bash" line copy>
sudo /etc/init.d/firewall status
</syntaxhighlight>


=== cron ===
=== cron ===
<pre>
<syntaxhighlight lang="bash" line copy>
#relancer service cron
#relancer service cron
sudo /etc/init.d/cron restart
sudo /etc/init.d/cron restart
</pre>
</syntaxhighlight>
 
=== IPv6 ===
<syntaxhighlight lang="bash" line copy>
/etc/sysctl.d/enableipv6.conf
journalctl | grep -Ei 'dhcp6'
ip -6 route
</syntaxhighlight>
 
=== Désactivation ===
==== Bluetooth & Wifi ====
<syntaxhighlight lang="bash" line copy>
dans /boot/config.txt
dtoverlay=pi3-disable-wifi
dtoverlay=pi3-disable-bt
puis sudo reboot
</syntaxhighlight>
 
==== ipv6 ====
<syntaxhighlight lang="bash" line copy>
# * au démarage
# dans /etc/sysctl.d/
#créer /etc/sysctl.d/disableipv6.conf
#avec :
 
# désactivation de ipv6 pour toutes les interfaces
net.ipv6.conf.all.disable_ipv6=1
 
# désactivation de l’auto configuration pour toutes les interfaces
net.ipv6.conf.all.autoconf=0
 
# désactivation de ipv6 pour les nouvelles interfaces (ex:si ajout de carte réseau)
net.ipv6.conf.default.disable_ipv6=1
 
# désactivation de l’auto configuration pour les nouvelles interfaces
net.ipv6.conf.default.autoconf=0
</syntaxhighlight>


=== version matériel ===
=== version matériel ===
cat /proc/cpuinfo
<syntaxhighlight lang="bash" line copy>
#Raspberry Pi 3 Model B Rev 1.2
cat /proc/cpuinfo
#Raspberry Pi 3 Model B Rev 1.2
</syntaxhighlight>


=== CPU infos ===
=== CPU infos ===
lscpu
<syntaxhighlight lang="bash" line copy>
lscpu
</syntaxhighlight>


=== Paquets APT ===
=== Paquets APT ===
 
[[ APT | voir APT]]
#mettre à jour un paquet :
<span style="color: red;font-weight:bold;">sudo apt update (mise à jour de '''la liste''' des paquets) </span>
<span style="color: red;font-weight:bold;">sudo apt list --upgradable (pour voir ce qui doit être mis à jour) </span>
<span style="color: red;font-weight:bold;">sudo apt install --only-upgrade firefox </span>
#voir tous les paquets
<span style="color: red;font-weight:bold;">dpkg --list</span>
#voir si un paquet est à jour
<span style="color: red;font-weight:bold;">apt-cache policy firefox</span>


=== Redémarrer unbound ===
=== Redémarrer unbound ===
<span style="color: red;font-weight:bold;">sudo service unbound restart</font>
<syntaxhighlight lang="bash" line copy>
sudo service unbound restart
</syntaxhighlight>


=== Lighttpd ===
=== DHCPCD (static ip_address) ===
<span style="color: red;font-weight:bold;">sudo service lighttpd status</span>
<pre>
<span style="color: red;font-weight:bold;">sudo service lighttpd restart</span>
DHCPCD signifie DHCP Client Daemon. Comme son nom l'indique, c'est un client DHCP s'exécutant en tâche de fond. Mais son nom est également trompeur car il ne se limite pas à récupérer une adresse IP via DHCP, c'est aussi sur lui que repose toute la configuration réseau d'une machine Linux.
==== vhost ====
DHCPCD est emmené à remplacer la configuration du réseau que l'on fait via le fichier /etc/network/interfaces et le service networking sous les distributions Linux dérivées de Debian.
<span style="color: red;font-weight:bold;">ln -s /etc/lighttpd/conf-available/91-exemple.com.conf /etc/lighttpd/conf-enabled/91-exemple.com.conf</span>
</pre>
*voir:[https://www.jesus-forain.fr/blog/configuration-de-dhcpcd-52.html Configuration de DHCPCD]


=== Pihole ===
<syntaxhighlight lang="bash" line copy>
#update pihole
sudo service dhcpcd status
<span style="color: red;font-weight:bold;">pihole -up</span>
</syntaxhighlight>
/etc/dhcpcd.conf


==== Black Lists ====
<syntaxhighlight lang="bash" line copy>
[https://fleuryk.kappatau.fr/pihole-blocklist/ pihole-blocklist]
dhcpcd man
* https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Block-EU-Cookie-Shit-List.txt
</syntaxhighlight>
* https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/CountryCodesLists/France.txt
* https://easylist-downloads.adblockplus.org/liste_fr%2Beasylist.txt
* https://blocklist.site/app/dl/malware
* https://blocklist.site/app/dl/ransomware
* https://blocklist.site/app/dl/phishing
* https://blocklist.site/app/dl/ads
* https://gist.githubusercontent.com/BBcan177/4a8bf37c131be4803cb2/raw/343ff780e15205b4dd0de37c86af34cfb26b2fbe/MS-2
* https://raw.githubusercontent.com/anudeepND/youtubeadsblacklist/master/domainlist.txt
* https://blocklist.site/app/dl/spam
* https://hosts.ubuntu101.co.za/domains.list
* https://hosts.ubuntu101.co.za/ips.list


=== PiVpn ===
<pre>
#ajouter un client vpn
static value
  <span style="color: red;font-weight:bold;">pivpn add nopass</span>
            Configures a static value. If you set ip_address then dhcpcd will not attempt to obtain a lease and will just use the value for the address with an infinite lease time. If you
  #pour voir qui est connecté
            set ip6_address, dhcpcd will continue auto-configuration as normal.
<span style="color: red;font-weight:bold;">pivpn clients</span>
==== upgrading ====
[https://github.com/pivpn/pivpn/wiki/Upgrading pivpn/wiki/Upgrading]<br>


Voir la version en cours d'openvpn disponible pour le raspberry<br>
            Here is an example which configures two static address, overriding the default IPv4 broadcast address, an IPv4 router, DNS and disables IPv6 auto-configuration.  You could also
            use the inform6 command here if you wished to obtain more information via DHCPv6.  For IPv4, you should use the inform ipaddress option instead of setting a static address.
                  interface eth0
                  noipv6rs
                  static ip_address=192.168.0.10/24
                  static broadcast_address=192.168.0.63
                  static ip6_address=fd51:42f8:caae:d92e::ff/64
                  static routers=192.168.0.1
                  static domain_name_servers=192.168.0.1 fd51:42f8:caae:d92e::1


[https://packages.debian.org/search?arch=armhf&keywords=openvpn debian dépot armhf]
            Here is an example for PPP which gives the destination a default route. It uses the special destination keyword to insert the destination address into the value.
                  interface ppp0
                  static ip_address=
                  destination routers
</pre>


=== Réseaux ===
=== Lighttpd ===
<syntaxhighlight lang="bash" line copy>
sudo service lighttpd status
sudo service lighttpd restart
</syntaxhighlight>
==== vhost ====
<syntaxhighlight lang="bash" line copy>
ln -s /etc/lighttpd/conf-available/91-exemple.com.conf /etc/lighttpd/conf-enabled/91-exemple.com.conf
</syntaxhighlight>


voir les ip du reseaux et le mac adress
=== Commandes Réseaux ===
<span style="color: red;font-weight:bold;">arp</span>
<syntaxhighlight lang="bash" line>
Pour voir les DNS en cours
# voir les ip du reseaux et le mac adress
<span style="color: red;font-weight:bold;">cat /etc/resolv.conf</span>
arp
<span style="color: red;font-weight:bold;">dig pi-hole.net @127.0.0.1 -p 53</span>
# Pour voir les DNS en cours
table de routage (IPv4/IPv6)
# cat /etc/resolv.conf
<span style="color: red;font-weight:bold;">ip route</span>
dig pi-hole.net @127.0.0.1 -p 53
Vérification des interfaces
# table de routage (IPv4/IPv6)
<span style="color: red;font-weight:bold;">ifconfig</span>
ip route
Lister les ports ouverts et les services réseaux en écoute sur son serveur Linux grâce à netstat.
iip -6 neigh show
<span style="color: red;font-weight:bold;">netstat -lntup</span>
# Vérification des interfaces
Lister tous les ports :
ifconfig
<span style="color: red;font-weight:bold;">netstat -a</span>
# Lister les ports ouverts et les services réseaux en écoute sur son serveur Linux grâce à netstat.
Lister tous les ports TCP :
netstat -lntup
<span style="color: red;font-weight:bold;">netstat -at</span>
# Lister tous les ports :
Lister tous les ports UDP :
netstat -a
<span style="color: red;font-weight:bold;">netstat -au</span>
# Lister tous les ports TCP :
Lister tous les ports en écoute :
netstat -at
<span style="color: red;font-weight:bold;">netstat -l</span>
# Lister tous les ports UDP :
Lister uniquement les ports TCP en écoutes :
netstat -au
<span style="color: red;font-weight:bold;">netstat -lt</span>
# Lister tous les ports en écoute :
Lister uniquement les ports UDP en écoutes :
netstat -l
<span style="color: red;font-weight:bold;">netstat -lu</span>
# Lister uniquement les ports TCP en écoutes :
Afficher les statistique de tous les ports :
netstat -lt
<span style="color: red;font-weight:bold;">netstat -s</span>
# Lister uniquement les ports UDP en écoutes :
Affichier les statistique des Port TCP :
netstat -lu
<span style="color: red;font-weight:bold;">netstat -st</span>
# Afficher les statistique de tous les ports :
Affichier les statistique des Port UDP :
netstat -s
<span style="color: red;font-weight:bold;">netstat -su</span>
# Affichier les statistique des Port TCP :
Affiche le nom du programme et le PID associé :
netstat -st
Cette commande est très utile lorsque vous souhaitez connaitre quel programme est exécuté sur un port particulier.
# Affichier les statistique des Port UDP :
<span style="color: red;font-weight:bold;">netstat -p</span>
netstat -su
Afficher directement les IP et pas de résolution de nom :
# Affiche le nom du programme et le PID associé :
Pour afficher toutes les connexions et tous les ports en écoute mais n’affiche que les adresses IP sans la résolutions des noms.
# Cette commande est très utile lorsque vous souhaitez connaitre quel programme est exécuté sur un port particulier.
<span style="color: red;font-weight:bold;">netstat -an</span>
netstat -p
Affiche le numéro d’identification des processus (PID) associé à chaque connexion :
# Afficher directement les IP et pas de résolution de nom :
<span style="color: red;font-weight:bold;">netstat -o</span>
# Pour afficher toutes les connexions et tous les ports en écoute mais n’affiche que les adresses IP sans la résolutions des noms.
Afficher la table de routage IPV4 et IP6 :
netstat -an
<span style="color: red;font-weight:bold;">netstat -r</span>
# Affiche le numéro d’identification des processus (PID) associé à chaque connexion :
Affichage à un interval de temps régulier en seconde :
netstat -o
netstat -t “temps en seconde” ( Exemple : netstat -t 5 )
# Afficher la table de routage IPV4 et IP6 :
<span style="color: red;font-weight:bold;">netstat -t 5</span>
netstat -r
# Affichage à un interval de temps régulier en seconde :
netstat -t “temps en seconde” #( Exemple : netstat -t 5 )
netstat -t 5
</syntaxhighlight>


1. Lister les machines à explorer
==== 1. Lister les machines à explorer ====
Cette commande va se contenter de lister les machines que nmap explorerait sur le réseau en question.
:Cette commande va se contenter de lister les machines que nmap explorerait sur le réseau en question.
La valeur 24 indique que les trois premières valeurs sont fixes et que seule la dernière va varier.
:La valeur 24 indique que les trois premières valeurs sont fixes et que seule la dernière va varier.
<span style="color: red;font-weight:bold;">nmap -sL 192.168.0.1/24</span>
<syntaxhighlight lang="bash" line>
nmap -sL 192.168.0.1/24
</syntaxhighlight>
==== 2. Scanner les machines du réseau ====
:On va maintenant passer la même commande en faisant un ping sur chaque machine.
<syntaxhighlight lang="bash" line>
nmap -sP 192.168.0.1/24
</syntaxhighlight>
==== 3. Scanner une machine ====
<syntaxhighlight lang="bash" line>
nmap 192.168.0.72
</syntaxhighlight>
==== 4. Scanner une machine plus en détail ====
:On peut en plus activer la détection du système d'exploitation et des versions dans la commande précédente an ajoutant le flag -A:
<syntaxhighlight lang="bash" line>
nmap -A 192.168.0.72
</syntaxhighlight>
:Si maintenant on scanne la Box Internet:
<syntaxhighlight lang="bash" line>
nmap -A 192.168.0.254
</syntaxhighlight>
==== 5. Accélérer le scan de la machine ====
:Le précédent scan ayant duré 17mn, on va essayer d'obtenir un résultat plus rapidement en changeant la politique de temporisation de nmap:
<syntaxhighlight lang="bash" line>
nmap -A -T5 192.168.0.254
</syntaxhighlight>


2. Scanner les machines du réseau
=== Heure ===
On va maintenant passer la même commande en faisant un ping sur chaque machine.
<pre>
<span style="color: red;font-weight:bold;">nmap -sP 192.168.0.1/24</span>
#serveurs NTP
#Fichier de configuration des serveurs NTP : /etc/systemd/timesyncd.conf
#Permet la synchronisation NTP même si aucun serveur DNS n’est joignable :
#NTP=145.238.203.14 145.238.203.10


3. Scanner une machine
#Vérifier la prise en compte du serveur avec
<span style="color: red;font-weight:bold;">nmap 192.168.0.72</span>
systemctl status systemd-timesyncd.service
timedatectl status
timedatectl set-timezone "Europe/Paris"
timedatectl set-ntp true
</pre>
* [https://www.jbnet.fr/systeme/raspbian/raspberry-pi-installation-mode-serveur.html www.jbnet.fr]


4. Scanner une machine plus en détail
=== Voir version installé ===
On peut en plus activer la détection du système d'exploitation et des versions dans la commande précédente an ajoutant le flag -A:
<pre>
<span style="color: red;font-weight:bold;">nmap -A 192.168.0.72</span>
Sur les systèmes similaires à Debian, dans le dossier /proc :
 
“cpuinfo” contient des informations sur votre processeur.
Si maintenant on scanne la Box Internet:
“meminfo” concerne la RAM.
<span style="color: red;font-weight:bold;">nmap -A 192.168.0.254</span>
</pre>
 
5. Accélérer le scan de la machine
Le précédent scan ayant duré 17mn, on va essayer d'obtenir un résultat plus rapidement en changeant la politique de temporisation de nmap:
<span style="color: red;font-weight:bold;">nmap -A -T5 192.168.0.254</span>


[[Catégorie: Raspian]]
[[Catégorie: Raspian]]