From: /dev/rob0 <rob0@gmx.co.uk>
To: netfilter@lists.netfilter.org
Subject: Re: Route packets from an interface to another
Date: Fri, 9 Sep 2005 23:45:40 -0500 [thread overview]
Message-ID: <200509092345.40386.rob0@gmx.co.uk> (raw)
In-Reply-To: <2646.83.227.27.100.1126300683.squirrel@webmail.2lug.se>
On Friday 2005-September-09 16:18, Jonathan wrote:
> >> >> >> box2: lo:0 192.121.234.213 netmask 255.255.255.255
> >
> > lo:0 ?? Don't do this. Why are you trying to bind another IP to lo?
>
> a guy I talked to told me to do it, I have no other explaination.
It's simple to see why this is wrong. It's called "loopback", right? The
packets loop back. You're wanting to route them outside. With enough
NAT duct-tape and bubble-gum it could be made to work, but it's ugly.
> >> >> >> between box1 and box2 I have a OpenVPN tunnel (endpoints
> >> >> >> 10.1.0.1 and 10.1.0.2).
> >
> > Why these IP's? You could simplify by using the remote static IP as
> > the IP for your home endpoint. IINM you wouldn't need NAT at all.
> >
> > Remote eth0: 192.121.234.212 netmask 255.255.255.240
> > Remote tun0: 192.121.234.212 netmask 255.255.255.240
> > Home tun0 192.121.234.213 netmask 255.255.255.240
> >
> > When something comes in on eth0 with a destination IP of
> > 192.121.234.213, your kernel knows it needs to go out tun0. If
> > routing is enabled and nothing blocking it in table filter chain
> > FORWARD, out it goes.
> >
> > What you are talking about is indeed possible. I did it myself
> > before figuring out the better way of doing it. :) You need to do
> > both SNAT and DNAT.
>
> Yeah, your solution was much better than mine. :-p
> If I understand you right, the only thing I have to do is to edit my
> openvpn-config and restart the tunnel? No edit in routing tables? And
Yes.[1]
> I have to set up 192.121.234.213 as an alias of eth0 at the remote
> box, right?
Actually I think not. As long as the upstream router knows to send
192.121.234.213 through you, and you have a route to 192.121.234.213, I
think that's enough. Try it and see? I have a machine where I'll try it
too.
[later: I tried it]
The problem, I believe, is the routing on the return. Packets get in,
but replies are trying to go out through the default gateway.
The answer is indeed, either NAT or MARK/--set-mark/fwmark (iproute2).
I'll mess around a bit more and let you know what I find. You are, of
course, welcome to do the same. :)
[even later: success]
Sorry to take away your chance to shine, but I have solved this. :) It
was easier than I thought.
Home machine: LAN address 192.168.6.6/24 (no direct external interface)
Remote machine: x.y.z.112/29
Home openvpn config:
remote x.y.z.112
ifconfig x.y.z.116 192.168.6.248
ifconfig-nowarn
Remote openvpn config:
remote my.dynamic.dnsname
ifconfig 192.168.6.248 x.y.z.116
Started both ends of the tunnel. At home:
# echo 64 tunnel >> /etc/iproute2/rt_tables
# ip rule add from x.y.z.116 table tunnel
# ip route add default via 192.168.6.248 table tunnel
# ip route flush cache
(These should go in an openvpn --up script.)
As it happens, no explicit iptables rules were needed! YMMV depending
upon the rules you have, of course. I do the firewalling on the remote,
so only allowed services and replies to my own connections go through
the tunnel. I had to make sure the filter/FORWARD chain on the remote
would pass the packets I needed. Here at home, filter/INPUT accepts
anything from that interface.
Thanks for the idea, and for the learning experience! I left in the
process, including the incorrect hypotheses. Please note that the
affirmative reply above about NOT needing to edit routing tables was
not correct.
[large snip]
> established an IRC session. Everything worked. But when I tried to
> reach the box via HTTP the connection freezed.
These things, it's hard to say what they might be. Sounds like a
possible physical layer problem. It doesn't sound likely to be a
netfilter issue.
[1] Believed at the time, later proven untrue.
--
mail to this address is discarded unless "/dev/rob0"
or "not-spam" is in Subject: header
next prev parent reply other threads:[~2005-09-10 4:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-09 19:51 Route packets from an interface to another Jonathan
2005-09-09 21:36 ` /dev/rob0
2005-09-09 21:18 ` Jonathan
2005-09-10 4:45 ` /dev/rob0 [this message]
2005-09-10 7:54 ` /dev/rob0
2005-09-12 7:56 ` Jonathan
2005-09-13 1:45 ` /dev/rob0
2005-09-12 13:36 ` Rudi Starcevic
[not found] ` <65aa6af905091114314108597e@mail.gmail.com>
2005-09-11 21:32 ` Fwd: " Edmundo Carmona
2005-09-12 14:39 ` Rudi Starcevic
[not found] ` <65aa6af9050911145833fa12fd@mail.gmail.com>
2005-09-11 21:58 ` Edmundo Carmona
2005-09-12 15:06 ` Fwd: " Rudi Starcevic
[not found] ` <65aa6af9050911151962bc24a2@mail.gmail.com>
2005-09-11 22:20 ` Edmundo Carmona
2005-09-12 15:19 ` Rudi Starcevic
2005-09-11 21:34 ` /dev/rob0
2005-09-12 14:47 ` Rudi Starcevic
2005-09-12 14:51 ` Rudi Starcevic
-- strict thread matches above, loose matches on Subject: below --
2007-09-10 12:18 vinod K D
2007-09-10 15:23 ` Grant Taylor
2005-09-09 19:15 Jonathan
2005-09-09 20:22 ` Edmundo Carmona
2005-09-09 19:32 ` Jonathan
[not found] ` <65aa6af905090913353e0d0150@mail.gmail.com>
2005-09-09 20:35 ` Edmundo Carmona
[not found] ` <1224.83.227.26.235.1126295454.squirrel@webmail.2lug.se>
2005-09-09 21:03 ` Edmundo Carmona
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200509092345.40386.rob0@gmx.co.uk \
--to=rob0@gmx.co.uk \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.