LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2023, 07:10 AM   #1
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Rep: Reputation: 13
am i abusing conntrackd?


Hello,
I'm trying to do a connection with a dnat, but in case the answer packets come back via a a different server, I want it to work too.

interfaces Server 1: 192.168.0.1/24 and 10.0.0.1/24
interfaces Server 2: 192.168.0.2/24 and 10.0.0.2/24
Each one doing a DNAT to 10.0.0.100 (destination)
Source 192.168.0.10 is trying to connect to either 192.168.0.1 or .2, shouldn't matter.
Destination is routing back to either 10.0.0.1 or 10.0.0.2, shouldn't matter either.

e.g
192.168.0.10 (Source) connects to 192.168.0.1 (Server 1)
that will be forwarded to 10.0.0.100 (destination)
which routes the answer-packets back to 10.0.0.2 (Server 2),
that should undo the DNAT, like Server 1 would,
and send back to 192.168.0.10 (Source)

If the destination routes the answers back to the same router, which did the dnat, it works (of course).
If the destination routes back to the other one, that one doesn't have the conntrack entry to undo the dnat.

So I thought I could use conntrackd to exchange the conntrack entries.
It seems to work as far as when I connect to Server 1, Server 2 has its conntrack updated and vice versa.

But when I connect via Server 1 and the reply is routed via Server 2 the connection doesn't work.

On the destination I can see
SYN from 192.168.0.10 to 10.0.0.100 (as expected)
SYN ACK from 10.0.0.100 to 192.168.0.10 (as expected)

on Server 2 I can see
SYN ACK from 192.168.0.1 to 192.168.0.10 (so it seems to work, dnat is reversed, packets go back to source)

on Source I can see
SYN from 192.168.0.10 to 192.168.0.1 (as expected)
another
SYN from 192.168.0.10 to 192.168.0.1 (shouldn't matter afaik)
SYN ACK from 192.168.0.1 to 192.168.0.10 (IP Server 1 but mac Server 2, is what I wanted)
ACK from 192.168.0.10 to 192.168.0.1 (expected that too)
RST from 192.168.0.1 (Server 1 mac Server 1)

I think maybe the conntrack entries aren't updated fast enough so Server 1 doesn't know about the SYN ACK yet, because that went via Server 2?

Or maybe there's something else I'm missing?
 
Old 08-24-2023, 06:52 AM   #2
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Original Poster
Rep: Reputation: 13
I've found out the following:
It seems that the DNAT I'm using is only applied to the SYN on router1, the SYN ACK goes back via router2, DNAT is reversed, because conntrackd exchanged the information from router1 to router2.
So far so good.

But the ACK via router1 isn't DNATted any more, even though router1 knows about the SYN ACK that went via router2.

I thought I might circumvent that problem by using mangle and changing the destination IP-address of every packet, even those that are not SYNs, but that doesn't seem to be possible.

If I use UDP it works perfectly btw.

Is there any way I can get the packets that are not SYNs to use the DNAT?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
conntrackd sync connection but ctstate is INVALID sdmitriy Linux - Networking 0 06-30-2018 04:55 PM
Conntrackd won't synchronize between routers. horizn Linux - Networking 3 05-18-2016 07:55 AM
conntrackd is not work. invalid argument error. sodoojin Linux - Newbie 0 10-31-2008 12:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration