2004-09-24 00:50:12 +02:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
2008-07-07 22:42:54 +02:00
|
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
2004-09-24 00:50:12 +02:00
|
|
|
<article>
|
|
|
|
<!--$Id$-->
|
|
|
|
|
|
|
|
<articleinfo>
|
|
|
|
<title>Shorewall and a Simple Bridge</title>
|
|
|
|
|
|
|
|
<authorgroup>
|
|
|
|
<author>
|
|
|
|
<firstname>Tom</firstname>
|
|
|
|
|
|
|
|
<surname>Eastep</surname>
|
|
|
|
</author>
|
|
|
|
</authorgroup>
|
|
|
|
|
2006-07-07 03:04:16 +02:00
|
|
|
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
|
2004-09-24 00:50:12 +02:00
|
|
|
|
|
|
|
<copyright>
|
|
|
|
<year>2004</year>
|
|
|
|
|
2005-10-12 19:31:29 +02:00
|
|
|
<year>2005</year>
|
|
|
|
|
2006-03-08 03:06:30 +01:00
|
|
|
<year>2006</year>
|
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<holder>Thomas M. Eastep</holder>
|
|
|
|
</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
|
|
|
|
<quote><ulink url="GnuCopyright.htm">GNU Free Documentation
|
|
|
|
License</ulink></quote>.</para>
|
|
|
|
</legalnotice>
|
|
|
|
</articleinfo>
|
|
|
|
|
2007-06-29 00:06:10 +02:00
|
|
|
<section id="Background">
|
2004-09-24 00:50:12 +02:00
|
|
|
<title>Background</title>
|
|
|
|
|
|
|
|
<para>Systems where Shorewall runs normally function as
|
|
|
|
<firstterm>routers</firstterm>. In the context of the Open System
|
|
|
|
Interconnect (OSI) reference model, a router operates at layer 3.
|
|
|
|
Shorewall may also be deployed on a GNU Linux System that acts as a
|
|
|
|
<firstterm>bridge</firstterm>. Bridges are layer-2 devices in the OSI
|
2008-08-15 07:03:24 +02:00
|
|
|
model (think of a bridge as an Ethernet switch).</para>
|
2004-09-24 00:50:12 +02:00
|
|
|
|
|
|
|
<para>Some differences between routers and bridges are:</para>
|
|
|
|
|
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>Routers determine packet destination based on the destination IP
|
|
|
|
address while bridges route traffic based on the destination MAC
|
2008-08-15 07:03:24 +02:00
|
|
|
address in the Ethernet frame.</para>
|
2004-09-24 00:50:12 +02:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>As a consequence of the first difference, routers can be
|
|
|
|
connected to more than one IP network while a bridge may be part of
|
|
|
|
only a single network.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>A router cannot forward broadcast packets while a bridge
|
|
|
|
can.</para>
|
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</section>
|
|
|
|
|
2007-06-29 00:06:10 +02:00
|
|
|
<section id="Application">
|
2004-09-24 00:50:12 +02:00
|
|
|
<title>Application</title>
|
|
|
|
|
|
|
|
<para>There are cases where you want to create a bridge to join two or
|
|
|
|
more LAN segments and you don't need to restrict the traffic between those
|
2004-12-11 16:36:42 +01:00
|
|
|
segments. This is the environment that is described in this
|
|
|
|
article.</para>
|
2004-09-24 00:50:12 +02:00
|
|
|
|
|
|
|
<para>If you do need to restrict traffic through the bridge, please refer
|
2007-06-29 00:06:10 +02:00
|
|
|
to the <ulink url="bridge-Shorewall-perl.html">Shorewall Bridge/Firewall
|
2004-09-24 00:50:12 +02:00
|
|
|
documentation</ulink>. Also please refer to that documentation for
|
|
|
|
information about how to create a bridge.</para>
|
|
|
|
|
|
|
|
<para>The following diagram shows a firewall for two bridged LAN
|
|
|
|
segments.</para>
|
|
|
|
|
2016-02-19 18:46:23 +01:00
|
|
|
<graphic align="center" fileref="images/SimpleBridge.png" valign="middle"/>
|
2004-09-24 00:50:12 +02:00
|
|
|
|
2006-03-08 02:54:39 +01:00
|
|
|
<para>This is fundamentally the Two-interface Firewall described in the
|
2004-09-24 00:50:12 +02:00
|
|
|
<ulink url="two-interface.htm">Two-interface Quickstart Guide</ulink>. The
|
|
|
|
bridge-specific changes are restricted to the
|
|
|
|
<filename>/etc/shorewall/interfaces</filename> file.</para>
|
|
|
|
|
2009-09-05 17:23:35 +02:00
|
|
|
<note>
|
|
|
|
<para>Older configurations that specify an interface name in the SOURCE
|
|
|
|
column of <filename>/etc/shorewall/masq</filename> will also need to
|
|
|
|
change that file.</para>
|
|
|
|
</note>
|
|
|
|
|
2008-08-15 07:03:24 +02:00
|
|
|
<para>This example illustrates the bridging of two Ethernet devices but
|
2006-10-26 16:23:47 +02:00
|
|
|
the types of the devices really isn't important. What is shown here would
|
2008-08-15 07:03:24 +02:00
|
|
|
apply equally to bridging an Ethernet device to an <ulink
|
2006-10-26 16:23:47 +02:00
|
|
|
url="OPENVPN.html">OpenVPN</ulink> tap device (e.g.,
|
|
|
|
<filename>tap0</filename>) or to a wireless device
|
|
|
|
(<filename>ath0</filename> or <filename>wlan0</filename>).</para>
|
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<para><filename>/etc/shorewall/interfaces</filename>:</para>
|
|
|
|
|
2016-02-19 18:46:23 +01:00
|
|
|
<programlisting>?FORMAT 2
|
|
|
|
#ZONE INTERFACE OPTIONS
|
|
|
|
net eth0 ...
|
|
|
|
loc <emphasis role="bold">br0</emphasis> <emphasis
|
|
|
|
role="bold">routeback,bridge</emphasis>,...</programlisting>
|
2004-09-24 00:50:12 +02:00
|
|
|
|
|
|
|
<para>So the key points here are:</para>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>The <emphasis role="bold">loc</emphasis> interface is <filename
|
|
|
|
class="devicefile">br0</filename>.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Neither <filename class="devicefile">eth1</filename> nor
|
|
|
|
<filename class="devicefile">eth2</filename> have IP addresses and
|
|
|
|
neither are mentioned in the Shorewall configuration.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2016-02-19 18:46:23 +01:00
|
|
|
<para>The <emphasis role="bold">routeback</emphasis> and <emphasis
|
|
|
|
role="bold">bridge</emphasis> options is specified for <filename
|
|
|
|
class="devicefile">br0</filename>.</para>
|
2004-09-24 00:50:12 +02:00
|
|
|
</listitem>
|
2004-12-11 16:36:42 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>The default gateway for hosts in the local segments will be
|
2005-10-12 19:31:29 +02:00
|
|
|
10.0.1.254 — the IP address of the bridge itself.</para>
|
2004-12-11 16:36:42 +01:00
|
|
|
</listitem>
|
2004-09-24 00:50:12 +02:00
|
|
|
</itemizedlist>
|
2007-07-05 18:00:09 +02:00
|
|
|
|
2009-09-05 16:24:29 +02:00
|
|
|
<para>Your entry in <filename>/etc/shorewall/masq</filename> should be
|
|
|
|
unchanged:</para>
|
|
|
|
|
|
|
|
<programlisting>#INTERFACE SOURCE ADDRESS
|
|
|
|
eth0 10.0.1.0/24 ... # 10.0.1.0/24 is the local network on LAN A and LAN B</programlisting>
|
2016-10-15 22:52:28 +02:00
|
|
|
|
|
|
|
<para>When running Shorewall 5.0.14 or later, the equivalent
|
|
|
|
<filename>/etc/shorewall/snat</filename> is:</para>
|
|
|
|
|
|
|
|
<programlisting>#ACTION SOURCE DEST PROTO PORT
|
|
|
|
MASQUERADE 10.0.1.0/24 eth0</programlisting>
|
2004-09-24 00:50:12 +02:00
|
|
|
</section>
|
2008-07-07 22:42:54 +02:00
|
|
|
</article>
|