<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Shorewall and a Simple Bridge</title><link rel="stylesheet" href="html.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="article" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id257527"></a>Shorewall and a Simple Bridge</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Tom</span> <span class="surname">Eastep</span></h3></div></div></div><div><p class="copyright">Copyright © 2004, 2005, 2006 Thomas M. Eastep</p></div><div><div class="legalnotice"><a id="id257916"></a><p>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 “<span class="quote"><a class="ulink" href="GnuCopyright.htm" target="_self">GNU Free Documentation License</a></span>”.</p></div></div><div><p class="pubdate">2008/12/15</p></div></div><hr /></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#Background">Background</a></span></dt><dt><span class="section"><a href="#Application">Application</a></span></dt></dl></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Background"></a>Background</h2></div></div></div><p>Systems where Shorewall runs normally function as <em class="firstterm">routers</em>. 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 <em class="firstterm">bridge</em>. Bridges are layer-2 devices in the OSI model (think of a bridge as an Ethernet switch).</p><p>Some differences between routers and bridges are:</p><div class="orderedlist"><ol type="1"><li><p>Routers determine packet destination based on the destination IP address while bridges route traffic based on the destination MAC address in the Ethernet frame.</p></li><li><p>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.</p></li><li><p>A router cannot forward broadcast packets while a bridge can.</p></li></ol></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Application"></a>Application</h2></div></div></div><p>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 segments. This is the environment that is described in this article.</p><p>If you do need to restrict traffic through the bridge, please refer to the <a class="ulink" href="bridge-Shorewall-perl.html" target="_self">Shorewall Bridge/Firewall documentation</a>. Also please refer to that documentation for information about how to create a bridge.</p><p>The following diagram shows a firewall for two bridged LAN segments.</p><div align="center"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle"><img src="images/SimpleBridge.png" align="middle" /></td></tr></table></div><p>This is fundamentally the Two-interface Firewall described in the <a class="ulink" href="two-interface.htm" target="_self">Two-interface Quickstart Guide</a>. The bridge-specific changes are restricted to the <code class="filename">/etc/shorewall/interfaces</code> file.</p><p>This example illustrates the bridging of two Ethernet devices but the types of the devices really isn't important. What is shown here would apply equally to bridging an Ethernet device to an <a class="ulink" href="OPENVPN.html" target="_self">OpenVPN</a> tap device (e.g., <code class="filename">tap0</code>) or to a wireless device (<code class="filename">ath0</code> or <code class="filename">wlan0</code>).</p><p><code class="filename">/etc/shorewall/interfaces</code>:</p><pre class="programlisting">#ZONE INTERFACE BROADCAST OPTIONS net eth0 detect ... loc <span class="bold"><strong>br0</strong></span> 10.0.1.255 <span class="bold"><strong>routeback</strong></span>,...</pre><p>So the key points here are:</p><div class="itemizedlist"><ul type="disc"><li><p>The <span class="bold"><strong>loc</strong></span> interface is <code class="filename">br0</code>.</p></li><li><p>Neither <code class="filename">eth1</code> nor <code class="filename">eth2</code> have IP addresses and neither are mentioned in the Shorewall configuration.</p></li><li><p>The <span class="bold"><strong>routeback</strong></span> option is specified for <code class="filename">br0</code>.</p></li><li><p>The default gateway for hosts in the local segments will be 10.0.1.254 — the IP address of the bridge itself.</p></li></ul></div><p><span class="bold"><strong>Note to Shorewall-perl users</strong></span>: You should also specify the <span class="bold"><strong>bridge</strong></span> option:</p><pre class="programlisting">#ZONE INTERFACE BROADCAST OPTIONS net eth0 detect ... loc <span class="bold"><strong>br0</strong></span> 10.0.1.255 <span class="bold"><strong>routeback,bridge</strong></span>,...</pre></div></div></body></html>