\documentclass[a4paper,11pt]{report}

	\input{../includes/headers_global.tex}

	\def\sitename{Debian GNU/Linux :: Serveur }
	\def\shorttitre{VPN IPSec}
	\def\titre{Serveur VPN : Racoon}
	\def\autheur{Matthieu Vogelweith}
	\def\subject{Mise en place d'un VPN Ipsec sous Debian GNU/Linux}
	\def\keywords{Debian, Linux, Matthieu, Vogelweith, Serveur, Etch, VPN, SSL, IPsec, racoon, FreeRadius, LDAP, dns, resolvconf}

	\input{../includes/headers.tex}

\begin{document}

\renewcommand{\bibname}{R\'ef\'erences}

\begin{titlepage}
	\maketitle
\end{titlepage}

\chapter*{Résumé}

	Racoon IPSec\\
	...\\

	L'objectif de ce document est de détailler la mise en place d'un VPN IPsec avec authentification LDAP (via FreeRadius) entre 2 passerelles puis entre un "roadwarrior" et une passerelle.

\input{../includes/licence.tex}

\tableofcontents
		
\chapter{Introduction}

- Permet d'établir un tunnel inter-site, éventuellement avec un concentrateur matériel (Cisco PIX, Netopia, ...)\\
- Permet de donner un accès complet aux roadwarriors\\

\chapter{Préparation de la passerelle}

	\section{Installation des paquets}

\vspace{1em}
\begin{lstlisting} 
# aptitude install racoon ipsec-tools
\end{lstlisting}
\vspace{1em}

    \section{Certificats SSL}

Création de l'autorité de certification

\vspace{1em}
\begin{lstlisting} 
# openssl genrsa -des3 -out /etc/ssl/private/ca.key 2048
# openssl req -new -x509 -days 3650 -key /etc/ssl/private/ca.key -out /etc/ssl/certs/ca.pem
\end{lstlisting}
\vspace{1em}

Création de la demande de signature :

\vspace{1em}
\begin{lstlisting} 
# openssl genrsa -out /etc/ssl/private/vpn.key 2048
# openssl req -new -key /etc/ssl/private/vpn.key -out /etc/ssl/certs/vpn.csr
\end{lstlisting}
\vspace{1em}

Signature du certificat :

\vspace{1em}
\begin{lstlisting} 
# openssl x509 -req -days 3650 -CAcreateserial \
    -in /etc/ssl/certs/vpn.csr -out /etc/ssl/certs/vpn.pem \
    -CA /etc/ssl/certs/ca.pem -CAkey /etc/ssl/private/ca.key \
\end{lstlisting}
\vspace{1em}

	\section{Configuration de base}

- distribution des routes\\
- distribution des DNS\\

	\section{Configuration de Shorewall}

Dans /etc/shorewall/zones :

\vspace{1em}
\begin{lstlisting} 
net    ipv4
lan    ipv4
vpn    ipsec
\end{lstlisting}
\vspace{1em}

Dans /etc/shorewall/tunnels :

\vspace{1em}
\begin{lstlisting} 
ipsec       net     0.0.0.0/0   vpn
ipsecnat    net     0.0.0.0/0   vpn
\end{lstlisting}
\vspace{1em}

Dans /etc/shorewall/hosts :

\vspace{1em}
\begin{lstlisting} 
vpn         ppp0:0.0.0.0/0
\end{lstlisting}
\vspace{1em}

Dans /etc/shorewall/policy :

\vspace{1em}
\begin{lstlisting} 
vpn         lan     ACCEPT
\end{lstlisting}
\vspace{1em}

\chapter{Tunnel de passerelle à passerelle}

	\section{Principe}

- schéma\\


\chapter{Configuration en mode "RoadWarrior"}

	\section{Principe}

- l'adresse du clients n'est pas déterminable à l'avance\\
- schéma\\

	\section{Configuration de la passerelle}

Dans /etc/racoon/racoon.conf :

\vspace{1em}
\begin{lstlisting} 
listen {
    adminsock disabled;
}

remote anonymous {
    exchange_mode aggressive;
    certificate_type x509 "/etc/ssl/certs/vpn.pem" "/etc/ssl/private/vpn.key";
    ca_type x509 "/etc/ssl/certs/ca.pem";
    my_identifier asn1dn;
    proposal_check claim;
    generate_policy on;
    nat_traversal on;
    dpd_delay 20;
    ike_frag on;
    proposal {
        encryption_algorithm aes;
        hash_algorithm sha1;
        authentication_method hybrid_rsa_server;
        dh_group 2;
    }
}

mode_cfg {
    network4 192.168.100.1;     # 192.168.100.1 est la premiere adresse allouee aux clients VPN
    pool_size 20;
    netmask4 255.255.255.0;
    auth_source system;
    dns4 192.168.200.254;       # 192.168.200.254 est l'adresse du DNS dans le reseau local distant
    banner "/etc/racoon/motd";
    pfs_group 2;
}

sainfo anonymous {
    pfs_group 2;
    lifetime time 1 hour;
    encryption_algorithm aes;
    authentication_algorithm hmac_sha1;
    compression_algorithm deflate;
}
\end{lstlisting}
\vspace{1em}


\chapter{Clients "RoadWarrior" Linux}

	\section{Installation des paquets}

Les clients Linux utilisent également Racoon pour établir le tunnel avec le concentrateur VPN.

\vspace{1em}
\begin{lstlisting} 
# aptitude install racoon ipsec-tools
# cp /usr/share/doc/racoon/examples/samples/roadwarrior/client/phase1-*.sh /etc/racoon/
\end{lstlisting}
\vspace{1em}

	\section{Configuration de Racoon}

Dans /etc/racoon/racoon.conf :

\vspace{1em}
\begin{lstlisting} 
path pre_shared_key "/etc/racoon/psk.txt";

listen {
    adminsock "/var/run/racoon/racoon.sock" "root" "operator" 0660;
}

# 1.2.3.4 est l'adresse publique de la passerelle VPN
remote 1.2.3.4 {

    exchange_mode aggressive;
    ca_type x509 "/etc/ssl/certs/vpn.pem";
    proposal_check obey;
    nat_traversal on;
    ike_frag on;
    mode_cfg on;

    script "/etc/racoon/phase1-up.sh" phase1_up;
    script "/etc/racoon/phase1-down.sh" phase1_down;

    verify_cert off;
    passive off;

    proposal {
        encryption_algorithm aes;
        hash_algorithm sha1;
        authentication_method hybrid_rsa_client;
        dh_group 2;
    }
}

sainfo anonymous {
    pfs_group 2;
    lifetime time 1 hour;
    encryption_algorithm aes;
    authentication_algorithm hmac_sha1;
    compression_algorithm deflate ;
}
\end{lstlisting}
\vspace{1em}

	\section{Configuration de Shorewall}

Dans /etc/shorewall/zones :

\vspace{1em}
\begin{lstlisting} 
net    ipv4
wlan   ipv4
vpn    ipsec
\end{lstlisting}
\vspace{1em}

Dans /etc/shorewall/tunnels :

\vspace{1em}
\begin{lstlisting} 
ipsec       net         0.0.0.0/0       vpn
ipsecnat    net         0.0.0.0/0       vpn
ipsec       wlan        0.0.0.0/0       vpn
ipsecnat    wlan        0.0.0.0/0       vpn
\end{lstlisting}
\vspace{1em}

Dans /etc/shorewall/hosts :

\vspace{1em}
\begin{lstlisting} 
vpn         eth0:0.0.0.0/0
vpn         wlan0:0.0.0.0/0
\end{lstlisting}
\vspace{1em}

    \section{Gestion du tunnel}

- établissement du tunnel :

\vspace{1em}
\begin{lstlisting} 
# racoonctl vc -u <mon_login> 1.2.3.4
\end{lstlisting}
\vspace{1em}

- fermeture du tunnel :

\vspace{1em}
\begin{lstlisting} 
# racoonctl vd 1.2.3.4
\end{lstlisting}
\vspace{1em}

\chapter{Clients "RoadWarrior" Mac OS X}

Sous MacOS X, c'est également Racoon qui est utiliser pour établir les tunnels IPSec. Il existe ensuite plusieurs interfaces graphiques permettant de configurer Racoon le plus simplement possible.

Sous MacOS 10.4, l'interface native fournie par Apple est assez simpliste et ne permet pas d'établir le tunnel IPSec dans tous les cas de figure. Il y a donc deux solutions pour configurer correctement Racoon :
\begin{itemize}
    \item Configuration manuelle comme sous linux.
    \item Utilisation d'une autre interface à Racoon comme IPSecuritas \cite{ipsecuritas}.
\end{itemize}

Avec MacOS 10.5 le support des VPN IPSec est beaucoup plus complet et il est possible de tout faire avec le client natif. http://www.jacco2.dds.nl/networking/openswan-macosx.html\#Certs

\chapter{Clients "RoadWarrior" Windows}

Le client natif de windows est assez limité mais il existe un très bon client IPSec gratuit développé par Shrew Soft \cite{shrewsoft}.

\clearpage
\nocite{*}
\bibliographystyle{unsrt}
\bibliography{\jobname}

%\ifpdf
%\else
%\chapter{Vos commentaires}
%\fi
\end{document}
