2004-03-17 16:03:46 +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$-->
|
|
|
|
|
|
|
|
<articleinfo>
|
|
|
|
<title>Shorewall and Bridged Firewalls</title>
|
|
|
|
|
|
|
|
<authorgroup>
|
|
|
|
<author>
|
|
|
|
<firstname>Tom</firstname>
|
|
|
|
|
|
|
|
<surname>Eastep</surname>
|
|
|
|
</author>
|
|
|
|
</authorgroup>
|
|
|
|
|
2005-10-22 19:37:38 +02:00
|
|
|
<pubdate>2005-10-21</pubdate>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<copyright>
|
|
|
|
<year>2004</year>
|
|
|
|
|
2005-01-04 03:52:23 +01:00
|
|
|
<year>2005</year>
|
|
|
|
|
2004-03-17 16:03:46 +01: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
|
2004-08-19 20:29:13 +02:00
|
|
|
<quote><ulink url="GnuCopyright.htm">GNU Free Documentation
|
|
|
|
License</ulink></quote>.</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
</legalnotice>
|
|
|
|
</articleinfo>
|
|
|
|
|
2005-09-30 08:30:36 +02:00
|
|
|
<caution>
|
|
|
|
<para><emphasis role="bold">This article applies to Shorewall 3.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>
|
|
|
|
</caution>
|
|
|
|
|
2004-03-17 16:03:46 +01:00
|
|
|
<section>
|
|
|
|
<title>Background</title>
|
|
|
|
|
|
|
|
<para>Systems where Shorewall runs normally function as
|
|
|
|
<firstterm>routers</firstterm>. In the context of the Open System
|
2005-09-30 08:30:36 +02:00
|
|
|
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
|
|
|
|
model (think of a bridge as an ethernet switch).</para>
|
2004-03-17 16:03:46 +01: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
|
|
|
|
address in the ethernet frame.</para>
|
|
|
|
</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>
|
2005-10-02 17:34:20 +02:00
|
|
|
<para>In most configurations, routers don't forward broadcast packets
|
|
|
|
while a bridges do.</para>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>Section 4 of RFC 1812 describes the conditions under which a
|
|
|
|
router may or must forward broadcasts.</para>
|
|
|
|
</note>
|
2004-03-17 16:03:46 +01:00
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Requirements</title>
|
|
|
|
|
2005-10-22 19:37:38 +02:00
|
|
|
<para>Note that if you need a bridge but do not need to restrict the
|
|
|
|
traffic through the bridge then any version of Shorewall will work. See
|
|
|
|
the <ulink url="SimpleBridge.html">Simple Bridge documentation</ulink> for
|
|
|
|
details.</para>
|
|
|
|
|
2004-09-24 00:50:12 +02:00
|
|
|
<para>In order to use Shorewall as a bridging firewall:</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2004-04-05 23:13:45 +02:00
|
|
|
<para>Your kernel must contain bridge support (CONFIG_BRIDGE=m or
|
2004-03-17 16:03:46 +01:00
|
|
|
CONFIG_BRIDGE=y).</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2004-04-05 23:13:45 +02:00
|
|
|
<para>Your kernel must contain Netfilter physdev match support
|
2004-03-17 16:03:46 +01:00
|
|
|
(CONFIG_IP_NF_MATCH_PHYSDEV=m or CONFIG_IP_NF_MATCH_PHYSDEV=y).
|
2004-04-05 23:13:45 +02:00
|
|
|
Physdev match is standard in the 2.6 kernel series but must be patched
|
2004-08-19 20:29:13 +02:00
|
|
|
into the 2.4 kernels (see <ulink
|
2004-09-07 18:09:11 +02:00
|
|
|
url="http://bridge.sf.net">http://bridge.sf.net</ulink>). Bering and
|
|
|
|
Bering uCLibc users must find and install ipt_physdev.o for their
|
|
|
|
distribution and add <quote>ipt_physdev</quote> to
|
|
|
|
/etc/modules.</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Your iptables must contain physdev match support. iptables 1.2.9
|
|
|
|
and later contain this support.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>You must have the bridge utilities (bridge-utils) package
|
|
|
|
installed.</para>
|
|
|
|
</listitem>
|
2004-04-05 23:13:45 +02:00
|
|
|
</itemizedlist>
|
2004-03-17 16:03:46 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Application</title>
|
|
|
|
|
|
|
|
<para>The following diagram shows a typical application of a
|
|
|
|
bridge/firewall. There is already an existing router in place whose
|
|
|
|
internal interface supports a network and you want to insert a firewall
|
|
|
|
between the router and the systems in the local network. In the example
|
|
|
|
shown, the network uses RFC 1918 addresses but that is not a requirement;
|
|
|
|
the bridge would work exactly the same if public IP addresses were used
|
2004-08-19 20:29:13 +02:00
|
|
|
(remember that the bridge doesn't deal with IP addresses).</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<graphic fileref="images/bridge.png" />
|
|
|
|
|
|
|
|
<para>There are a several key differences in this setup and a normal
|
|
|
|
Shorewall configuration:</para>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>The Shorewall system (the Bridge/Firewall) has only a single IP
|
|
|
|
address even though it has two ethernet interfaces! The IP address is
|
|
|
|
configured on the bridge itself rather than on either of the network
|
|
|
|
cards.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>The systems connected to the LAN are configured with the
|
2004-08-19 20:29:13 +02:00
|
|
|
router's IP address (192.168.1.254 in the above diagram) as their
|
2004-03-17 16:03:46 +01:00
|
|
|
default gateway.</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2004-08-19 20:29:13 +02:00
|
|
|
<para><command>traceroute</command> doesn't detect the Bridge/Firewall
|
|
|
|
as an intermediate router.</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>If the router runs a DHCP server, the hosts connected to the LAN
|
|
|
|
can use that server without having <command>dhcrelay</command> running
|
|
|
|
on the Bridge/Firewall.</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
|
|
|
|
<para>There are other possibilities here -- there could be a hub or switch
|
|
|
|
between the router and the Bridge/Firewall and there could be other
|
|
|
|
systems connected to that switch. All of the systems on the local side of
|
2004-04-05 23:13:45 +02:00
|
|
|
the <emphasis role="bold">router</emphasis> would still be configured with
|
|
|
|
IP addresses in 192.168.1.0/24 as shown below.<graphic
|
|
|
|
fileref="images/bridge3.png" /></para>
|
2004-03-17 16:03:46 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Configuring the Bridge</title>
|
|
|
|
|
2004-05-09 00:31:54 +02:00
|
|
|
<para>Configuring the bridge itself is quite simple and uses the
|
2004-03-17 16:03:46 +01:00
|
|
|
<command>brctl</command> utility from the bridge-utils package. Bridge
|
|
|
|
configuration information may be found at <ulink
|
|
|
|
url="http://bridge.sf.net">http://bridge.sf.net</ulink>.</para>
|
|
|
|
|
2005-10-02 17:34:20 +02:00
|
|
|
<para>Unfortunately, many Linux distributions don't have good bridge
|
2004-08-19 20:29:13 +02:00
|
|
|
configuration tools and the network configuration GUIs don't detect the
|
2004-10-14 21:20:17 +02:00
|
|
|
presence of bridge devices. Here is an excerpt from a Debian
|
|
|
|
<filename>/etc/network/interfaces</filename> file for a two-port bridge
|
|
|
|
with a static IP address:</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
2004-04-05 23:13:45 +02:00
|
|
|
<blockquote>
|
|
|
|
<programlisting>auto br0
|
2004-03-17 16:03:46 +01:00
|
|
|
iface br0 inet static
|
|
|
|
address 192.168.1.253
|
|
|
|
netmask 255.255.255.0
|
|
|
|
network 192.168.1.0
|
|
|
|
broadcast 192.168.1.255
|
|
|
|
pre-up /sbin/ip link set eth0 up
|
|
|
|
pre-up /sbin/ip link set eth1 up
|
|
|
|
pre-up /usr/sbin/brctl addbr br0
|
|
|
|
pre-up /usr/sbin/brctl addif br0 eth0
|
2004-04-05 23:13:45 +02:00
|
|
|
pre-up /usr/sbin/brctl addif br0 eth1</programlisting>
|
|
|
|
</blockquote>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<para>While it is not a requirement to give the bridge an IP address,
|
|
|
|
doing so allows the bridge/firewall to access other systems and allows the
|
2004-04-05 23:13:45 +02:00
|
|
|
bridge/firewall to be managed remotely. The bridge must also have an IP
|
|
|
|
address for REJECT rules and policies to work correctly — otherwise REJECT
|
2004-08-19 20:29:13 +02:00
|
|
|
behaves the same as DROP. It is also a requirement for bridges to have an
|
|
|
|
IP address if they are part of a <link
|
|
|
|
linkend="bridge-router">bridge/router</link>.</para>
|
2004-04-05 23:13:45 +02:00
|
|
|
|
2005-01-04 03:52:23 +01:00
|
|
|
<important>
|
|
|
|
<para>Get your bridge configuration working first, including bridge
|
|
|
|
startup at boot, before you configure and start Shorewall.</para>
|
|
|
|
</important>
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
<para>The bridge may have its IP address assigned via DHCP. Here's an
|
2004-04-05 23:13:45 +02:00
|
|
|
example of an /etc/sysconfig/network/ifcfg-br0 file from a
|
|
|
|
<trademark>SuSE</trademark> system:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
2004-08-19 20:29:13 +02:00
|
|
|
<programlisting>BOOTPROTO='dhcp'
|
|
|
|
REMOTE_IPADDR=''
|
|
|
|
STARTMODE='onboot'
|
|
|
|
UNIQUE='3hqH.MjuOqWfSZ+C'
|
|
|
|
WIRELESS='no'
|
|
|
|
MTU=''</programlisting>
|
2004-04-05 23:13:45 +02:00
|
|
|
</blockquote>
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
<para>Here's an /etc/sysconfig/network-scripts/ifcfg-br0 file for a
|
2004-04-05 23:13:45 +02:00
|
|
|
<trademark>Mandrake</trademark> system:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>DEVICE=br0
|
|
|
|
BOOTPROTO=dhcp
|
|
|
|
ONBOOT=yes</programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
<para>On both the SuSE and Mandrake systems, a separate script is required
|
2004-10-14 21:20:17 +02:00
|
|
|
to configure the bridge itself.</para>
|
|
|
|
|
|
|
|
<para>Here are scripts that I used on a <trademark>Suse</trademark> 9.1
|
|
|
|
system.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para><filename>/etc/sysconfig/network/ifcfg-br0</filename></para>
|
|
|
|
|
|
|
|
<programlisting>BOOTPROTO='dhcp'
|
|
|
|
REMOTE_IPADDR=''
|
|
|
|
STARTMODE='onboot'
|
|
|
|
UNIQUE='3hqH.MjuOqWfSZ+C'
|
|
|
|
WIRELESS='no'
|
|
|
|
MTU=''</programlisting>
|
|
|
|
|
|
|
|
<para><filename>/etc/init.d/bridge</filename><programlisting>#!/bin/sh
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Script to create a bridge
|
|
|
|
#
|
|
|
|
# (c) 2004 - Tom Eastep (teastep@shorewall.net)
|
|
|
|
#
|
|
|
|
# Modify the following variables to match your configuration
|
|
|
|
#
|
|
|
|
#### BEGIN INIT INFO
|
|
|
|
# Provides: bridge
|
|
|
|
# Required-Start: coldplug
|
|
|
|
# Required-Stop:
|
|
|
|
# Default-Start: 2 3 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Description: starts and stops a bridge
|
|
|
|
### END INIT INFO
|
|
|
|
#
|
|
|
|
# chkconfig: 2345 05 89
|
|
|
|
# description: GRE/IP Tunnel
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
|
|
|
|
|
|
|
INTERFACES="eth1 eth0"
|
|
|
|
BRIDGE="br0"
|
|
|
|
MODULES="tulip"
|
|
|
|
|
|
|
|
do_stop() {
|
|
|
|
echo "Stopping Bridge $BRIDGE"
|
|
|
|
brctl delbr $BRIDGE
|
|
|
|
for interface in $INTERFACES; do
|
|
|
|
ip link set $interface down
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
do_start() {
|
|
|
|
|
|
|
|
echo "Starting Bridge $BRIDGE"
|
|
|
|
for module in $MODULES; do
|
|
|
|
modprobe $module
|
|
|
|
done
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
for interface in $INTERFACES; do
|
|
|
|
ip link set $interface up
|
|
|
|
done
|
|
|
|
|
|
|
|
brctl addbr $BRIDGE
|
|
|
|
|
|
|
|
for interface in $INTERFACES; do
|
|
|
|
brctl addif $BRIDGE $interface
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
do_start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
do_stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
do_stop
|
|
|
|
sleep 1
|
|
|
|
do_start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
exit 0</programlisting></para>
|
|
|
|
</blockquote>
|
2004-04-05 23:13:45 +02:00
|
|
|
|
|
|
|
<para>Axel Westerhold has contributed this example of configuring a bridge
|
|
|
|
with a static IP address on a Fedora System (Core 1 and Core 2 Test 1).
|
|
|
|
Note that these files also configure the bridge itself so there is no need
|
|
|
|
for a separate bridge config script.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<para><filename>/etc/sysconfig/network-scripts/ifcfg-br0:</filename></para>
|
|
|
|
|
|
|
|
<programlisting>DEVICE=br0
|
|
|
|
TYPE=Bridge
|
|
|
|
IPADDR=192.168.50.14
|
|
|
|
NETMASK=255.255.255.0
|
|
|
|
ONBOOT=yes</programlisting>
|
|
|
|
|
|
|
|
<para><filename>/etc/sysconfig/network-scripts/ifcfg-eth0:</filename><programlisting>DEVICE=eth0
|
|
|
|
TYPE=ETHER
|
|
|
|
BRIDGE=br0
|
|
|
|
ONBOOT=yes</programlisting><filename>/etc/sysconfig/network-scripts/ifcfg-eth1:</filename><programlisting>DEVICE=eth1
|
|
|
|
TYPE=ETHER
|
|
|
|
BRIDGE=br0
|
|
|
|
ONBOOT=yes</programlisting></para>
|
|
|
|
</blockquote>
|
|
|
|
|
2004-06-11 20:35:13 +02:00
|
|
|
<para>Florin Grad at <trademark>Mandrake</trademark> provides this script
|
|
|
|
for configuring a bridge:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>#!/bin/sh
|
|
|
|
# chkconfig: 2345 05 89
|
|
|
|
# description: Layer 2 Bridge
|
|
|
|
#
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
[ -f /etc/sysconfig/bridge ] && . /etc/sysconfig/bridge
|
2004-06-11 20:35:13 +02:00
|
|
|
|
|
|
|
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
|
|
|
|
|
|
|
do_stop() {
|
2004-08-19 20:29:13 +02:00
|
|
|
echo "Stopping Bridge"
|
2004-06-11 20:35:13 +02:00
|
|
|
for i in $INTERFACES $BRIDGE_INTERFACE ; do
|
|
|
|
ip link set $i down
|
|
|
|
done
|
|
|
|
brctl delbr $BRIDGE_INTERFACE
|
|
|
|
}
|
|
|
|
|
|
|
|
do_start() {
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
echo "Starting Bridge"
|
2004-06-11 20:35:13 +02:00
|
|
|
for i in $INTERFACES ; do
|
|
|
|
ip link set $i up
|
|
|
|
done
|
|
|
|
brctl addbr br0
|
|
|
|
for i in $INTERFACES ; do
|
|
|
|
ip link set $i up
|
2004-06-12 00:31:43 +02:00
|
|
|
brctl addif br0 $i
|
2004-06-11 20:35:13 +02:00
|
|
|
done
|
|
|
|
ifup $BRIDGE_INTERFACE
|
|
|
|
}
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
case "$1" in
|
2004-06-11 20:35:13 +02:00
|
|
|
start)
|
|
|
|
do_start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
do_stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
do_stop
|
|
|
|
sleep 1
|
|
|
|
do_start
|
|
|
|
;;
|
|
|
|
*)
|
2004-08-19 20:29:13 +02:00
|
|
|
echo "Usage: $0 {start|stop|restart}"
|
2004-06-11 20:35:13 +02:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
exit 0</programlisting>
|
|
|
|
|
2004-06-12 00:31:43 +02:00
|
|
|
<para>The <filename>/etc/sysconfig/bridge file</filename>:</para>
|
2004-06-11 20:35:13 +02:00
|
|
|
|
|
|
|
<programlisting>BRIDGE_INTERFACE=br0 #The name of your Bridge
|
2004-08-19 20:29:13 +02:00
|
|
|
INTERFACES="eth0 eth1" #The physical interfaces to be bridged</programlisting>
|
2004-06-11 20:35:13 +02:00
|
|
|
</blockquote>
|
|
|
|
|
2004-08-07 04:13:32 +02:00
|
|
|
<para>Andrzej Szelachowski contributed the following.</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>Here is how I configured bridge in Slackware:
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
1) I had to compile bridge-utils (It's not in the standard distribution)
|
|
|
|
2) I've created rc.bridge in /etc/rc.d:
|
2004-08-07 04:13:32 +02:00
|
|
|
|
|
|
|
#########################
|
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
ifconfig eth0 0.0.0.0
|
|
|
|
ifconfig eth1 0.0.0.0
|
2004-08-19 20:29:13 +02:00
|
|
|
#ifconfig lo 127.0.0.1 #this line should be uncommented if you don't use rc.inet1
|
2004-08-07 04:13:32 +02:00
|
|
|
|
|
|
|
brctl addbr most
|
|
|
|
|
|
|
|
brctl addif most eth0
|
|
|
|
brctl addif most eth1
|
|
|
|
|
|
|
|
ifconfig most 192.168.1.31 netmask 255.255.255.0 up
|
|
|
|
#route add default gw 192.168.1.1 metric 1 #this line should be uncommented if
|
2004-08-19 20:29:13 +02:00
|
|
|
#you don't use rc.inet1
|
2004-08-07 04:13:32 +02:00
|
|
|
#########################
|
|
|
|
|
|
|
|
3) I made rc.brige executable and added the following line to /etc/rc.d/rc.local
|
|
|
|
|
|
|
|
/etc/rc.d/rc.bridge </programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2005-01-25 02:10:51 +01:00
|
|
|
<para>Joshua Schmidlkofer writes:</para>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<programlisting>Bridge Setup for Gentoo
|
|
|
|
|
|
|
|
#install bridge-utils
|
|
|
|
emerge bridge-utils
|
|
|
|
|
|
|
|
## create a link for net.br0
|
|
|
|
cd /etc/init.d
|
|
|
|
ln -s net.eth0 net.br0
|
|
|
|
|
|
|
|
# Remove net.eth*, add net.br0 and bridge.
|
|
|
|
rc-update del net.eth0
|
|
|
|
rc-update del net.eth1
|
2005-03-01 21:20:26 +01:00
|
|
|
rc-update add net.br0 default
|
2005-01-25 02:10:51 +01:00
|
|
|
rc-update add bridge boot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/etc/conf.d/bridge:
|
|
|
|
|
|
|
|
#bridge contains the name of each bridge you want created.
|
|
|
|
bridge="br0"
|
|
|
|
|
|
|
|
# bridge_<bridge>_devices contains the devices to use at bridge startup.
|
|
|
|
bridge_br0_devices="eth0 eth1"
|
|
|
|
|
|
|
|
/etc/conf.d/net
|
|
|
|
|
|
|
|
iface_br0="10.0.0.1 broadcast 10.0.0.255 netmask 255.255.255.0"
|
|
|
|
#for dhcp:
|
|
|
|
#iface_br0="dhcp"
|
|
|
|
#comment this out if you use dhcp.
|
|
|
|
gateway="eth0/10.0.0.1" </programlisting>
|
|
|
|
</blockquote>
|
|
|
|
|
2004-04-05 23:13:45 +02:00
|
|
|
<para>Users who successfully configure bridges on other distributions,
|
|
|
|
with static or dynamic IP addresses, are encouraged to send <ulink
|
|
|
|
url="mailto:webmaster@shorewall.net">me</ulink> their configuration so I
|
|
|
|
can post it here.</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Configuring Shorewall</title>
|
|
|
|
|
|
|
|
<para>Bridging in Shorewall is enabled using the BRIDGING option in
|
|
|
|
<filename>/etc/shorewall/shorewall.conf</filename>:</para>
|
|
|
|
|
|
|
|
<programlisting>BRIDGING=Yes</programlisting>
|
|
|
|
|
|
|
|
<para>In the scenario pictured above, there would probably be two zones
|
|
|
|
defined -- one for the internet and one for the local LAN so in
|
|
|
|
<filename>/etc/shorewall/zones</filename>:</para>
|
|
|
|
|
2005-09-04 01:03:06 +02:00
|
|
|
<programlisting>#ZONE TYPE OPTIONS
|
|
|
|
fw firewall
|
2005-09-30 19:39:24 +02:00
|
|
|
net ipv4
|
|
|
|
loc ipv4
|
2004-03-17 16:03:46 +01:00
|
|
|
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE</programlisting>
|
|
|
|
|
|
|
|
<para>A conventional two-zone policy file is appropriate here —
|
|
|
|
<filename>/etc/shorewall/policy</filename>:</para>
|
|
|
|
|
|
|
|
<programlisting>#SOURCE DEST POLICY LOG LIMIT:BURST
|
|
|
|
loc net ACCEPT
|
|
|
|
net all DROP info
|
|
|
|
all all REJECT info
|
|
|
|
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE</programlisting>
|
|
|
|
|
|
|
|
<para>Only the bridge device itself is configured with an IP address so
|
2004-08-19 20:29:13 +02:00
|
|
|
only that device is defined to Shorewall in
|
|
|
|
<filename>/etc/shorewall/interfaces</filename>:</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
|
|
|
- br0 192.168.1.255
|
|
|
|
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</programlisting>
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
<para>The zones are defined using the
|
|
|
|
<filename>/etc/shorewall/hosts</filename> file. Assuming that the router
|
|
|
|
is connected to <filename class="devicefile">eth0</filename> and the
|
|
|
|
switch to <filename class="devicefile">eth1</filename>:</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<programlisting>#ZONE HOST(S) OPTIONS
|
|
|
|
net br0:eth0
|
|
|
|
loc br0:eth1
|
|
|
|
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS LINE -- DO NOT REMOVE</programlisting>
|
|
|
|
|
|
|
|
<para>When Shorewall is stopped, you want to allow only local traffic
|
2004-08-19 20:29:13 +02:00
|
|
|
through the bridge —
|
|
|
|
<filename><filename>/etc/shorewall/routestopped</filename></filename>:</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<programlisting>#INTERFACE HOST(S) OPTIONS
|
|
|
|
br0 192.168.1.0/24 routeback
|
|
|
|
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</programlisting>
|
|
|
|
|
|
|
|
<para>The <filename>/etc/shorewall/rules</filename> file from the
|
|
|
|
two-interface sample is a good place to start for defining a set of
|
|
|
|
firewall rules.</para>
|
|
|
|
</section>
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
<section id="bridge-router">
|
2004-03-17 16:03:46 +01:00
|
|
|
<title>Combination Router/Bridge</title>
|
|
|
|
|
2004-08-19 20:29:13 +02:00
|
|
|
<para>A system running Shorewall doesn't have to be exclusively a bridge
|
|
|
|
or a router -- it can act as both. Here's an example:<graphic
|
2004-03-17 16:03:46 +01:00
|
|
|
fileref="images/bridge2.png" /></para>
|
|
|
|
|
|
|
|
<para>This is basically the same setup as shown in the <ulink
|
|
|
|
url="shorewall_setup_guide.htm">Shorewall Setup Guide</ulink> with the
|
|
|
|
exception that the DMZ is bridged rather than using Proxy ARP. Changes in
|
|
|
|
the configuration shown in the Setup Guide are as follows:</para>
|
|
|
|
|
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>The <filename>/etc/shorewall/proxyarp</filename> file is empty
|
2005-05-28 00:53:55 +02:00
|
|
|
in this configuration.</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>The <filename>/etc/shorewall/interfaces</filename> file is as
|
|
|
|
follows:<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
2004-04-05 23:13:45 +02:00
|
|
|
- br0 detect routefilter
|
2004-03-17 16:03:46 +01:00
|
|
|
loc eth1 detect</programlisting></para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
2004-08-19 20:29:13 +02:00
|
|
|
<para>The <filename>/etc/shorewall/hosts</filename> file would
|
|
|
|
have:</para>
|
2004-03-17 16:03:46 +01:00
|
|
|
|
|
|
|
<programlisting>#ZONE HOSTS OPTIONS
|
|
|
|
net br0:eth0
|
|
|
|
dmz br0:eth2</programlisting>
|
|
|
|
</listitem>
|
2004-10-04 18:47:43 +02:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>The DMZ systems need a route to the 192.168.201.0/24 network via
|
|
|
|
192.0.2.176 to enable them to communicate with the local
|
|
|
|
network.</para>
|
|
|
|
</listitem>
|
2004-03-17 16:03:46 +01:00
|
|
|
</orderedlist>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Limitations</title>
|
|
|
|
|
2005-05-28 00:53:55 +02:00
|
|
|
<para>Bridging doesn't work with some wireless cards — see <ulink
|
2004-03-17 16:03:46 +01:00
|
|
|
url="http://bridge.sf.net">http://bridge.sf.net</ulink>.</para>
|
|
|
|
</section>
|
2004-09-07 18:09:11 +02:00
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Other Links</title>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para><ulink
|
|
|
|
url="http://wiki.buenosaireslibre.org/HowTos_2fBridgedFirewall">Here
|
|
|
|
is an article in Spanish </ulink>detailing bridging a public and local
|
|
|
|
network using Shorewall. This is another router/bridge
|
|
|
|
configuration.</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</section>
|
2004-10-14 21:20:17 +02:00
|
|
|
</article>
|