Gentoo Archives: gentoo-user

From: Walter Dnes <waltdnes@××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] Redirecting traffic for a TCP port to another gateway
Date: Tue, 28 Mar 2017 21:35:23
Message-Id: 20170328213438.GA13526@waltdnes.org
In Reply to: [gentoo-user] [OT] Redirecting traffic for a TCP port to another gateway by Dan Johansson
1 On Tue, Mar 28, 2017 at 09:26:05PM +0200, Dan Johansson wrote
2
3 > Host 192.168.1.100/24 has a default-gateway of 192.168.1.1
4 > Now I want to send all traffic from this host to destination-tcp-port 80
5 > to gateway 192.168.2.1 instead (the host has a second interface with the
6 > address 192.168.2.100/24 as well).
7 > I only want the traffic to port 80 to go thru this GW (and then to its
8 > final destination).
9 > And port 80 is just an example, it could be port 12345 as well.
10 >
11 > Is this possible? If yes, any suggestion on how to do it?
12
13 Use the FORWARD table (yes, it's built-in). You'll need to divert
14 those packets from that source with "--dport 80" (i.e. destination port
15 80) from regular output to the built-in FORWARD table.
16
17 iptables -A OUTPUT --source 192.168.1.100/24 --dport 80 -j FORWARD
18
19 Step 2) I'm not familiar with the FORWARD table (never used it), but I
20 assume that you can specify stuff in it about where to forward.
21
22 --
23 Walter Dnes <waltdnes@××××××××.org>
24 I don't run "desktop environments"; I run useful applications