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 |