Skip to content

Instantly share code, notes, and snippets.

@yunginnanet
Last active September 22, 2023 21:04
Show Gist options
  • Save yunginnanet/909c4870beb39123460010f1def29dcf to your computer and use it in GitHub Desktop.
Save yunginnanet/909c4870beb39123460010f1def29dcf to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
_IF=$1
# note that if you have different masks i'm bad at bash and this is only removing '/24' atm
/bin/ip --brief a | grep "$_IF" | sed 's|/24||g' | awk -F 'P' '{print $NF}' | sed 's| |\n|g' | grep \. | sort | while read line; do
echo -e "-A INPUT -i $_IF -s $line -j LOG --log-prefix '[$line SPOOF DROP] '\n-A INPUT -i $_IF -s $line -j DROP";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment