Linux Netfilter discussions
 help / color / mirror / Atom feed
* Change source or destination for packets arriving locally (for Direct Server Return)
@ 2017-09-12  6:00 Thomas Rosenstein
  2017-09-13  9:34 ` Arturo Borrero Gonzalez
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Rosenstein @ 2017-09-12  6:00 UTC (permalink / raw)
  To: netfilter

Hello,

I'm trying to setup L3 load balancing (with direct server return) which 
requires me to send back or receive packets with a certain src/dst 
address,
but for these packets the dst address is replaced on the load balancer, 
then routed and are arriving on my linux container.

I tried with mangle, filter, nat tables and ip route, tc etc. and it 
seems nothing works as expected.

I tried to match via ip rule tos 0xc (2 additional bits) but that never 
matches, and ip rule doesn't allow arbitrary values
I tried to mark the packets in iptables mangle, and apply the ip rule on 
the fwmark, also never matches
I tried to match the fwmark with tc and use the nat action, also never 
matches (counters stay 0)
I tried to use PREROUTING with DNAT, but the packet is never there 
(packet to the local system)
The IP 10.253.1.18 is configured locally on eth0
The IP 10.253.253.163 is configured locally on eth0
The GW is 10.253.1.1
The IP 10.21.13.19 is in a completly different network segment

I'd like to do the following:

Incoming Packet: DSCP 0x3 Src: 10.21.13.19 Dst 10.253.1.18 SrcPort: 
45240 DstPort: 53

Match this packet based on DSCP = 0x3

Rewrite this Packet before it hits anything to:

DSCP: 0x0 Src: 10.21.13.19 Dst: 10.253.253.163 SrcPort: 45240 DstPort: 
53

Expected outcome:

The kernel sees this packet, and established the connection, all return 
traffic packets should look like this:

DSCP: 0x0 Src: 10.253.253.163 Dst 10.21.13.19 SrcPort: 53 DstPort: 45240

I do not want NAT (e.g. connection tracking, and reversing of the DNAT) 
- best would be a single rule that does this.
It looks like it can be done: 
https://www.slideshare.net/jschauma/l3dsr-overcoming-layer-2-limitations-of-direct-server-return-load-balancing

an illustration would be this: 
https://www.draw.io/?lightbox=1&highlight=0000ff&edit=_blank&layers=1&nav=1&title=Masq-Async-Routing.xml#R7Zxbc5s4FMc%2FjR%2BXQTcMj7m03Z3p7mQmndnmKSODbLPBiAElcfr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HDsdMXr4hdLCbSHab6Mdwbi%2BMtLr%2BMEdj8upzo9Sc2W7H%2FxihAzGHWdeq85E3o3EQyQqSh2LNitf071i5T2YiwHoJE5pzFsQzlbSbzT9SSvJ0%2F%2Fs55Qz9%2FjeK0Jf%2FAQ%3D%3D

It's just missing the DSCP part.

BR
Thomas Rosenstein

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

end of thread, other threads:[~2017-09-13 14:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12  6:00 Change source or destination for packets arriving locally (for Direct Server Return) Thomas Rosenstein
2017-09-13  9:34 ` Arturo Borrero Gonzalez
2017-09-13  9:36   ` Thomas Rosenstein
2017-09-13 10:10     ` Pablo Neira Ayuso
2017-09-13 13:23   ` Thomas Rosenstein
2017-09-13 13:34     ` Arturo Borrero Gonzalez
2017-09-13 14:14       ` Thomas Rosenstein
2017-09-13 14:32         ` Arturo Borrero Gonzalez
2017-09-13 14:36           ` Thomas Rosenstein
2017-09-13 14:40           ` Thomas Rosenstein

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