La configuration serveur peut être la même sous Debian et sous OpenBSD => on homogénéise + changement ordre
This commit is contained in:
parent
df757aa715
commit
bcf3822eaa
151
HowtoOpenVPN.md
151
HowtoOpenVPN.md
|
@ -85,8 +85,6 @@ La configuration se fait via le fichier `/etc/openvpn/server.conf` avec les para
|
|||
* `push` : route vers le réseau que les clients VPN pourront joindre
|
||||
* `ifconfig-pool-persist` : permet aux clients de conserver la même IP en cas de redémarrage
|
||||
|
||||
### Serveur sous Debian
|
||||
|
||||
~~~
|
||||
user nobody
|
||||
group nogroup
|
||||
|
@ -97,12 +95,15 @@ proto udp
|
|||
dev tun
|
||||
mode server
|
||||
keepalive 10 120
|
||||
tls-exit
|
||||
|
||||
cipher AES-256-GCM # AES
|
||||
|
||||
persist-key
|
||||
persist-tun
|
||||
|
||||
ifconfig-pool-persist /etc/openvpn/ipp.txt
|
||||
|
||||
status /var/log/openvpn-status.log
|
||||
log-append /var/log/openvpn.log
|
||||
|
||||
|
@ -115,12 +116,59 @@ crl-verify /etc/shellpki/crl.pem
|
|||
|
||||
server 192.0.2.0 255.255.255.0
|
||||
|
||||
push "route 192.0.3.0 255.255.255.0"
|
||||
#push "route 192.0.3.0 255.255.255.0"
|
||||
|
||||
# Management interface (used by check_openvpn for Nagios)
|
||||
management 127.0.0.1 1195 /etc/openvpn/management-pwd
|
||||
~~~
|
||||
|
||||
Générer un mot de passe pour l'accès à l'interface de management (nécessaire au check Nagios) :
|
||||
|
||||
~~~
|
||||
# apg -n1 -m 12 > /etc/openvpn/management-pwd
|
||||
~~~
|
||||
|
||||
On peut utiliser le [check NRPE OpenVPN suivant](https://gitea.evolix.org/evolix/ansible-roles/raw/branch/unstable/openvpn/files/check_openvpn.pl) (sous OpenBSD, modifier la ligne `use lib "/usr/lib/nagios/plugins/";` par `use lib "/usr/local/libexec/nagios/";`)
|
||||
|
||||
~~~
|
||||
## Debian
|
||||
# apt install libnet-telnet-perl
|
||||
# /usr/local/lib/nagios/plugins/check_openvpn -H 127.0.0.1 -p 1195 -P $MANAGEMENT_PWD
|
||||
|
||||
## OpenBSD
|
||||
# pkg_add p5-Net-Telnet
|
||||
# /usr/local/libexec/nagios/plugins/check_openvpn.pl -H 127.0.0.1 -p 1195 -P $MANAGEMENT_PWD
|
||||
~~~
|
||||
|
||||
On peut également utiliser le [check NRPE suivant](https://gitea.evolix.org/evolix/ansible-roles/raw/branch/unstable/openvpn/files/check_openvpn_certificates.sh) pour monitorer les dates d'expirations de la CA et du certificat serveur:
|
||||
|
||||
~~~
|
||||
## Debian
|
||||
# visudo -f /etc/sudoers.d/openvpn
|
||||
nagios ALL=NOPASSWD: /usr/local/lib/nagios/plugins/check_openvpn_certificates.sh
|
||||
# sudo /usr/local/lib/nagios/plugins/check_openvpn_certificates.sh
|
||||
|
||||
## OpenBSD
|
||||
# vim /etc/doas.conf
|
||||
permit nopass _nrpe as root cmd /usr/local/libexec/nagios/plugins/check_openvpn_certificates.sh
|
||||
# doas /usr/local/libexec/nagios/plugins/check_openvpn_certificates.sh
|
||||
~~~
|
||||
|
||||
Un script [cert-expirations.sh](https://gitea.evolix.org/evolix/shellpki/raw/branch/dev/cert-expirations.sh) peut être mis en cron pour avertir régulièrement des prochaines expirations des certificats clients et serveur :
|
||||
|
||||
~~~
|
||||
@monthly /usr/share/scripts/cert-expirations.sh | mail -E -s "PKI VPN XXX : recapitulatif expirations" mail@example.com
|
||||
~~~
|
||||
|
||||
Penser à remplacer :
|
||||
|
||||
* L'horaire d'exécution du cron, si voulu ;
|
||||
* L'emplacement des certificats dans le script (/etc/shellpki/certs/), ceux-ci peuvent se trouver dans "/etc/openvpn/ssl/certs/" ou ailleurs encore ;
|
||||
* Le nom du serveur XXX dans le sujet "PKI VPN XXX" ;
|
||||
* L'adresse mail de contact.
|
||||
|
||||
### Serveur sous Debian
|
||||
|
||||
Il ne faut pas oublier le changement suivant à ajouter dans `/etc/default/minifirewall` (en remplaçant `192.0.2.0/24` par le réseau utilisé dans le paramètre `server`) :
|
||||
|
||||
~~~
|
||||
|
@ -148,58 +196,8 @@ Le service s'active et se démarre ensuite via :
|
|||
# systemctl start openvpn@server.service
|
||||
~~~
|
||||
|
||||
|
||||
### Serveur sous OpenBSD
|
||||
|
||||
~~~
|
||||
daemon
|
||||
|
||||
port 1194
|
||||
proto udp
|
||||
dev tap0
|
||||
dev-type tap
|
||||
verb 3
|
||||
|
||||
user nobody
|
||||
group nobody
|
||||
chroot /var/empty
|
||||
|
||||
max-clients 50
|
||||
keepalive 15 120
|
||||
tls-exit
|
||||
persist-key
|
||||
persist-tun
|
||||
client-to-client
|
||||
resolv-retry infinite
|
||||
|
||||
local 198.51.100.1
|
||||
server 192.0.2.0 255.255.255.0
|
||||
#client-to-client
|
||||
ifconfig-pool-persist /etc/openvpn/ipp.txt
|
||||
#route-method exe
|
||||
#route-delay 2
|
||||
push "route 203.0.113.0 255.255.255.0 192.0.2.1"
|
||||
|
||||
ca /etc/openvpn/ssl/ca/cacert.pem
|
||||
dh /etc/openvpn/ssl/ca/dh2048.pem
|
||||
|
||||
cert /etc/openvpn/ssl/files/fw.vpn.example.com-1278421834/fw.vpn.example.com.crt
|
||||
key /etc/openvpn/ssl/files/fw.vpn.example.com-1278421834/fw.vpn.example.com.key
|
||||
|
||||
crl-verify /etc/shellpki/crl.pem
|
||||
|
||||
log-append /var/log/openvpn.log
|
||||
status /var/log/openvpn-status.log
|
||||
|
||||
cipher AES-256-GCM # AES
|
||||
|
||||
#fragment 1350
|
||||
#mssfix
|
||||
|
||||
# Management interface (used by check_openvpn for Nagios)
|
||||
management 127.0.0.1 1195 /etc/openvpn/management-pwd
|
||||
~~~
|
||||
|
||||
On autorise la connexion au serveur VPN en modifiant `/etc/pf.conf` :
|
||||
|
||||
~~~
|
||||
|
@ -248,53 +246,6 @@ Ainsi que plannifier en crontab un restart d'OpenVPN juste après cette rotation
|
|||
0 4 * * 6 cp /var/log/openvpn.log /var/log/openvpn.log.$(date +\%F) && echo "$(date +\%F' '\%R) - logfile turned over via cron" > /var/log/openvpn.log && gzip /var/log/openvpn.log.$(date +\%F) && find /var/log/ -type f -name "openvpn.log.*" -mtime +365 -exec rm {} \+
|
||||
~~~
|
||||
|
||||
### Commun à Debian et OpenBSD
|
||||
|
||||
Générer un mot de passe pour l'accès à l'interface de management (nécessaire au check Nagios) :
|
||||
|
||||
~~~
|
||||
# apg -n1 -m 12 > /etc/openvpn/management-pwd
|
||||
~~~
|
||||
|
||||
On peut utiliser le [check NRPE OpenVPN suivant](https://gitea.evolix.org/evolix/ansible-roles/raw/branch/unstable/openvpn/files/check_openvpn.pl) (sous OpenBSD, modifier la ligne `use lib "/usr/lib/nagios/plugins/";` par `use lib "/usr/local/libexec/nagios/";`)
|
||||
|
||||
~~~
|
||||
## Debian
|
||||
# apt install libnet-telnet-perl
|
||||
# /usr/local/lib/nagios/plugins/check_openvpn -H 127.0.0.1 -p 1195 -P $MANAGEMENT_PWD
|
||||
|
||||
## OpenBSD
|
||||
# pkg_add p5-Net-Telnet
|
||||
# /usr/local/libexec/nagios/plugins/check_openvpn.pl -H 127.0.0.1 -p 1195 -P $MANAGEMENT_PWD
|
||||
~~~
|
||||
|
||||
On peut également utiliser le [check NRPE suivant](https://gitea.evolix.org/evolix/ansible-roles/raw/branch/unstable/openvpn/files/check_openvpn_certificates.sh) pour monitorer les dates d'expirations de la CA et du certificat serveur:
|
||||
|
||||
~~~
|
||||
## Debian
|
||||
# visudo -f /etc/sudoers.d/openvpn
|
||||
nagios ALL=NOPASSWD: /usr/local/lib/nagios/plugins/check_openvpn_certificates.sh
|
||||
# sudo /usr/local/lib/nagios/plugins/check_openvpn_certificates.sh
|
||||
|
||||
## OpenBSD
|
||||
# vim /etc/doas.conf
|
||||
permit nopass _nrpe as root cmd /usr/local/libexec/nagios/plugins/check_openvpn_certificates.sh
|
||||
# doas /usr/local/libexec/nagios/plugins/check_openvpn_certificates.sh
|
||||
~~~
|
||||
|
||||
Un script [cert-expirations.sh](https://gitea.evolix.org/evolix/shellpki/raw/branch/dev/cert-expirations.sh) peut être mis en cron pour avertir régulièrement des prochaines expirations des certificats clients et serveur :
|
||||
|
||||
~~~
|
||||
@monthly /usr/share/scripts/cert-expirations.sh | mail -E -s "PKI VPN XXX : recapitulatif expirations" mail@example.com
|
||||
~~~
|
||||
|
||||
Penser à remplacer :
|
||||
|
||||
* L'horaire d'exécution du cron, si voulu ;
|
||||
* L'emplacement des certificats dans le script (/etc/shellpki/certs/), ceux-ci peuvent se trouver dans "/etc/openvpn/ssl/certs/" ou ailleurs encore ;
|
||||
* Le nom du serveur XXX dans le sujet "PKI VPN XXX" ;
|
||||
* L'adresse mail de contact.
|
||||
|
||||
## Configuration client
|
||||
|
||||
Pour simplifier la configuration pour les utilisateurs finaux on peut générer un fichier de configuration embarquant les certificats :
|
||||
|
|
Loading…
Reference in a new issue