1 |
On 04/10/2013 21:55, Grant Edwards wrote: |
2 |
> Let's posit two network interfaces net1 (192.168.x.y/16) and net2 |
3 |
> (172.16.a.b/16). There's a NAT/gateway available on each of the |
4 |
> networks. I want to use the 172.16 gateway for TCP connections to port |
5 |
> 80 and the 192.168 gateway for everything else. |
6 |
> |
7 |
> I'm primarily following this example: |
8 |
> |
9 |
> http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.netfilter.html |
10 |
> |
11 |
> My "main" routing table contains all directly accessible subnets plus |
12 |
> a default route via the 192.168 gateway. |
13 |
> |
14 |
> I created a second route table named "pmain" which is identical to |
15 |
> "main" except it has a different default route via the 172.16 gateway. |
16 |
> |
17 |
> My ip rules are: |
18 |
> |
19 |
> 0: from all lookup local |
20 |
> 10000: from all fwmark 0x1 lookup pmain |
21 |
> 32766: from all lookup main |
22 |
> 32767: from all lookup default |
23 |
> |
24 |
> I then add an iptables rule like this: |
25 |
> |
26 |
> iptables -A OUTPUT -t mangle -p tcp --dport 80 -j MARK --set-mark 1 |
27 |
|
28 |
It would help if you were to also supply the details of: |
29 |
|
30 |
* ip -f inet -o a s |
31 |
* ip route show table main |
32 |
* ip route show table pmain |
33 |
|
34 |
> |
35 |
> Now all TCP packets destined for port 80 are sent to the 172.16 |
36 |
> gateway, _but_ they're being sent with a 192.168 source address. The |
37 |
> TCP stack is apparently unaware of the advanced routing tricks and |
38 |
> thinks that the packets are going out via the 192.168 gateway. |
39 |
> |
40 |
> IOW I've succesfully re-routed TCP _packets_ but not the TCP |
41 |
> _connection_. |
42 |
> |
43 |
> How do I tell the TCP stack that it's supposed to use the 172.16 |
44 |
> inteface/gateway for connections to port 80? |
45 |
|
46 |
--Kerin |