Files
mkdocs/docs/Raspberry/reseau.md
2019-03-15 20:20:37 +01:00

311 lines
5.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Réseau et partage
#### Configurer le réseau wifi:
```bash
$ nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=FR
network={
ssid="Bart_nomap"
psk="ma_clef_wifi"
key_mgmt=WPA-PSK
}
```
#### Encoder le mot de passe:
```bash
$ wpa_passphrase "Bart_nomap"
# reading passphrase from stdin
ma_clef_wifi
network={
ssid="Bart_nomap"
#psk="ma_clef_wifi"
psk=40e6467b0ab3569a63dfe33001abb3a6b8757989937091f3edf7c9d9bd508ede7
}
```
```bash
$ nano /etc/network/interfaces
### (ne pas changer !!!) ###
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
```
#### Adresses IP:
```bash
$ ip -4 addr | grep global
inet 192.168.1.254/24 brd 192.168.1.255 scope global eth0
inet 192.168.1.21/24 brd 192.168.1.255 scope global wlan0
```
#### Adresse du routeur (gateway):
```bash
$ ip route | grep default | awk '{print $3}'
192.168.1.1
192.168.1.1
```
#### Adresse du serveur DNS:
```bash
$ cat /etc/resolv.conf
# Generated by resolvconf
domain home
nameserver 192.168.1.1
nameserver fe80::4265:a3ff:fec3:8132%eth0
nameserver fe80::4265:a3ff:fec3:8132%wlan0
```
#### Liste des noms d'interface
```bash
$ ls /sys/class/net
eth0 lo wlan0
```
#### Mettre en IP fixe:
```bash
$ sudo nano /etc/dhcpcd.conf
# à rajouter à la fin du fichier:
interface eth0
static ip_address=192.168.1.254/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
interface wlan0
static ip_address=192.168.1.253/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
```
#### VNC:
*VNC Server (Pi):*
Menu → Options:
- Sécurité:
- Chiffrement: De préférence actif
- Authentification: Mot de passe VNC
- Utilisateurs et autorisations:
- Utilisateur standart: Mot de passe
*VNC Viewer (Mac):*
Port 5900
#### SSH:
Changer le port par défaut (22):
```bash
$ sudo nano sshd_config
#Décommenter la ligne # Port 22 et modifier le port
Port 39517
$ sudo service ssh restart
```
#### Ajouter la clé ssh:
```bash
bruno@silverbook:~/.ssh$ ssh pi@framboise.local 'mkdir -p ~/.ssh; chmod 0700 ~/.ssh; echo ' $(< ~/.ssh/id_ed25519.pub) ' >> ~/.ssh/authorized_keys ; chmod 0600 ~/.ssh/authorized_keys'
```
#### Installer Samba:
Installer et créer un répertoire partagé:
```bash
$ sudo apt-get install apt-transport-https samba samba-common-bin
$ sudo mkdir -p /home/pi/share
$ sudo chown -hR pi:pi /home/pi/share
$ sudo chmod 777 /home/pi/share
```
#### Sauvegarder le fichier de configuration
```bash
$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
```
#### Editer le fichier smb.conf:
```bash
$ sudo nano /etc/samba/smb.conf
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
wins support = yes
####### Authentication #######
security = user
[homes]
read only = no
[Share]
comment = Partage Samba sur Raspberry
path=/home/pi/share
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
```
#### Créer un utilisateur Samba:
```bash
$ sudo smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi.
```
#### Tester la config Samba:
```bash
$ testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
WARNING: The "syslog" option is deprecated
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[Share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
usershare allow guests = Yes
map to guest = Bad User
obey pam restrictions = Yes
pam password change = Yes
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
server role = standalone server
unix password sync = Yes
dns proxy = No
wins support = Yes
idmap config * : backend = tdb
[homes]
comment = Home Directories
browseable = No
create mask = 0700
directory mask = 0700
valid users = %S
[printers]
comment = All Printers
path = /var/spool/samba
browseable = No
printable = Yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[Share]
comment = Partage Samba sur Raspberry
path = /home/pi/share
create mask = 0777
directory mask = 0777
read only = No
```
**Messages d'erreurs:**
`rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)`
```bash
# Global files limit:
$ cat /proc/sys/fs/file-max
88603
# Local files limit:
$ ulimit -Hn
1048576
$ ulimit -Sn
1024
# Modifier temporairement les limites:
ulimit -Hn n
ulimit -Sn m
# Modifier les limites:
Editer /etc/security/limits.conf et ajouter:
samba soft nofile 16384
samba hard nofile 32768
```
`WARNING: The "syslog" option is deprecated`
commenter la ligne syslog: `#syslog = 0`
#### Redémarrer Samba:
```bash
$ sudo /etc/init.d/samba restart
```
#### Liens:
[:fa-link: http://nagashur.com/blog/2016/07/21/partage-de-fichiers-samba-avec-le-raspberry-pi/](http://nagashur.com/blog/2016/07/21/partage-de-fichiers-samba-avec-le-raspberry-pi/)
[:fa-link: https://gist.github.com/masterT/407a6d9e30ba4169bb39](https://gist.github.com/masterT/407a6d9e30ba4169bb39)
[:fa-link: http://www.framboise314.fr/partager-un-repertoire-sous-jessie-avec-samba/](http://www.framboise314.fr/partager-un-repertoire-sous-jessie-avec-samba/)