If you want to remove incoming RST packets, you will want to do this:
iptables -I INPUT -p tcp --tcp-flags ALL RST,ACK -j DROP iptables -I INPUT -p tcp --tcp-flags ALL RST -j DROP
If you want to remove outgoing RST packets, you will want to do this:
iptables -I OUTPUT -p tcp --tcp-flags ALL RST,ACK -j DROP
Why RST ACK? According to the RFC, any response to a TCP packet containing a SYN must ACK to the sequence number. Therefore, even if you indicate that your port is closed, you are responding with an RST ACK.
Why worry about outgoing RST? If you are trying to use a tool like Scapy to experiment with IP behavior, you will often need to prevent the host IP stack from sending RST ACKs. Alternatively, you can implement the pseudo-source in Scapy, requiring a MAC, responding to ARP or ICMP ND for IPv6, and bind your own IP address, which will also prevent the host from reacting. Obviously, this is more than just blocking outgoing RST packets.
source share