<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>syst.eng. Anders Larsen - linux</title><link href="/" rel="alternate"></link><link href="http://www.alarsen.net/feeds/linux.atom.xml" rel="self"></link><id>/</id><updated>2013-03-23T20:14:00+01:00</updated><entry><title>Port-based routing</title><link href="/posts/port-based-routing.html" rel="alternate"></link><published>2013-03-23T20:14:00+01:00</published><updated>2013-03-23T20:14:00+01:00</updated><author><name>Anders Larsen</name></author><id>tag:None,2013-03-23:/posts/port-based-routing.html</id><summary type="html">&lt;p class="first last"&gt;Port-based routing&lt;/p&gt;
</summary><content type="html">&lt;p&gt;My current network setup looks somewhat like this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
                         ________     \            /     ________
          __________    |        |    /            \    |        |
_________|          |___| ADSL-  |____\  Internet  /____| root   |
  LAN    | firewall |   | router |    /            \    | server |
         |__________|   |________|    \            /    |________|
             ^                        /            \        ^
             :..............................................:
                              OpenVPN tunnel
&lt;/pre&gt;
&lt;p&gt;My local Internet connection (left-hand side)
does not have a fixed IPv4 address,
so I used to send outgoing e-mails through my mail-hosting provider,
who unfortunately &lt;a class="reference external" href="/posts/server-outage.html"&gt;went south last month&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The root-server on the right-hand side,
which hosts some virtual machines,
has a fixed, global IPv4 address, and since I control the DNS zone file,
I decided to have it handle outgoing as well as incoming e-mail traffic.&lt;/p&gt;
&lt;p&gt;One of the virtual machines on the root-server hosts a &lt;a class="reference external" href="http://www.postfix.org/"&gt;Postfix&lt;/a&gt; mail-server,
another hosts an &lt;a class="reference external" href="//www.apache.org/"&gt;Apache&lt;/a&gt; web-server.&lt;/p&gt;
&lt;p&gt;The easy part was to route incoming traffic to those VMs
using &lt;em&gt;iptables&lt;/em&gt; on the root-server:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 25 -j DNAT --to-destination &amp;quot;IP of Postfix VM&amp;quot;
# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination &amp;quot;IP of Apache VM&amp;quot;
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source &amp;quot;global IP of root-server&amp;quot;
&lt;/pre&gt;
&lt;p&gt;Now, routing outgoing e-mail traffic from my LAN through the root-server
without passing &lt;em&gt;all&lt;/em&gt; traffic through the VPN tunnel was a bit more tricky.&lt;/p&gt;
&lt;p&gt;First, declare a new routing table for &lt;a class="reference external" href="//wiki.linuxfoundation.org/networking/iproute2"&gt;iproute2&lt;/a&gt; on the firewall;
let's call it &amp;quot;smtp&amp;quot; and assign it the (arbitrary) number 25:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# echo &amp;quot;25 smtp&amp;quot; &amp;gt;&amp;gt; /etc/iproute2/rt_tables
&lt;/pre&gt;
&lt;p&gt;Next, when the VPN tunnel comes up,
add a default route using the new table &lt;em&gt;smtp&lt;/em&gt;
and force marked packets through that route:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# ip route add default via &amp;quot;root-server IP on VPN&amp;quot; table smtp
# ip rule add fwmark 0x01 lookup smtp
&lt;/pre&gt;
&lt;p&gt;(the above two commands could be placed in the &lt;a class="reference external" href="//openvpn.net/"&gt;OpenVPN&lt;/a&gt; &amp;quot;up&amp;quot; script).&lt;/p&gt;
&lt;p&gt;Finally, mark outgoing SMTP packets using &lt;em&gt;iptables&lt;/em&gt; on the firewall:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# iptables -t mangle -A OUTPUT -p tcp --dport 25 -j MARK --set-mark 0x01
&lt;/pre&gt;
&lt;p&gt;Et voilà - SMTP packets originating on the firewall
(which queues outgoing e-mails using Postfix)
are routed through the VPN tunnel and exit from the root-server
(using its global IP address).&lt;/p&gt;
&lt;p&gt;With outgoing e-mail traffic originating from a fixed IP address,
configuring &lt;a class="reference external" href="http://www.dkim.org/"&gt;DKIM&lt;/a&gt; and &lt;a class="reference external" href="http://www.openspf.org/"&gt;SPF&lt;/a&gt; is now possible.&lt;/p&gt;
</content><category term="linux"></category><category term="networking"></category></entry><entry><title>The QNX4 file-system in Linux</title><link href="/posts/qnx4fs.html" rel="alternate"></link><published>2004-02-03T21:01:00+01:00</published><updated>2004-02-03T21:01:00+01:00</updated><author><name>Anders Larsen</name></author><id>tag:None,2004-02-03:/posts/qnx4fs.html</id><summary type="html">&lt;p class="first last"&gt;The QNX4 file-system in Linux&lt;/p&gt;
</summary><content type="html">&lt;p&gt;The QNX4 file-system option in Linux allows you to mount QNX4/QNX6-formatted
floppies and hard-disk partitions on your Linux box and access
the files as if they were on your native file-system.&lt;/p&gt;
&lt;p&gt;It was originally written by Richard A. Frowÿn and Frank Denis, who -
due to lack of time - passed the maintainership on to me in december 1999.&lt;/p&gt;
&lt;p&gt;I fixed the last severe bugs in Kernels 2.2.15 and 2.3.35;
previous versions were quite buggy and did not support fragmented files at all.&lt;/p&gt;
&lt;p&gt;Starting with Kernel 2.4.19 it is possible to mount partitions created
with QNX version 6.1 and above.&lt;/p&gt;
&lt;p&gt;A bug that got exposed by subtle changes to the Virtual File System can cause
a &lt;strong&gt;complete system hang&lt;/strong&gt; when using the QNX4 file-system in Kernel 2.4.8
and 2.4.9 - the solution is to comment out line 399 of fs/qnx4/inode.c
(the problem was fixed in Kernel 2.4.10)&lt;/p&gt;
&lt;p&gt;There's an alternative implementation which supports writing to the QNX
partition at &lt;a class="reference external" href="http://qnxfs.narod.ru/"&gt;http://qnxfs.narod.ru/&lt;/a&gt;, but I don't use it myself and cannot
guarantee that it will work for you.&lt;/p&gt;
&lt;div class="section" id="related-software"&gt;
&lt;h2&gt;Related software&lt;/h2&gt;
&lt;p&gt;Peter Waechtler (formerly of QSSL Germany) wrote a &lt;tt class="docutils literal"&gt;dinit&lt;/tt&gt;-like utility
to initialize the QNX4 file-system from within Linux; you can get a copy here:
&lt;a class="reference external" href="/files/dinit.tgz"&gt;dinit.tgz&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you are familiar with QNX and its Send/Receive/Reply IPC paradigm and would
like to use a similar mechanism with Linux, check the
S.I.M.P.L. project at &lt;a class="reference external" href="http://www.icanprogram.com/simpl/"&gt;http://www.icanprogram.com/simpl/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A light-weight library implemented by Sam Roberts was available
at &lt;a class="reference external" href="http://www.cogent.ca/Software/SRR.html"&gt;http://www.cogent.ca/Software/SRR.html&lt;/a&gt;, but that link is dead now.&lt;/p&gt;
&lt;p&gt;You may wish to see the QNX community portal at &lt;a class="reference external" href="http://www.openqnx.com/"&gt;http://www.openqnx.com/&lt;/a&gt;
for news, explanations, FAQ, forums, newsgroups, mailing lists,
software downloads, weblinks, tech reviews, searches, fun, tips,
online live support around QNX4 and QNX6.&lt;/p&gt;
&lt;/div&gt;
</content><category term="linux"></category><category term="qnx4"></category><category term="qnx4fs"></category></entry><entry><title>Booting Linux on a WindowsCE device</title><link href="/posts/amd-elan.html" rel="alternate"></link><published>2001-03-13T20:23:00+01:00</published><updated>2001-03-13T20:23:00+01:00</updated><author><name>Anders Larsen</name></author><id>tag:None,2001-03-13:/posts/amd-elan.html</id><summary type="html">&lt;p class="first last"&gt;Booting Linux on a WindowsCE device&lt;/p&gt;
</summary><content type="html">&lt;p&gt;I've written a &lt;a class="reference external" href="/files/LinuxCE.tar.gz"&gt;utility&lt;/a&gt;
to boot Linux 2.2.x via the WinCE loader on the credit-card size PC
&amp;quot;DIMM-PC EC&amp;quot; (manufactured by the German company &lt;a class="reference external" href="http://www.gesytec.de/uk/"&gt;Gesytec GmbH&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This module utilizes an AMD Élan SC410 PC-on-a-chip, which,
unfortunately, has some peculiarities.&lt;/p&gt;
&lt;p&gt;The company &lt;a class="reference external" href="http://www.pengutronix.de/index_en.html"&gt;Pengutronix&lt;/a&gt; provides &lt;a class="reference external" href="http://www.pengutronix.de/software/elan/index_en.html"&gt;patches&lt;/a&gt; against 2.4.13 .. 2.4.17
which fixes a clock drift problem
and provides a work-around for a nasty serial interface bug.&lt;/p&gt;
&lt;p&gt;The patches were merged into 2.4.18,
so you probably don't need them separately, though.&lt;/p&gt;
</content><category term="bootloaders"></category><category term="linux"></category></entry></feed>