Skip to content

Instantly share code, notes, and snippets.

@escalopa
Last active May 9, 2024 16:28
Show Gist options
  • Save escalopa/84f444df290d0e276362d8d22a9182ec to your computer and use it in GitHub Desktop.
Save escalopa/84f444df290d0e276362d8d22a9182ec to your computer and use it in GitHub Desktop.
Iptables simple explanation with exapmles

iptables practice

Check iptables rules

iptables -t {mangle|filter|nat} -L

You can also add the --line-number option to print rules numbers

Delete a rule

iptables -t {mangle|filter|nat} -D CHAIN RULE_NUMBER

Notice that to get the row number you can ues the first command in this gist

Block an incoming packet (icmp)

iptables -t filter -I INPUT -p icmp --icmp-type echo-request -j REJECT

Notice that REJECT returns error, you can use DROP to totally not respond on the request

Block an outcoming packet (icmp)

iptables -t filter -I OUTPUT -p icmp --icmp-type echo-request -j REJECT

Manipulating packet getting out of your system

iptables -t mangle -I POSTROUTING -j TTL --ttl-set 100
@NajiAli3010
Copy link

Good work my bro

@escalopa
Copy link
Author

Thx man really appreciate it

@LuisRamirezv
Copy link

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment