<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cypris&#039; lookout &#187; Web</title>
	<atom:link href="http://blog.nkadesign.com/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nkadesign.com</link>
	<description>Renaud Bompuis on the interwebs!</description>
	<lastBuildDate>Sat, 14 Jan 2012 06:30:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sysadmin: Multiple ISP firewall &#8211; The setup</title>
		<link>http://blog.nkadesign.com/2009/sysadmin-multiple-isp-firewall-servers-and-redundancy/</link>
		<comments>http://blog.nkadesign.com/2009/sysadmin-multiple-isp-firewall-servers-and-redundancy/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 07:22:24 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=336</guid>
		<description><![CDATA[After suffering broadband trouble for the past 9 months, including interruptions that lasted a few days, I decided to get an additional line installed by a different ISP. I could have bought one of these multi-WAN devices but decided against it for a couple of reasons: I like a challenge and I wanted to achieve [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/linux.png" alt="Linux" title="Linux" align="left" width="54" height="64" hspace="5" vspace="5" border="0" />
After suffering broadband trouble for the past 9 months, including interruptions that lasted a few days, I decided to get an additional line installed by a different ISP.<br />
I could have bought one of these multi-WAN devices but decided against it for a couple of reasons: I like a challenge and I wanted to achieve a particular setup that I wasn&#8217;t sure could be answered by off-the-shelf products (for a reasonable price that is).</p>

<p>This long article is fairly detailed but if your setup is similar it should be enough to get you going quickly.</p>

<ul>
<li><a href="#basicsetup">The basic setup</a></li>
<li><a href="#objectives">Objectives</a></li>
<li><a href="#technologies">Technologies</a></li>
<li><a href="#thingstoknow">Things to know</a></li>
<li><a href="#thingstoread">Things to read</a></li>
<li><a href="#installingshorewall">Installing shorewall</a></li>
<li><a href="#preparingthesystem">Preparing the system</a></li>
<li><a href="#shorewallconfiguration">Shorewall configuration</a></li>
<li><a href="#installingourfirewallrules">Installing our firewall rules</a></li>
<li><a href="#dns">DNS</a></li>
<li><a href="#initialconclusions">Initial conclusions</a></li>
<li><a href="#references">References</a></li>
</ul>

<h3 id="basicsetup">The basic setup</h3>

<p>Without further ado, this is the network configuration:</p>

<p><img src="/wp-content/uploads/2009/02/20090203NetworkDiagram.png" alt="Network Diagram" /></p>

<h4>Notable things</h4>

<p>We have 2 broadband connections:</p>

<ul>
<li><strong>CYBR</strong>, a standard DSL line with a fixed IP <code>111.99.88.77</code> allocated through PPPoE.</li>
<li><strong>HKBN</strong>, a standard 100Mbps line with a fixed IP <code>30.40.50.62</code>.</li>
</ul>

<p>The network is split into different <em>zones</em>:</p>

<ul>
<li>the <strong>Internet zone</strong>, connected to our Firewall through interfaces <code>eth0</code> (<code>ppp0</code>) and <code>eth1</code>.</li>
<li>a <strong>Firewall zone</strong>, delimited by the firewall system itself</li>
<li>a <strong><a href="http://en.wikipedia.org/wiki/DMZ_(computing)">DMZ</a> zone</strong> connected through interface <code>eth2</code> for the servers we want to make visible from the Internet.<br />
The DMZ has its own private subnet delimited by <code>192.168.254.0/255.255.255.0</code>.</li>
<li>a <strong>LAN zone</strong> connected through interface <code>eth3</code> so local computers can access the Internet and be protected from it.<br />
The DMZ has its own private subnet delimited by <code>192.168.0.0/255.255.255.0</code>.  </li>
</ul>

<h3 id="objectives">Objectives</h3>

<p>What we want from our setup:</p>

<ol>
<li>our <em>firewall</em> protects our DMZ and LAN from unwanted access.</li>
<li>our <em>win</em> server can host websites or other services.</li>
<li>our <em>linux</em> server can handle receiving and sending email or other services.</li>
<li>our <em>firewall</em> can handle incoming traffic from either ISP.</li>
<li>our <em>firewall</em> can load-balance local outgoing traffic across both ISP.</li>
<li>If one line fails, <em>incoming</em> traffic switches to the other line.</li>
<li>If one line fails, <em>outgoing</em> traffic switches to the other line.</li>
<li>Eventually, we want both the <em>linux</em> and <em>win</em> servers to be able to host different websites and we want the firewall to send incoming requests to the right server.</li>
</ol>

<p>In this first article, I&#8217;ll present the setup for items 1-5.<br />
The remaining topics will be the subject of subsequent articles of their own.</p>

<h3 id="technologies">Technologies</h3>

<p>The firewall is our primary subject. What is being discussed here is pretty much distribution-independent and should work on all flavours of Linux.</p>

<h4>OS on the firewall system</h4>

<p>I chose <a href="http://www.centos.org/">CentOS</a> on the firewall.<br />
Being an almost byte-for-byte identical copy of <a href="http://www.redhat.com/rhel/">RedHat Enterprise Linux</a>, all configuration will be identical on RedHat and its derivatives such as Fedora.</p>

<h4>Firewall software, first try</h4>

<p>When my firewall needs are simpler, I use the <a href="http://tldp.org/HOWTO/IP-Masquerade-HOWTO/stronger-firewall-examples.html">Stronger IP Firewall Ruleset</a> from the <a href="http://tldp.org/HOWTO/IP-Masquerade-HOWTO/index.html">Linux IP Masquerade HOWTO</a>.<br />
I started to modify the script to adapt it to my new Multi-ISP setup but things got complicated once I needed to debug routing tables.<br />
I got it 80% of the way but tracing network connections and packet routing is complicated and time-consuming.<br />
After a couple of days of peering into log files and <a href="http://www.wireshark.org/">wireshark</a> capture screens, I gave up manual configuration and decided to go with something else.</p>

<h4>Firewall software, final</h4>

<p>The product I chose in the end is <a href="http://shorewall.net/">shorewall</a>: it&#8217;s a very flexible firewall system that create the necessary iptable rules and configure most of the routing needs to properly handle complex network setup.<br />
Shorewall is Open Source, very stable, has been out for a long time, is actively maintained and has lots of excellent documentation and examples.</p>

<h3 id="thingstoknow">Things to know</h3>

<p>Before we get into the meat of the article, you should brush up on the following topics:</p>

<ul>
<li>You have some knowledge of Linux system administration, know how to configure network connections, know how to enable/disable/stop/start  services, able to edit config files.</li>
<li>Networking: you should know what a netmask is, what a gateway is, what a subnet is and have a passing understanding of IP classes, IP notation, what ports are for, what&#8217;s the difference between the tcp, udp, icmp protocols, what Dynamic Port Forwarding (DNAT) is, what Network Address Translation (NAT) is, what <em>masquerading</em> means.</li>
<li>Some basic understanding of DNS and local host name resolving (using <code>host.conf</code> and <code>resolv.conf</code>)</li>
<li>Some basic knowledge of what <em>routing</em> is for and how it works.</li>
<li>Some knowledge of how the linux kernel handles network packets (NetFilter, basics of iptables).</li>
</ul>

<p>You don&#8217;t need to be a specialist in any of these areas but any knowledge helps.<br />
I&#8217;m far from being well versed into Netfilter and routing, it&#8217;s not often that I have to deal directly with these topics, but brushing up on these topics helped.</p>

<h4 id="thingstoread">Things to read</h4>

<p>Shorewall has very extensive documentation. So much so that it can be a bit daunting, not knowing where to start.<br />
I found the following documents helpful to get me started:</p>

<ul>
<li><a href="http://shorewall.net/shorewall_setup_guide.htm">Setup Guide for multiple interfaces</a>.</li>
<li><a href="http://shorewall.net/Shorewall_and_Routing.html">Routing article</a></li>
<li><a href="http://shorewall.net/MultiISP.html">Guide for handling Multi-ISP</a></li>
</ul>

<h3 id="installingshorewall">Installing shorewall</h3>

<p>Go to the download site list [http://shorewall.net/download.htm#Sites]  and download the most appropriate binary package for your distribution.</p>

<p>If you get RPMs for RedHat systems, you only need to install (<code>rpm -ivh</code>) the following packages:</p>

<pre><code>shorewall-4.X.X-X.noarch.rpm
shorewall-perl-4.X.X-X.noarch.rpm 
</code></pre>

<p>If you install from source, only download, compile and install the <em>common</em>, <em>doc</em> and <em>perl</em> packages.</p>

<h3 id="preparingthesystem">Preparing the system</h3>

<p>For shorewall to properly handle both our firewall and packet routing needs, we need to make sure that the other parts of the system are not interfering with it.</p>

<h4>Internet lines</h4>

<p>Make sure that your multiple internet lines are properly working on their own!</p>

<h4>Disable routing</h4>

<ul>
<li>Make sure that you don&#8217;t define a <code>GATEWAY</code> in the configuration of your network interfaces (in <code>/etc/sysconfig/network-scripts/ifcfg-XXX</code>) .</li>
<li>If you use an (A)DSL connection, also set <code>DEFROUTE=no</code> if its <code>ifcfg-XXX</code> file as well.</li>
<li>Remove the <code>GATEWAY</code> from the <code>/etc/sysconfig/network</code> file if there is one.</li>
<li>Edit your <code>/etc/sysctl.conf</code> file and set <code>net.ipv4.conf.default.rp_filter = 0</code>.</li>
</ul>

<h4>Disable firewall</h4>

<p>Disable the current firewall, for instance using the <code>system-config-securitylevel</code> helper tool.<br />
Be careful if you&#8217;re directly connected to the Internet, you will be left without protection!<br />
You can actually wait until shorewall is properly configured to disable the firewall.</p>

<h3 id="shorewallconfiguration">Shorewall configuration</h3>

<p>Shorewall uses a set of simple configuration files, all located under <code>/etc/shorewall/</code>.
For exact detail of each configuration files, have a look at the list of <a href="http://shorewall.net/Manpages.html">man pages</a>.</p>

<h4>Zones</h4>

<p><code>zones</code> are probably the simplest configuration file.<br />
Details in the <a href="http://shorewall.net/manpages/shorewall-zones.html">zones man page</a>.
Here we just name the various zones we want our firewall to handle:</p>

<pre><code>################################################################
#ZONE   TYPE          OPTIONS       IN                  OUT
#                                   OPTIONS             OPTIONS
fw      firewall
net     ipv4
loc     ipv4
dmz     ipv4
</code></pre>

<p>This just reflects our setup as highlighted in the diagram above.</p>

<p>Note that the <code>fw</code> zone is often referred to as the  <code>$FW</code> variable instead in various configuration files.</p>

<h4>Interfaces</h4>

<p>Here we list all the network interfaces connected to our firewall and for which zone they apply.<br />
Details in the <a href="http://shorewall.net/manpages/shorewall-interfaces.html">interfaces man page</a>.</p>

<pre><code>################################################################
#ZONE   INTERFACE       BROADCAST       OPTIONS
net     ppp0            detect
net     eth1            detect
dmz     eth2            detect
loc     eth3            detect
</code></pre>

<p>Note that for our <code>net</code> zone, we list the 2 interfaces connected to our ISPs.<br />
If you&#8217;re using PPPoE to connect, don;t use the interface name <code>eth0</code> but use <code>ppp0</code> instead.</p>

<h4>Policy</h4>

<p>The <code>policy</code> file tells shorewall which default actions should be taken when traffic is moving from one zone to another.<br />
These default actions are taken if no other special action was specified in other configuration files.<br />
View the <code>policy</code> file as a list of default actions for the firewall.<br />
Details about this configuration file as in its <a href="http://shorewall.net/manpages/shorewall-policy.html">man page</a>.</p>

<pre><code>################################################################
#SOURCE DEST    POLICY          LOG     LIMIT:      CONNLIMIT:
#                               LEVEL   BURST       MASK
net     net     DROP            info
loc     net     ACCEPT
dmz     net     ACCEPT
loc     dmz     ACCEPT
loc     $FW     ACCEPT
dmz     $FW     ACCEPT
$FW     net     ACCEPT
dmz     loc     DROP            info
net     all     DROP            info
all     all     DROP            info
</code></pre>

<p>Traffic from one zone to another needs to be explicitely <code>ACCEPTed</code>, <code>REJECTed</code> or <code>DROPped</code>.<br />
For instance, <code>loc net ACCEPT</code> means that we allow all traffic from our local LAN to the Internet, while <code>net all DROP</code> means we don&#8217;t allow incoming traffic from the internet to anyone (remember this is the default action, in most cases we will override this for specific types of traffic in the <code>rules</code> file).<br />
When we set the default action to <code>DROP</code>, we can tell shorewall to keep a trace of the details in the <code>/var/log/messages</code> log.</p>

<h4>Providers</h4>

<p>The providers file is generally only used in a multi-ISP environment.<br />
Here we define how we want to <em>mark</em> packets originating from one ISP with a unique ID so we can tell the kernel to route these packets to the right interface.<br />
Not doing this would get packets received from one interface to be routed to the default gateway instead.<br />
The details of this configuration file are explained in the <a href="http://shorewall.net/manpages/shorewall-providers.html">providers man page</a> for it.</p>

<pre><code>#############################################################################
#NAME NUMBER MARK DUPLICATE INTERFACE GATEWAY      OPTIONS          COPY
CYBR  1      0x1  main      ppp0      -            track,balance=1  eth2,eth3
HKBN  2      0x2  main      eth1      30.40.50.61  track,balance=5  eth2,eth3
</code></pre>

<p>Note that the <code>DUPLICATE</code> columns tells shorewall that it should make a copy of the main default routing table for this particular routing table (called <code>CYBR</code> or <code>HKBN</code> depending on which ISP we refer to).<br />
Packets are marked with number 0&#215;1 or 0&#215;2 so we can distinguish them during their travel through the system.<br />
For PPPoE connections, don&#8217;t specify a <code>GATEWAY</code> since it&#8217;s most likely that your ISP didn&#8217;t give you one.</p>

<p>The most interesting part of this file are the <code>OPTIONS</code>: <code>track</code> means that we want the packets to be tracked as they travel through the system; <code>balance</code> tells the kernel that we want traffic coming out to be spread over both interfaces.<br />
Additionally, we want HKBN to receive more or less 5 times more traffic than CYBR (note that this has no effect on reply packets).</p>

<p>The <code>COPY</code> columns will ensure that the routing tables created for CYBR and HKBN are copied for each internal interface, so our <code>eth2</code> and <code>eth3</code> interfaces know how to route packets to the right ISP.</p>

<h4>Route Rules</h4>

<p>For our purpsose, the <code>route_rules</code> file only describes how traffic should be routed through one or the other ISP we set up in <code>/etc/shorewall/providers</code>.<br />
Details are in the <a href="http://shorewall.net/manpages/shorewall-route_rules.html">route_rules file man page</a>.</p>

<pre><code>#####################################################################
#SOURCE             DEST               PROVIDER        PRIORITY
ppp0                -                  CYBR            1000
eth1                -                  HKBN            1000
</code></pre>

<p>Here we simply say that all traffic through the <code>CYBR</code> table should be sent to <code>ppp0</code>.<br />
The <code>PRIORITY</code> is an ordering number that tell shorewall to consider this routing rule before it marks the packets. Since we know the packets originated from <code>ppp0</code> or <code>eth1</code> we don&#8217;t really need to mark them.</p>

<h4>Masq</h4>

<p>The <code>masq</code> file will contain the masquerading rules for our private interfaces: in essence, we want traffic from the local LAN and DMZ to be hidden behind our limited number of external IPs.<br />
See the <a href="http://shorewall.net/manpages/shorewall-masq.html">masq manpage</a> for all the details.</p>

<pre><code>#####################################################################
#INTERFACE              SOURCE           ADDRESS                 
# Ensure that traffic originating on the firewall and redirected via 
# packet marks always has the source IP address corresponding to the 
# interface that it is routed out of.
# See http://shorewall.net/MultiISP.html#Example1
ppp0                    30.40.50.62      111.99.88.77
eth1                    111.99.88.77     30.40.50.62
ppp0                    eth2             111.99.88.77
eth1                    eth2             30.40.50.62
ppp0                    eth3             111.99.88.77
eth1                    eth3             30.40.50.62
</code></pre>

<p>The first part ensures that the traffic coming out of our public interfaces but originating from the other is actually rewritten as originating from the right IP for the interface.<br />
This ensures that packets leaving <code>eth1</code> for instance don&#8217;t come out with the wrong source address of the <em>other</em> interface.<br />
The second part of the ensures that packets from our LAN or DMZ leaving either public interfaces are doing so with the right IP address, so traffic from my desktop going through <code>ppp0</code> for instance, will have its source address as <code>100.90.80.70</code>.</p>

<h4>Rules</h4>

<p>This is the main file where we tell shorewall our basic configuration and how we want packets to be handled in the general case.<br />
The <code>/etc/shorewall/rules</code> file contains the specific instructions on where to direct traffic that will override the default actions defined in the <code>/etc/shorewall/policy</code> file.</p>

<pre><code>#####################################################################
#ACTION    SOURCE                DEST                   PROTO  
#                                                                     
SECTION NEW
# Drop and log packets that come from the outside but pretend 
# to have a local address
DROP:info  net:192.168.0.0/24    all
DROP:info  net:192.168.254.0/24  all

# Redirect incoming traffic to the correct server for WWW and email
DNAT       all                   dmz:192.168.254.20     tcp   www
DNAT       all                   dmz:192.168.254.10     tcp   110
DNAT       all                   dmz:192.168.254.10     tcp   143
DNAT       all                   dmz:192.168.254.10     tcp   25
</code></pre>

<p>In its most basic form, what we&#8217;ve just defined here is that we want all traffic from anywhere destined for port 80 (www) to be sent to our <em>win</em> server.<br />
All mail traffic, POP3 (port 110), IMAP (port 143) and SMTP (port 25) is to be redirected to our <em>linux</em> server in the DMZ.</p>

<p>There are a few more useful rules that we can include, for instance, I want to be able to access my servers  through either ISPs from home (IP <code>123.45.67.89</code>) and disallow everyone else from accessing it.</p>

<pre><code>#####################################################################
#ACTION    SOURCE                DEST                   PROTO  
#                                                                     
# Allow SSH to the firewall from the outside only from home

ACCEPT     net:123.45.67.89      $FW                    tcp   ssh
# Redirect input traffic to the correct server for RDP, VNC and SSH 
DNAT       net:123.45.67.89      dmz:192.168.254.10:22  tcp   2222
DNAT       net:123.45.67.89      dmz:192.168.254.10     tcp   5901
DNAT       net:123.45.67.89      dmz:192.168.254.20     tcp   3389
</code></pre>

<p>When I SSH to <code>30.40.50.62</code> or <code>100.90.80.70</code>, on the normal port 22, I will access the firewall.<br />
Now if I SSH to the non-standard port 2222, I will instead access the <em>linux</em> server.<br />
Ports 5901 are for remoting through VNC on the <em>linux</em> machine, and port 3389 will be used for Remote Desktop connections to the <em>win</em> server.</p>

<p>To make sure my machines are up and running, I like to be able to ping them:</p>

<pre><code>#####################################################################
#ACTION    SOURCE              DEST              PROTO  
#                                                                     
# Accept pings between zones
ACCEPT     dmz                 loc               icmp  echo-request
ACCEPT     loc                 dmz               icmp  echo-request
</code></pre>

<p>Note that ping will only work between the LAN and the DMZ and pinging my firewall from the Internet will result in the requests being silently dropped.<br />
I usually prefer that configuration as it makes discovering the servers by random bots slightly less likely.</p>

<p>There are lots of other cool things we can do with forwarding but that will do for now.</p>

<h4>shorewall.conf</h4>

<p>The last file we&#8217;re going to look at is the main configuration file for shorewall.<br />
See details about each option from the <a href="http://shorewall.net/manpages/shorewall.conf.html">man page for <code>shorewall.conf</code></a>.</p>

<p>Most options are OK by default. The only ones that I have had to change are:</p>

<pre><code>STARTUP_ENABLED=Yes
MARK_IN_FORWARD_CHAIN=Yes
FASTACCEPT=Yes
OPTIMIZE=1
</code></pre>

<p>The first option tells shorewall that we want it to start automatically when the system boots.<br />
That&#8217;s not enough though, so make sure that the service will be started:</p>

<pre><code># chkconfig shorewall --levels 235 on
</code></pre>

<h3 id="installingourfirewallrules">Installing our firewall rules</h3>

<p>Shorewall configuration files need to be compiled without error before the firewall is actually loaded by shorewall.<br />
The command:</p>

<pre><code># shorewall restart
</code></pre>

<p>will stop and recompile the current configuration.<br />
If there are any errors, the current firewall rules will be unchanged.<br />
There are lots of other commands that can be issued. Check the man page for a complete list.</p>

<p>If you use PPPoE, you will want the firewall to be restarted every time the line reconnects.<br />
The simplest way is to create a file <code>/etc/ppp/if-up.local</code> with only a single line:</p>

<pre><code>shorewall restart
</code></pre>

<h3 id="dns">DNS</h3>

<p>There is one remaining issue with our firewall: if a user on the LAN attempts to access the web server by its name the request will probably fail.<br />
Same for accessing our mail server: we can configure our desktop to connect to <code>192.168.254.10</code> to get and send emails, but on the laptop we would usually use something like <code>pop.acme.com</code> instead so we can read our emails from outside the office.</p>

<p>Similarly, trying to access <code>www.acme.com</code> hosted on the <em>win</em> server from the <em>linux</em> server will fail.</p>

<p>One solution is to route traffic through the firewall but that&#8217;s actually fairly complicated to setup properly.<br />
The shorewall FAQ 2 discourages this and instead recommends the use of <a href="http://en.wikipedia.org/wiki/Split-horizon_DNS">split-DNS</a>: it&#8217;s very easy to setup and it works like a charm.</p>

<h4>dnsmasq</h4>

<p>Just install  <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> on the firewall. There are ready-made packages available for it and a simple <code>yum install dsnmasq</code> should suffice.</p>

<p>Dnsmasq provides a simple DNS forwarding and DHCP service. I had already configured <code>dhcpd</code> -which is already fairly simple to configure- on my firewall so I won&#8217;t need DHCP from dnsmasq but you can easily set it up if you want.</p>

<p>On the DNS side, dnsmasq can be told to first try to resolve hostnames by looking at the standard <code>/etc/hosts</code> file and then query the DNS servers defined in <code>/etc/resolv.conf</code> if necessary.</p>

<p>This simple trick means that we can:</p>

<ul>
<li>Keep our normal DNS service pointing to say <code>100.90.80.70</code> for <code>www.acme.com</code> so that people on the Internet will properly resolve their web requests to our <em>win</em> server.</li>
<li>Add an entry in the firewall&#8217;s <code>hosts</code> file to point local clients to <code>192.168.254.20</code> instead.</li>
</ul>

<p>To achieve this, simply edit  <code>/etc/hosts</code>and add entries matching all your services:</p>

<pre><code># Acme's services. 
# One line for each DNS entries accessible from the Internet
192.168.254.20        acme.com
192.168.254.20        www.acme.com
192.168.254.10        pop.acme.com
192.168.254.10        mail.acme.com
</code></pre>

<h4>dsnmasq configuration</h4>

<p>Edit the <code>/etc/dsnmasq.conf</code> and uncomment or add the following lines:</p>

<pre><code># Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
# listen on DMZ and LAN interfaces
interface=eth2
interface=eth3
# don't want dnsmasq to provide dhcp
no-dhcp-interface=eth2
no-dhcp-interface=eth3
</code></pre>

<p>Then make sure that dsnmasq will start on boot:</p>

<pre><code># chkconfig dnsmasq --levels 235 on
# service dnsmasq restart
</code></pre>

<h4 id="dnsresolution">DNS resolution</h4>

<p>There may be one last issue with DNS: in your <code>/etc/resolv.conf</code> you will have listed the DNS servers of one or both of your ISPs.<br />
The problem is that some ISPs don&#8217;t allow access to their name servers from a network different than theirs.</p>

<p>The result is that each time any of the systems issues a DNS request it may fail and need to be sent to the next server instead, which may also fail and introduce delays in accessing named resources on the Internet.</p>

<p>One easy way out is to not use the ISPs DNS servers but instead only list the free <a href="http://opendns.org/">OpenDNS</a> name servers in your <code>resolv.conf</code>:</p>

<pre><code>search acme.com
nameserver 208.67.222.222
nameserver 208.67.220.220
</code></pre>

<p>Then make sure that you disable DNS in your <code>/etc/sysconfig/network-config/ifcfg-XXX</code> configuration file for your PPPoE connection:</p>

<pre><code>PEERDNS=no
</code></pre>

<p>Failure to do so will result in your <code>/etc/resolv.conf</code> file being rewritten with the DNS servers of one of your ISP every time you reconnect to them.</p>

<h4>DHCP configuration</h4>

<p>If you use <code>dhcpd</code> for local users, then you will need to make sure that its DNS server is set to the firewall&#8217;s:</p>

<pre><code># DHCP Server Configuration file.
ddns-update-style none;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {
    option routers                  192.168.0.1;
    option subnet-mask              255.255.255.0;
    option domain-name              "acme.com";
    option domain-name-servers      192.168.0.1;
    range 192.168.0.200 192.168.0.250;
    default-lease-time 86400;
    max-lease-time 132000;
}
</code></pre>

<p>On your local machines that use DHCP, make sure to renew your IP.<br />
All other machines should be configured to use <code>192.168.0.1</code> as their unique DNS server and the machines in the DMZ should have their DNS set to <code>192.168.254.1</code>.</p>

<p>Unless you reboot, don&#8217;t forget and flush the local DNS cache of each machine:<br />
On Windows, from the command line:</p>

<pre><code>C:\&gt; ipconfig /flushdns
</code></pre>

<p>On Mac, from the terminal:</p>

<pre><code>bash-x.xxx$ dnscacheutil -flushcache
</code></pre>

<h3 id="initialconclusions">Initial conclusions</h3>

<p>I believe this type of firewall setup is fairly common and I hope that the -rather long- article helped you get your own setup in place.<br />
In the -much shorter- follow-up articles, we&#8217;ll make our system as redundant as possible so our web and email services stay online even when one of the broadband connections fails.</p>

<p>In the meantime, don&#8217;t hesitate to leave your comments and corrections below.</p>

<h3 id="history">History</h3>

<ul>
<li>06FEB2009: added info about restarting the firewall on <a href="#installingourfirewallrules">PPPoE reconnection</a> and disabling <a href="#dnsresolution">ISP&#8217;s DNS resolution</a>.</li>
<li>04FEB2009: initial release.</li>
</ul>

<h3 id="references">References</h3>

<ul>
<li><a href="http://shorewall.net/">Shorewall</a>&#8216;s main site.</li>
<li>Shorewall&#8217;s [man page][manpage] list for all configuration files.</li>
<li><a href="http://opendns.org/">OpenDNS</a> free worldwide DNS service (and more).</li>
<li><a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> DNS forwarder (for easily setting up <a href="http://en.wikipedia.org/wiki/Split-horizon_DNS">split-horizon-DNS</a>).</li>
<li><a href="http://www.centos.org/">CentOS</a> linux distribution, based on <a href="http://www.redhat.com/rhel/">RedHat Enterprise Linux</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/sysadmin-multiple-isp-firewall-servers-and-redundancy/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Windows 2008 / Windows 7 x64: The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine.</title>
		<link>http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/</link>
		<comments>http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 13:31:53 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=236</guid>
		<description><![CDATA[There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues. One of them just occurred to me while trying to run the ASPx demos from Developer Express, my main provider of .Net components (the best supplier I&#8217;ve ever been able to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology01.png" alt="Technology" title="Technology" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues.<br />
One of them just occurred to me while trying to run the <a href="http://www.devexpress.com/Downloads/NET/OnlineDemos.xml">ASPx demos</a> from <a href="http://www.devexpress.com/">Developer Express</a>, my main provider of .Net components (the best supplier I&#8217;ve ever been able to find).<br />
I was getting the following error:</p>

<p><em>The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine:</em> 
<center><img src="/wp-content/uploads/2008/10/sshot-2.png" alt="Server Error" /></center></p>

<p>It may look otherwise, but this error is generally due to either of two thing:</p>

<ul>
<li>you don&#8217;t have Office 2007/2010 Jet drivers installed</li>
<li>or you are running a 32 bit application in a default x64 environment.</li>
</ul>

<p>The first issue is easy to solve, just download the <a href="http://www.microsoft.com/download/en/details.aspx?id=13255">Access 2010 Database Engine</a> from Microsoft (works with Access 2007 databases as well).</p>

<p>For the second one, the fix is also easy enough:</p>

<ul>
<li><em>For Windows 2008</em>: Navigate to  Server Manager > Roles > Web Server (IIS)  > Internet Information Services (IIS) Manager,  then look under your machine name > Application Pool.</li>
<li><em>For Windows 7</em>: Navigate to  Programs > Administrative Tools > Internet Information Services (IIS) Manager,  then look under your machine name > Application Pool.</li>
</ul>

<p><center><a title="Server Manager" style="border:0;" href="/wp-content/uploads/2008/10/sshot-6.png" rel="lightbox"><img title="Server Manager" src="/wp-content/uploads/2008/10/sshot-6sm.png" width=560 Height=410 /></a></center></p>

<p>Under there you can call the DefaultAppPool&#8217;s advanced settings to change <code>Enable 32-Bits Applications</code> to <code>True</code>:<br />
<center><img src="/wp-content/uploads/2008/10/sshot-3.png" alt="Advanced Settings" /></center></p>

<p>You may have to restart the service for it to take effect but it should work.</p>

<h3>References</h3>

<ul>
<li><a href="http://www.hanselman.com/blog/BackToBasics32bitAnd64bitConfusionAroundX86AndX64AndTheNETFrameworkAndCLR.aspx">Scott Hanselman&#8217;s blog entry</a> about undestanding 64 vs. 32 bitness in .Net.</li>
<li><a href="http://www.microsoft.com/download/en/details.aspx?id=13255">Access 2010 Database Engine driver</a></li>
</ul>

<h3>Updates</h3>

<ul>
<li>10DEC2011: Updated driver link to use the Access 2010 engine.</li>
<li>03APR2010: Added instructions for Windows 7</li>
<li>12FEB2009: Added reference to Scott&#8217;s article.</li>
<li>28OCT2008: Original version</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/feed/</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
	</channel>
</rss>

