1 |
Am Tue, 28 Mar 2017 21:26:05 +0200 |
2 |
schrieb Dan Johansson <Dan.Johansson@×××.nu>: |
3 |
|
4 |
> Slight Off-topic, but at least the host are Gentoo. |
5 |
> |
6 |
> Is it possible, using iptables or something equivalent, to redirect |
7 |
> traffic to some specific TCP ports to another gateway than the |
8 |
> default-gateway? |
9 |
> |
10 |
> Eg. |
11 |
> |
12 |
> Host 192.168.1.100/24 has a default-gateway of 192.168.1.1 |
13 |
> Now I want to send all traffic from this host to destination-tcp-port |
14 |
> 80 to gateway 192.168.2.1 instead (the host has a second interface |
15 |
> with the address 192.168.2.100/24 as well). |
16 |
> I only want the traffic to port 80 to go thru this GW (and then to |
17 |
> its final destination). |
18 |
> And port 80 is just an example, it could be port 12345 as well. |
19 |
> |
20 |
> Is this possible? If yes, any suggestion on how to do it? |
21 |
|
22 |
If I understand you correctly, you want to do the redirect decision on |
23 |
the source machine 192.168.1.100, and not on the default gateway |
24 |
192.168.1.1. |
25 |
|
26 |
This means you need to mark packages with iptables, and then doing the |
27 |
routing based on the mark. For this, you need to setup policy routing. |
28 |
Look here: |
29 |
|
30 |
http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.netfilter.html |
31 |
|
32 |
That example uses port 25 instead of 80. It marks packets, and then |
33 |
creates a second routing table to use for such marked packets. |
34 |
|
35 |
-- |
36 |
Regards, |
37 |
Kai |
38 |
|
39 |
Replies to list-only preferred. |