Mangle
Mangle
Chains
PREROUTING
Engaged for incoming packets before any routing decision is made, suitable for DNAT.
POSTROUTING
Activated for outgoing packets after all routing decisions have been made, ideal for SNAT and masquerading.
OUTPUT
Applied to locally generated packets before they are sent out, allowing for DNAT on outgoing traffic.
Examples by Action
Custom TTL
Windows 128
Cisco 255
Linux 64
Increase TTL to prevent packets from expiring prematurely:
Decrease TTL to restrict packet reach to a specific network segment:
This rule sets the TTL of outgoing packets destined for the 192.168.2.0/24 network to 32, limiting their reach to that segment.
Marking packets for differentiated treatment
Mark packets based on source IP for specific routing:
Mark packets based on destination port for specific firewall rules:
This marks packets targeting port 80 with 0x20 for applying specific firewall rules later.
Modifying packet flags
Disable timestamps on outgoing packets for performance optimization:
Enable IP options for specific applications:
This sets the Type of Service (TOS) field for HTTPS traffic (port 443) to 0x10, potentially enabling specific options needed by the application.
Changing the DSCP Field of Outgoing Packets
Differentiated Services Code Point (DSCP) can be used for quality of service (QoS) purposes.
This rule sets the DSCP field for outgoing HTTP traffic to prioritize it within the network.
Last updated
Was this helpful?