I have a small program that creates a raw socket and sends a packet over the socket. This is what the program looks like (or its usage):
Code: Select all
$> ./tcp4 lo 127.0.0.214 127.0.0.194
- create a raw socket and bind the socket to the interface "lo" (loopback);
- compose a TCP packet with src ip 127.0.0.214 and dst ip 127.0.0.194;
- sends the TCP packet to 127.0.0.194
Since the packet is a TCP SYN with a dst port which is not opened in my computer, the OS will respond an RST/ACK packet. Now it is the response packet that confuses me. When I ran the same program respectively on Ubuntu 14.04 and Centos 6.4, I observed that, in the RST/ACK packet,
1) On Ubuntu 14.04, the src ip and the dst ip are 127.0.0.194 and 127.0.0.214 respectively, as shown in figure 1.
2) On CentoS 6.4, the src ip and the dst ip are both 127.0.0.194, as shown in figure 2. It seems the OS didn't use as the dst ip the SYN packet's src ip, which is sent by my program.
Is it possible to make CentoS behave like Ubuntu 14.04? I mean, I want CeontOS to use the SYN packet's src ip as the RST/ACK packet's dst ip, and not ot modify it.