TCP Forwarding Calculation

I have a redirect. I am trying to change the port on packets as I see them. When I do this - do I need to recount the TCP checksum and the IP checksum?

I try to do this, but I see reset packets in tcpdump. I do not know if this is because I am calculating the tcp checksum incorrectly or if something else is happening.

I used cksum methods from this site:

http://www.enderunix.org/docs/en/rawipspoof/

I thought using divert socket, if I changed something, it should be pretty simple, but it doesn't seem to be that way. is there a TCP checksum calculator that I can use to verify that I am getting the correct value?

+4
source share
2 answers

You need to recalculate the checksum. The calculation is described below: TCP / IP checksum calculation

0
source

See section 3.3 of RFC 1631 for adjustments to the checksum that NAT / PAT must perform. You do not need to go through the whole packet, you just need to set up a checksum based on the bytes you changed.

0
source

Source: https://habr.com/ru/post/1443753/


All Articles