LinuxQuestions.org
Visit Jeremy's Blog.
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 08-12-2010, 10:09 AM   #1
sseeley
LQ Newbie
 
Registered: Aug 2010
Posts: 4

Rep: Reputation: 0
iptables bad tcp cksum for DNAT OUTPUT


Hi:

I've searched for this topic and found some similar stuff but not exactly, so here goes (sorry if I could not find it). I am trying to use DNAT for some seemingly unorthodox usage. I am *not* trying to setup a firewall. I am not a network admin. I am trying to setup a scenario for internal development. I am completely internal to my local network and I have 3 standard end-hosts to play with, which we can call;

client
server
3rd_host

I have a standard TCP client / server scenario in which I would like to create some asymmetric routes.. i.e traffic from client to server is on one network interface and traffic from server back to client on on another network interface. The client is multi-homed with the following:

eth0: 100.21.13.05/21 <--- I want server packets to arrive here
tun0: 192.168.13.05/21 <--- I want client packets to be sent here

Client connection requests are sent to server port@host equal to 5001@100.21.13.13

iptables is configured like this:

sudo /sbin/iptables -t nat -A OUTPUT -p tcp -d 100.21.13.13 --dport 5001 -j DNAT --to-destination 192.168.13.13

** As an aside. The above works fine if server is reachable on tun0 and I want all incoming and outgoing packets to use tun0 interface... ***

Packets sent out tun0 now has Source IP = 192.168.13.05 and Dest IP = 192.168.13.13. Very Nice.. Now lets suppose that tun0 interface is really destined to 3rd_host in which 3rd_host is ip_forwarding. So 3rd_host is also muti-homed:

tun0: 192.168.13.89/21 <--- client packets arrive here
eth0: 100.21.13.89/21 <--- client packets are sent here (after DNAT)

On 3rd_host I have the following commands:

sudo /sbin/iptables -i tun0 -A PREROUTING -t nat -j DNAT --to-destination 100.21.13.13
sudo /sbin/iptables -d 100.21.13.13 -p tcp -A POSTROUTING -t nat -j SNAT --to-source 100.21.13.05

So now in a sense, 3rd_host has effectively undone the NAT translation that client performed.. tcpdump on eth0 shows Source IP = 100.21.13.05 and Dest IP = 100.21.13.13. The server in single homed:

eth0: 100.21.13.13/21

And Source and Dest IP are the expected 100.21.13.05 and 100.21.13.13 respectively..

Now for the problem: The TCP 3-way handshake is completed successfully (SYN from client, SYN-ACK from server, ACK from client all ok), however the first user level packet from client (first packet after client ACK) has a "bad tcp cksum". There is more.. I watch the tcpdump on the client eth0 and tun0 interfaces.. Only the very first SYN packet from the client is sent to the tun0 and everything else sent by the client appears on the eth0 interface. This is very unexpected by me. This is the root of my question and problem.. Why is SYN packet the only packet to be sent on tun0? I read that iptables nat table only "evaluates" the first packet in a "stream" and then all packets in teh same "stream" follow it's lead. And, why is a bad tcp cksum error created on first real user data packet. I suppose the latter question has something to do with the former.

I think this might have to do with the definition of a stream possibly.. What is a stream? This must be the Kernel's notion of a tcp connection defined by port@host pairs. Looking at open file descriptors on client I can see that my socket is still defined as the original 100.21.x.x address pairs, so I don't know why subsequent packets are not matching the DNAT rule..

Any help, please..

Thanks in Advance
 
Old 08-20-2010, 09:26 AM   #2
sseeley
LQ Newbie
 
Registered: Aug 2010
Posts: 4

Original Poster
Rep: Reputation: 0
iptables conntrack shows why this problem occurs..

conntrack expects SYN-ACK to be the IP on the tun which it is not.. When the SYN-ACK arrives on eth0 with real network IP, there is no match and the state does not move from NEW to ESTABLISHED.

Still no resolution..

I still wonder if there is an easy solution. I posted a new approach and new problem:
http://www.linuxquestions.org/questi...packet-827306/
 
  


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
Iptables and DNAT _TeRmInEt_ Linux - Networking 9 11-24-2009 05:56 PM
bad cksum in tcpdump v_fone Linux - Networking 7 06-15-2009 02:16 PM
IPTables trouble with DNAT target (bad argument error) Eightpock Linux - Software 9 06-16-2008 10:36 AM
-A PREROUTING -i eth2 -p tcp --dport 80 -j DNAT --to-destination 10.1.1.200:80 GSMD Linux - Networking 5 05-04-2007 09:26 AM
iptables DNAT bentz Linux - Networking 15 05-19-2003 01:17 PM

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

All times are GMT -5. The time now is 03:19 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