2004-02-14 19:06:39 +01:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
|
|
|
<article id="OPENVPN">
|
|
|
|
<!--$Id$-->
|
|
|
|
|
|
|
|
<articleinfo>
|
2005-10-22 19:37:38 +02:00
|
|
|
<title>OpenVPN Tunnels and Bridges</title>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<authorgroup>
|
|
|
|
<author>
|
2004-12-25 04:13:18 +01:00
|
|
|
<firstname>Simon</firstname>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2005-10-12 21:23:11 +02:00
|
|
|
<surname>Matter</surname>
|
2004-02-14 19:06:39 +01:00
|
|
|
</author>
|
|
|
|
|
|
|
|
<author>
|
2004-12-25 04:13:18 +01:00
|
|
|
<firstname>Tom</firstname>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-12-25 04:13:18 +01:00
|
|
|
<surname>Eastep</surname>
|
2004-02-14 19:06:39 +01:00
|
|
|
</author>
|
|
|
|
</authorgroup>
|
|
|
|
|
2005-10-25 18:47:38 +02:00
|
|
|
<pubdate>2005-10-25</pubdate>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<copyright>
|
|
|
|
<year>2003</year>
|
|
|
|
|
2005-02-06 20:21:18 +01:00
|
|
|
<year>2004</year>
|
|
|
|
|
|
|
|
<year>2005</year>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<holder>Simon Mater</holder>
|
2004-12-25 04:13:18 +01:00
|
|
|
|
|
|
|
<holder>Thomas M. Eastep</holder>
|
2004-02-14 19:06:39 +01:00
|
|
|
</copyright>
|
|
|
|
|
|
|
|
<legalnotice>
|
|
|
|
<para>Permission is granted to copy, distribute and/or modify this
|
|
|
|
document under the terms of the GNU Free Documentation License, Version
|
|
|
|
1.2 or any later version published by the Free Software Foundation; with
|
|
|
|
no Invariant Sections, with no Front-Cover, and with no Back-Cover
|
|
|
|
Texts. A copy of the license is included in the section entitled
|
2004-09-24 00:50:12 +02:00
|
|
|
<quote><ulink url="GnuCopyright.htm">GNU Free Documentation
|
|
|
|
License</ulink></quote>.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
</legalnotice>
|
|
|
|
</articleinfo>
|
|
|
|
|
2005-09-04 01:03:06 +02:00
|
|
|
<caution>
|
|
|
|
<para><emphasis role="bold">This article applies to Shorewall 3.0 and
|
2005-10-13 16:59:02 +02:00
|
|
|
later and to OpenVPN 2.0 and later. If you are running a version of
|
|
|
|
Shorewall earlier than Shorewall 3.0.0 then please see the documentation
|
|
|
|
for that release.</emphasis></para>
|
2005-09-04 01:03:06 +02:00
|
|
|
</caution>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>OpenVPN is a robust and highly configurable VPN (Virtual Private
|
|
|
|
Network) daemon which can be used to securely link two or more private
|
|
|
|
networks using an encrypted tunnel over the internet. OpenVPN is an Open
|
|
|
|
Source project and is <ulink
|
2004-09-24 00:50:12 +02:00
|
|
|
url="http://openvpn.sourceforge.net/license.html">licensed under the
|
|
|
|
GPL</ulink>. OpenVPN can be downloaded from <ulink
|
2005-02-22 00:18:35 +01:00
|
|
|
url="http://openvpn.net/">http://openvpn.net/</ulink>.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2005-10-14 04:29:36 +02:00
|
|
|
<para>Unless there are interoperability issues (the remote systems do not
|
|
|
|
support OpenVPN), OpenVPN is my choice any time that I need a VPN.</para>
|
|
|
|
|
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>It is widely supported -- I run it on both Linux and Windows
|
|
|
|
XP.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>It requires no kernel patching.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>It is very easy to configure.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>It just works!</para>
|
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
|
2004-12-25 04:13:18 +01:00
|
|
|
<section>
|
|
|
|
<title>Preliminary Reading</title>
|
|
|
|
|
|
|
|
<para>I recommend reading the <ulink url="VPNBasics.html">VPN
|
|
|
|
Basics</ulink> article if you plan to implement any type of VPN.</para>
|
|
|
|
</section>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<section>
|
|
|
|
<title>Bridging two Masqueraded Networks</title>
|
|
|
|
|
|
|
|
<para>Suppose that we have the following situation:</para>
|
|
|
|
|
|
|
|
<graphic fileref="images/TwoNets1.png" />
|
|
|
|
|
|
|
|
<para>We want systems in the 192.168.1.0/24 subnetwork to be able to
|
|
|
|
communicate with the systems in the 10.0.0.0/8 network. This is
|
2004-09-24 00:50:12 +02:00
|
|
|
accomplished through use of the
|
|
|
|
<filename>/etc/shorewall/tunnels</filename> file and the
|
|
|
|
<filename>/etc/shorewall/policy file</filename> and OpenVPN.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<para>While it was possible to use the Shorewall start and stop script to
|
|
|
|
start and stop OpenVPN, I decided to use the init script of OpenVPN to
|
|
|
|
start and stop it.</para>
|
|
|
|
|
|
|
|
<para>On each firewall, you will need to declare a zone to represent the
|
2004-09-24 00:50:12 +02:00
|
|
|
remote subnet. We'll assume that this zone is called <quote>vpn</quote>
|
|
|
|
and declare it in <filename>/etc/shorewall/zones</filename> on both
|
|
|
|
systems as follows.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<para><filename>/etc/shorewall/zones</filename> — Systems A &
|
|
|
|
B</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2005-09-04 01:03:06 +02:00
|
|
|
<programlisting>#ZONE TYPE OPTIONS IN OUT
|
|
|
|
# OPTIONS OPTIONS
|
2005-09-30 19:39:24 +02:00
|
|
|
vpn ipv4</programlisting>
|
2004-09-24 00:50:12 +02:00
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<para>On system A, the 10.0.0.0/8 will comprise the <emphasis
|
|
|
|
role="bold">vpn</emphasis> zone.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<para>In <filename>/etc/shorewall/interfaces</filename> on system
|
|
|
|
A:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
|
|
|
vpn tun0</programlisting>
|
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<para>In <filename>/etc/shorewall/tunnels</filename> on system A, we need
|
|
|
|
the following:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpn net 134.28.54.2</programlisting>
|
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<para>This entry in <filename>/etc/shorewall/tunnels</filename> opens the
|
2004-12-27 16:39:58 +01:00
|
|
|
firewall so that OpenVPN traffic on the default port 1194/udp will be
|
2004-09-24 00:50:12 +02:00
|
|
|
accepted to/from the remote gateway. If you change the port used by
|
|
|
|
OpenVPN to 7777, you can define /etc/shorewall/tunnels like this:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
2004-09-30 17:30:35 +02:00
|
|
|
<para>/etc/shorewall/tunnels with port 7777:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
2004-09-30 17:30:35 +02:00
|
|
|
openvpn:7777 net 134.28.54.2</programlisting>
|
2004-09-24 00:50:12 +02:00
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2005-10-18 17:58:41 +02:00
|
|
|
<para>Similarly, if you want to use TCP for your tunnel rather than UDP
|
|
|
|
(the default), then you can define /etc/shorewall/tunnels like
|
|
|
|
this:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para>/etc/shorewall/tunnels using TCP:</para>
|
|
|
|
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpn:tcp net 134.28.54.2</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>Finally, if you want to use TCP and port 7777:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para>/etc/shorewall/tunnels using TCP port 7777:</para>
|
|
|
|
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpn:tcp:7777 net 134.28.54.2</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>This is the OpenVPN config on system A:</para>
|
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<programlisting>dev tun
|
2004-02-14 19:06:39 +01:00
|
|
|
local 206.162.148.9
|
|
|
|
remote 134.28.54.2
|
|
|
|
ifconfig 192.168.99.1 192.168.99.2
|
|
|
|
up ./route-a.up
|
|
|
|
tls-server
|
|
|
|
dh dh1024.pem
|
|
|
|
ca ca.crt
|
|
|
|
cert my-a.crt
|
|
|
|
key my-a.key
|
|
|
|
comp-lzo
|
|
|
|
verb 5</programlisting>
|
2004-09-24 00:50:12 +02:00
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<para>Similarly, On system B the 192.168.1.0/24 subnet will comprise the
|
2004-09-24 00:50:12 +02:00
|
|
|
<emphasis role="bold">vpn</emphasis> zone</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<para>In <filename>/etc/shorewall/interfaces</filename> on system
|
|
|
|
B:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
|
|
|
vpn tun0 192.168.1.255</programlisting>
|
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<para>In <filename>/etc/shorewall/tunnels</filename> on system B, we
|
|
|
|
have:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpn net 206.191.148.9</programlisting>
|
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<para>And in the OpenVPN config on system B:</para>
|
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<programlisting>dev tun
|
2004-02-14 19:06:39 +01:00
|
|
|
local 134.28.54.2
|
|
|
|
remote 206.162.148.9
|
|
|
|
ifconfig 192.168.99.2 192.168.99.1
|
|
|
|
up ./route-b.up
|
|
|
|
tls-client
|
|
|
|
ca ca.crt
|
|
|
|
cert my-b.crt
|
|
|
|
key my-b.key
|
|
|
|
comp-lzo
|
|
|
|
verb 5</programlisting>
|
2004-09-24 00:50:12 +02:00
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<para>You will need to allow traffic between the <quote>vpn</quote> zone
|
|
|
|
and the <quote>loc</quote> zone on both systems -- if you simply want to
|
|
|
|
admit all traffic in both directions, you can use the policy file:</para>
|
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<blockquote>
|
|
|
|
<para><filename>/etc/shorewall/policy </filename>on systems A &
|
|
|
|
B</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<programlisting>#SOURCE DEST POLICY LOG LEVEL
|
|
|
|
loc vpn ACCEPT
|
|
|
|
vpn loc ACCEPT</programlisting>
|
|
|
|
</blockquote>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
|
|
|
<para>On both systems, restart Shorewall and start OpenVPN. The systems in
|
|
|
|
the two masqueraded subnetworks can now talk to each other.</para>
|
|
|
|
</section>
|
2004-12-21 17:55:29 +01:00
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Roadwarrior</title>
|
|
|
|
|
|
|
|
<para>OpenVPN 2.0 provides excellent support for roadwarriors. Consider
|
|
|
|
the setup in the following diagram:</para>
|
|
|
|
|
|
|
|
<graphic fileref="images/Mobile.png" />
|
|
|
|
|
|
|
|
<para>On the gateway system (System A), we need a zone to represent the
|
|
|
|
remote clients — we'll call that zone <quote>road</quote>.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para><filename>/etc/shorewall/zones</filename> — System A:</para>
|
|
|
|
|
2005-09-04 01:03:06 +02:00
|
|
|
<programlisting>#ZONE TYPE OPTIONS IN OUT
|
|
|
|
# OPTIONS OPTIONS
|
2005-09-30 19:39:24 +02:00
|
|
|
road ipv4</programlisting>
|
2004-12-21 17:55:29 +01:00
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>On system A, the remote clients will comprise the <emphasis
|
|
|
|
role="bold">road</emphasis> zone.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para>In <filename>/etc/shorewall/interfaces</filename> on system
|
|
|
|
A:</para>
|
|
|
|
|
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
|
|
|
road tun+</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>In <filename>/etc/shorewall/tunnels</filename> on system A, we need
|
|
|
|
the following:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpn:1194 net 0.0.0.0/0</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2005-08-27 23:47:09 +02:00
|
|
|
<para>If you are running Shorewall 2.4.3 or later, you might prefer the
|
|
|
|
following in <filename>/etc/shorewall/tunnels</filename> on system A.
|
|
|
|
Specifying the tunnel type as openvpnserver has the advantage that the VPN
|
|
|
|
connection will still work if the client is behind a gateway/firewall that
|
|
|
|
uses NAT.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpnserver:1194 net 0.0.0.0/0</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
<para>We want the remote systems to have access to the local LAN — we do
|
|
|
|
that with an entry in <filename>/etc/shorewall/policy</filename> (assume
|
|
|
|
that the local LAN comprises the zone <quote>loc</quote>).</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#SOURCE DESTINATION POLICY
|
|
|
|
road loc ACCEPT</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>The OpenVPN configuration file on system A is something like the
|
|
|
|
following:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>dev tun
|
|
|
|
|
|
|
|
server 192.168.2.0 255.255.255.0
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
dh dh1024.pem
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
ca /etc/certs/cacert.pem
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-27 16:39:58 +01:00
|
|
|
crl-verify /etc/certs/crl.pem
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
cert /etc/certs/SystemA.pem
|
|
|
|
key /etc/certs/SystemA_key.pem
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
port 1194
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
comp-lzo
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
user nobody
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
group nogroup
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
ping 15
|
|
|
|
ping-restart 45
|
|
|
|
ping-timer-rem
|
|
|
|
persist-tun
|
|
|
|
persist-key
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
verb 3</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>Configuration on the remote clients follows a similar line. We
|
|
|
|
define a zone to represent the remote LAN:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para><filename>/etc/shorewall/zones</filename> — System B:</para>
|
|
|
|
|
2005-09-04 01:03:06 +02:00
|
|
|
<programlisting>#ZONE TYPE OPTIONS IN OUT
|
|
|
|
# OPTIONS OPTIONS
|
2005-09-30 19:39:24 +02:00
|
|
|
home ipv4</programlisting>
|
2004-12-21 17:55:29 +01:00
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>On system A, the hosts accessible through the tunnel will comprise
|
|
|
|
the <emphasis role="bold">home</emphasis> zone.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para>In <filename>/etc/shorewall/interfaces</filename> on system
|
|
|
|
B:</para>
|
|
|
|
|
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
|
|
|
home tun0</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>In <filename>/etc/shorewall/tunnels</filename> on system B, we need
|
|
|
|
the following:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpn:1194 net 206.162.148.9</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2005-08-27 23:47:09 +02:00
|
|
|
<para>Again in you are running Shorewall 2.4.3 or later, in
|
|
|
|
<filename>/etc/shorewall/tunnels</filename> on system B you might
|
|
|
|
prefer:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY ZONE
|
|
|
|
openvpnclient:1194 net 206.162.148.9</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2005-10-15 17:13:35 +02:00
|
|
|
<para>We want the remote client to have access to the local LAN — we do
|
2004-12-21 17:55:29 +01:00
|
|
|
that with an entry in <filename>/etc/shorewall/policy</filename>.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#SOURCE DESTINATION POLICY
|
|
|
|
$FW home ACCEPT</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>The OpenVPN configuration on the remote clients is along the
|
|
|
|
following line:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>dev tun
|
|
|
|
remote 206.162.148.9
|
|
|
|
up /etc/openvpn/home.up
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
tls-client
|
|
|
|
pull
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
ca /etc/certs/cacert.pem
|
2004-12-27 16:39:58 +01:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
cert /etc/certs/SystemB.pem
|
|
|
|
key /etc/certs/SystemB_key.pem
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
port 1194
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
user nobody
|
|
|
|
group nogroup
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
comp-lzo
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
ping 15
|
|
|
|
ping-restart 45
|
|
|
|
ping-timer-rem
|
|
|
|
persist-tun
|
|
|
|
persist-key
|
2005-10-12 17:25:01 +02:00
|
|
|
|
2004-12-21 17:55:29 +01:00
|
|
|
verb 3</programlisting>
|
|
|
|
</blockquote>
|
2004-12-27 16:39:58 +01:00
|
|
|
|
2005-02-06 20:21:18 +01:00
|
|
|
<para>If you want multiple remote clients to be able to communicate openly
|
|
|
|
with each other then you must:</para>
|
2004-12-27 16:39:58 +01:00
|
|
|
|
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>Include the <emphasis role="bold">client-to-client</emphasis>
|
|
|
|
directive in the server's OpenVPN configuration; and</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Specify the <emphasis role="bold">routeback</emphasis> option on
|
2004-12-27 19:25:00 +01:00
|
|
|
the <filename class="devicefile">tun+</filename> device in <ulink
|
|
|
|
url="Documentation.htm#Interfaces">/etc/shorewall/interfaces</ulink>.</para>
|
2004-12-27 16:39:58 +01:00
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
2005-02-06 20:21:18 +01:00
|
|
|
|
|
|
|
<para>If you want to selectively allow communication between the clients,
|
|
|
|
then see <ulink
|
|
|
|
url="http://www.iut-lannion.fr/ZONZON/memos_index.php?part=Network&section=WRTMemo&subsec=vpnwithshorewall">this
|
|
|
|
article</ulink> by Marc Zonzon</para>
|
2004-12-21 17:55:29 +01:00
|
|
|
</section>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-25 18:47:38 +02:00
|
|
|
<section id="Bridge">
|
2005-10-12 02:44:04 +02:00
|
|
|
<title>Securing a Home Wireless Network with OpenVPN (OpenVPN
|
|
|
|
Bridge)</title>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-15 17:13:35 +02:00
|
|
|
<para>This section will describe how we secured our home wireless network
|
2005-10-12 02:13:11 +02:00
|
|
|
using OpenVPN. Our network is as shown in the following diagram.</para>
|
|
|
|
|
|
|
|
<graphic fileref="images/network3.png" />
|
|
|
|
|
2005-10-13 22:48:28 +02:00
|
|
|
<para>The Wireless network is in the lower right of the diagram and
|
|
|
|
consists of two laptops: Eastepnc6000 (Windows XP - SP1) and Tipper (SuSE
|
|
|
|
10.0). We use OpenVPN to bridge those two laptops with the local LAN shown
|
|
|
|
in the lower left hand corner. The laptops are configured with addresses
|
|
|
|
in the 192.168.3.0/24 network connected to the firewall's <filename
|
2005-10-12 02:44:04 +02:00
|
|
|
class="devicefile">eth0</filename> interface which places them in the
|
2005-10-13 16:59:02 +02:00
|
|
|
firewall's <emphasis role="bold">Wifi</emphasis> zone. OpenVPN bridging
|
2005-10-25 21:58:40 +02:00
|
|
|
allows them to be assigned an additional IP address from the
|
2005-10-13 16:59:02 +02:00
|
|
|
192.168.1.0/24 network and to be securely bridged to the LAN on the lower
|
|
|
|
left.</para>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-14 04:38:20 +02:00
|
|
|
<note>
|
|
|
|
<para>Eastepnc6000 is shown in both the local LAN and in the Wifi zone
|
|
|
|
with IP address 192.168.1.6 -- clearly, the computer can only be in one
|
|
|
|
place or the other. Tipper can also be in either place and will have the
|
|
|
|
IP address 192.168.1.8 regardless.</para>
|
|
|
|
</note>
|
|
|
|
|
2005-10-12 02:13:11 +02:00
|
|
|
<section>
|
|
|
|
<title>Configuring the Bridge</title>
|
|
|
|
|
|
|
|
<para>The firewall runs Debian Sarge so the bridge is defined in
|
|
|
|
<filename>/etc/network/interfaces</filename>.</para>
|
|
|
|
|
|
|
|
<programlisting># LAN interface
|
|
|
|
auto br0
|
|
|
|
iface br0 inet static
|
|
|
|
address 192.168.1.254
|
|
|
|
netmask 255.255.255.0
|
|
|
|
pre-up /usr/sbin/openvpn --mktun --dev tap0
|
2005-10-12 20:41:00 +02:00
|
|
|
pre-up /sbin/ip link set tap0 up
|
2005-10-12 02:13:11 +02:00
|
|
|
pre-up /sbin/ip link set eth3 up
|
|
|
|
pre-up /usr/sbin/brctl addbr br0
|
|
|
|
pre-up /usr/sbin/brctl addif br0 eth3
|
|
|
|
pre-up /usr/sbin/brctl addif br0 tap0
|
|
|
|
post-down /usr/sbin/brctl delif br0 eth3
|
|
|
|
post-down /usr/sbin/brctl delif br0 tap0
|
|
|
|
post-down /usr/sbin/brctl delbr br0
|
|
|
|
post-down /usr/sbin/openvpn --rmtun --dev tap0</programlisting>
|
|
|
|
|
|
|
|
<para>Note that the IP address assigned to the bridge is 192.168.1.254
|
|
|
|
-- that is the default gateway address for hosts in the local
|
|
|
|
zone.</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Configuring OpenVPN</title>
|
|
|
|
|
|
|
|
<para>We use X.509 certificates for authentication.</para>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Firewall (Server) configuration.</title>
|
|
|
|
|
|
|
|
<para>/etc/openvpn/server-bridge.conf defines a bridge and reserves IP
|
2005-10-12 19:14:49 +02:00
|
|
|
addresses 192.168.1.64-192.168.1.71 for VPN clients. Note that the
|
|
|
|
bridge server only uses local IP address 192.168.3.254. We run two
|
|
|
|
instances of OpenVPN; this one and a second tunnel-mode instance for
|
2005-10-12 20:41:00 +02:00
|
|
|
remote access (see <ulink url="myfiles.htm">this
|
|
|
|
article</ulink>).</para>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-14 01:37:22 +02:00
|
|
|
<para></para>
|
|
|
|
|
2005-10-12 02:13:11 +02:00
|
|
|
<programlisting>dev tap0
|
|
|
|
|
|
|
|
local 192.168.3.254
|
|
|
|
|
|
|
|
server-bridge 192.168.1.254 255.255.255.0 192.168.1.64 192.168.1.71
|
|
|
|
|
2005-10-12 18:18:39 +02:00
|
|
|
client-to-client
|
|
|
|
|
2005-10-12 02:13:11 +02:00
|
|
|
dh dh1024.pem
|
|
|
|
|
|
|
|
ca /etc/certs/cacert.pem
|
|
|
|
|
|
|
|
crl-verify /etc/certs/crl.pem
|
|
|
|
|
|
|
|
cert /etc/certs/gateway.pem
|
|
|
|
key /etc/certs/gateway_key.pem
|
|
|
|
|
|
|
|
port 1194
|
|
|
|
|
|
|
|
comp-lzo
|
|
|
|
|
|
|
|
user nobody
|
|
|
|
group nogroup
|
|
|
|
|
2005-10-12 19:14:49 +02:00
|
|
|
keepalive 15 45
|
2005-10-12 02:13:11 +02:00
|
|
|
ping-timer-rem
|
|
|
|
persist-tun
|
|
|
|
persist-key
|
|
|
|
|
2005-10-14 01:37:22 +02:00
|
|
|
client-config-dir /etc/openvpn/bridge-clients
|
|
|
|
ccd-exclusive
|
|
|
|
|
2005-10-12 02:13:11 +02:00
|
|
|
verb 3</programlisting>
|
2005-10-14 01:37:22 +02:00
|
|
|
|
|
|
|
<para>The files in <filename>/etc/openvpn/bridge-clients</filename>
|
|
|
|
are used to assign a fixed IP address to each laptop. For example,
|
|
|
|
tipper.shorewall.net:</para>
|
|
|
|
|
|
|
|
<programlisting>ifconfig-push 192.168.1.8 255.255.255.0</programlisting>
|
2005-10-12 02:13:11 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Tipper Configuration</title>
|
|
|
|
|
|
|
|
<para>/etc/openvpn/wireless.conf:</para>
|
|
|
|
|
|
|
|
<programlisting>dev tap
|
|
|
|
|
|
|
|
remote 192.168.3.254
|
|
|
|
tls-remote gateway.shorewall.net
|
|
|
|
|
|
|
|
client
|
|
|
|
|
2005-10-13 19:12:56 +02:00
|
|
|
redirect-gateway
|
2005-10-12 02:13:11 +02:00
|
|
|
|
|
|
|
ca /etc/certs/cacert.pem
|
|
|
|
|
|
|
|
cert /etc/certs/tipper.pem
|
|
|
|
key /etc/certs/tipper_key.pem
|
|
|
|
|
|
|
|
port 1194
|
|
|
|
|
|
|
|
comp-lzo
|
|
|
|
|
|
|
|
ping 15
|
|
|
|
ping-restart 45
|
|
|
|
ping-timer-rem
|
|
|
|
persist-tun
|
|
|
|
persist-key
|
|
|
|
|
|
|
|
mute-replay-warnings
|
|
|
|
|
|
|
|
verb 3</programlisting>
|
|
|
|
</section>
|
2005-10-13 16:21:16 +02:00
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Eastepnc6000 (Windows XP) Configuration</title>
|
|
|
|
|
|
|
|
<para>C:\Program Files\Openvpn\config\homewireless.ovpn:</para>
|
|
|
|
|
|
|
|
<programlisting>dev tap
|
|
|
|
remote 192.168.3.254
|
|
|
|
tls-remote gateway.shorewall.net
|
|
|
|
|
|
|
|
tls-client
|
|
|
|
pull
|
|
|
|
|
|
|
|
ca "/Program Files/OpenVPN/certs/cacert.pem"
|
|
|
|
|
|
|
|
cert "/Program Files/OpenVPN/certs/eastepnc6000.pem"
|
|
|
|
key "/Program Files/OpenVPN/certs/eastepnc6000_key.pem"
|
|
|
|
|
|
|
|
redirect-gateway
|
|
|
|
|
|
|
|
port 1194
|
|
|
|
|
|
|
|
comp-lzo
|
|
|
|
|
|
|
|
ping 15
|
|
|
|
ping-restart 45
|
|
|
|
ping-timer-rem
|
|
|
|
persist-tun
|
|
|
|
persist-key
|
|
|
|
|
|
|
|
verb 3</programlisting>
|
|
|
|
</section>
|
2005-10-12 02:13:11 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Configuring Shorewall</title>
|
|
|
|
|
|
|
|
<para>In this configuration, we don't need any firewalling between the
|
|
|
|
laptops and the local LAN so we set BRIDGING=No in shorewall.conf. The
|
|
|
|
configuration of the bridge then becomes as described in the <ulink
|
2005-10-15 17:13:35 +02:00
|
|
|
url="SimpleBridge.html">Simple Bridge documentation</ulink>. If you need
|
|
|
|
to control the traffic allowed through the VPN bridge then you will want
|
|
|
|
to configure Shorewall as shown in the <ulink
|
|
|
|
url="bridge.html">Bridge/Firewall documentation</ulink>.</para>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
|
|
|
<section>
|
2005-10-12 17:25:01 +02:00
|
|
|
<title>Firewall</title>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>/etc/shorewall/interfaces</title>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-12 17:25:01 +02:00
|
|
|
<para>Note that the bridge (br0) is defined as the interface to the
|
|
|
|
local zone and has the <emphasis role="bold">routeback</emphasis>
|
|
|
|
option.</para>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-12 17:25:01 +02:00
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
2005-10-12 02:13:11 +02:00
|
|
|
net eth2 206.124.146.255 dhcp,norfc1918,logmartians,blacklist,tcpflags,nosmurfs
|
|
|
|
loc br0 192.168.1.255 dhcp,<emphasis role="bold">routeback</emphasis>
|
|
|
|
dmz eth1 - logmartians
|
|
|
|
Wifi eth0 192.168.3.255 dhcp,maclist
|
|
|
|
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</programlisting>
|
2005-10-12 17:25:01 +02:00
|
|
|
</section>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-12 17:25:01 +02:00
|
|
|
<section>
|
|
|
|
<title>/etc/shorewall/tunnels</title>
|
2005-10-12 02:13:11 +02:00
|
|
|
|
2005-10-12 17:25:01 +02:00
|
|
|
<programlisting>#TYPE ZONE GATEWAY GATEWAY
|
2005-10-12 02:13:11 +02:00
|
|
|
# ZONE
|
2005-10-12 17:25:01 +02:00
|
|
|
openvpnserver:1194 Wifi 192.168.3.0/24
|
2005-10-12 02:13:11 +02:00
|
|
|
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</programlisting>
|
2005-10-12 17:25:01 +02:00
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Tipper</title>
|
|
|
|
|
2005-10-15 17:13:35 +02:00
|
|
|
<para>Wireless networks pose a threat to all systems that are
|
|
|
|
connected to them and we therefore run Firewalls on the two Laptops.
|
|
|
|
Eastepnc6000 runs <trademark>Sygate</trademark> Security Agent and
|
|
|
|
Tipper runs a Shorewall-based Netfilter firewall.</para>
|
|
|
|
|
2005-10-12 17:25:01 +02:00
|
|
|
<section>
|
|
|
|
<title>/etc/shorewall/zones</title>
|
|
|
|
|
2005-10-12 18:18:39 +02:00
|
|
|
<programlisting>#ZONE TYPE OPTIONS IN OUT
|
|
|
|
# OPTIONS OPTIONS
|
2005-10-12 21:23:11 +02:00
|
|
|
<emphasis role="bold">lan ipv4</emphasis> #Wired LAN at our home
|
2005-10-12 17:25:01 +02:00
|
|
|
net ipv4
|
|
|
|
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
|
|
|
|
</programlisting>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>/etc/shorewall/interfaces</title>
|
|
|
|
|
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
|
|
|
#
|
2005-10-12 18:18:39 +02:00
|
|
|
net eth0 detect routefilter,dhcp,tcpflags
|
2005-10-12 21:23:11 +02:00
|
|
|
<emphasis role="bold">lan tap0 192.168.1.255</emphasis>
|
2005-10-12 17:25:01 +02:00
|
|
|
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
|
|
|
|
</programlisting>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>/etc/shorewall/policy</title>
|
|
|
|
|
|
|
|
<para>Since we don't expect any traffic between the <emphasis
|
|
|
|
role="bold">net</emphasis> zone and the <emphasis
|
2005-10-12 21:23:11 +02:00
|
|
|
role="bold">lan</emphasis> zone, we use NONE policies for that
|
2005-10-12 17:25:01 +02:00
|
|
|
traffic. If any such traffic should occur, it will be handled
|
|
|
|
according to the all->all policy.</para>
|
|
|
|
|
|
|
|
<programlisting>#SOURCE DEST POLICY LOG LIMIT:BURST
|
|
|
|
# LEVEL
|
|
|
|
fw net ACCEPT
|
2005-10-12 21:23:11 +02:00
|
|
|
<emphasis role="bold">fw lan ACCEPT
|
|
|
|
lan fw ACCEPT
|
|
|
|
net lan NONE
|
|
|
|
lan net NONE</emphasis>
|
2005-10-12 17:25:01 +02:00
|
|
|
net all DROP info
|
|
|
|
# The FOLLOWING POLICY MUST BE LAST
|
|
|
|
all all REJECT info
|
|
|
|
#LAST LINE -- DO NOT REMOVE
|
|
|
|
</programlisting>
|
|
|
|
</section>
|
2005-10-12 02:13:11 +02:00
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
</section>
|
2004-12-27 19:25:00 +01:00
|
|
|
</article>
|