Linux Netfilter discussions
 help / color / mirror / Atom feed
* Split traffic between VPN and local interface
@ 2016-03-31  5:32 Perol.Chen
  2016-03-31 12:23 ` Pascal Hambourg
  0 siblings, 1 reply; 3+ messages in thread
From: Perol.Chen @ 2016-03-31  5:32 UTC (permalink / raw)
  To: netfilter

Dear all:

I start one vpn client on my computer, but I want my country's traffic
direct from local interface,

because the ip list is large, so I save them to ipset named chinaip.

I use commands below split the traffic, 192.168.1.1 is local interface
gateway, 10.7.0.2 is the vpn tun ip.


id="11"
ip rule add fwmark $id lookup $id
ip route add default via 192.168.1.1 table $id
iptables -t mangle -I OUTPUT 1 -m set --match-set chinaip dst -j MARK
--set-mark $id
iptables -t nat -A POSTROUTING -s 10.7.0.2 -o eth0 -j MASQUERADE


wireshark show the traffic send to eth0, but the local process can not
receive data.

128    5.583482000    192.168.1.118    180.149.134.141    TCP    74
33474 > http [SYN] Seq=0 Win=27840 Len=0 MSS=1392 SACK_PERM=1
TSval=17843425 TSecr=0 WS=128

129    5.586962000    180.149.134.141    192.168.1.118    TCP    66
http > 33474 [SYN, ACK] Seq=0 Ack=1 Win=14600 Len=0 MSS=1448
SACK_PERM=1 WS=128

249    6.332233000    192.168.1.118    180.149.134.141    TCP    74
[TCP Retransmission] 33473 > http [SYN] Seq=0 Win=27840 Len=0 MSS=1392
SACK_PERM=1 TSval=17843613 TSecr=0 WS=128

250    6.335188000    180.149.134.141    192.168.1.118    TCP    66
[TCP Retransmission] http > 33473 [SYN, ACK] Seq=0 Ack=1 Win=14600
Len=0 MSS=1448 SACK_PERM=1 WS=128

There are all TCP Retransmission, Are there something problems?

Thanks very much.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Split traffic between VPN and local interface
  2016-03-31  5:32 Split traffic between VPN and local interface Perol.Chen
@ 2016-03-31 12:23 ` Pascal Hambourg
  2016-04-01 14:43   ` Perol.Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Pascal Hambourg @ 2016-03-31 12:23 UTC (permalink / raw)
  To: Perol.Chen; +Cc: netfilter

Le 31/03/2016 07:32, Perol.Chen a écrit :
> Dear all:
>
> I start one vpn client on my computer, but I want my country's traffic
> direct from local interface,
>
> because the ip list is large, so I save them to ipset named chinaip.
>
> I use commands below split the traffic, 192.168.1.1 is local interface
> gateway, 10.7.0.2 is the vpn tun ip.
>
>
> id="11"
> ip rule add fwmark $id lookup $id
> ip route add default via 192.168.1.1 table $id
> iptables -t mangle -I OUTPUT 1 -m set --match-set chinaip dst -j MARK
> --set-mark $id
> iptables -t nat -A POSTROUTING -s 10.7.0.2 -o eth0 -j MASQUERADE
>
>
> wireshark show the traffic send to eth0, but the local process can not
> receive data.
>
> 128    5.583482000    192.168.1.118    180.149.134.141    TCP    74
> 33474 > http [SYN] Seq=0 Win=27840 Len=0 MSS=1392 SACK_PERM=1
> TSval=17843425 TSecr=0 WS=128
>
> 129    5.586962000    180.149.134.141    192.168.1.118    TCP    66
> http > 33474 [SYN, ACK] Seq=0 Ack=1 Win=14600 Len=0 MSS=1448
> SACK_PERM=1 WS=128
>
> 249    6.332233000    192.168.1.118    180.149.134.141    TCP    74
> [TCP Retransmission] 33473 > http [SYN] Seq=0 Win=27840 Len=0 MSS=1392
> SACK_PERM=1 TSval=17843613 TSecr=0 WS=128
>
> 250    6.335188000    180.149.134.141    192.168.1.118    TCP    66
> [TCP Retransmission] http > 33473 [SYN, ACK] Seq=0 Ack=1 Win=14600
> Len=0 MSS=1448 SACK_PERM=1 WS=128
>
> There are all TCP Retransmission, Are there something problems?

You probably need to disable rp_filter on eth0.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Split traffic between VPN and local interface
  2016-03-31 12:23 ` Pascal Hambourg
@ 2016-04-01 14:43   ` Perol.Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Perol.Chen @ 2016-04-01 14:43 UTC (permalink / raw)
  To: Pascal Hambourg; +Cc: netfilter

Thanks, it works when I set rp_filter on eth0 0 or 2.

On Thu, Mar 31, 2016 at 8:23 PM, Pascal Hambourg <pascal@plouf.fr.eu.org> wrote:
> Le 31/03/2016 07:32, Perol.Chen a écrit :
>>
>> Dear all:
>>
>> I start one vpn client on my computer, but I want my country's traffic
>> direct from local interface,
>>
>> because the ip list is large, so I save them to ipset named chinaip.
>>
>> I use commands below split the traffic, 192.168.1.1 is local interface
>> gateway, 10.7.0.2 is the vpn tun ip.
>>
>>
>> id="11"
>> ip rule add fwmark $id lookup $id
>> ip route add default via 192.168.1.1 table $id
>> iptables -t mangle -I OUTPUT 1 -m set --match-set chinaip dst -j MARK
>> --set-mark $id
>> iptables -t nat -A POSTROUTING -s 10.7.0.2 -o eth0 -j MASQUERADE
>>
>>
>> wireshark show the traffic send to eth0, but the local process can not
>> receive data.
>>
>> 128    5.583482000    192.168.1.118    180.149.134.141    TCP    74
>> 33474 > http [SYN] Seq=0 Win=27840 Len=0 MSS=1392 SACK_PERM=1
>> TSval=17843425 TSecr=0 WS=128
>>
>> 129    5.586962000    180.149.134.141    192.168.1.118    TCP    66
>> http > 33474 [SYN, ACK] Seq=0 Ack=1 Win=14600 Len=0 MSS=1448
>> SACK_PERM=1 WS=128
>>
>> 249    6.332233000    192.168.1.118    180.149.134.141    TCP    74
>> [TCP Retransmission] 33473 > http [SYN] Seq=0 Win=27840 Len=0 MSS=1392
>> SACK_PERM=1 TSval=17843613 TSecr=0 WS=128
>>
>> 250    6.335188000    180.149.134.141    192.168.1.118    TCP    66
>> [TCP Retransmission] http > 33473 [SYN, ACK] Seq=0 Ack=1 Win=14600
>> Len=0 MSS=1448 SACK_PERM=1 WS=128
>>
>> There are all TCP Retransmission, Are there something problems?
>
>
> You probably need to disable rp_filter on eth0.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-01 14:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-31  5:32 Split traffic between VPN and local interface Perol.Chen
2016-03-31 12:23 ` Pascal Hambourg
2016-04-01 14:43   ` Perol.Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox