Skip to content

Instantly share code, notes, and snippets.

@cutaway
Created December 16, 2020 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cutaway/855f47750aa885c3a371ecef730ac667 to your computer and use it in GitHub Desktop.
Save cutaway/855f47750aa885c3a371ecef730ac667 to your computer and use it in GitHub Desktop.
Script to use IPTables to prevent outbound traffic when using network taps and monitoring network traffic.
#!/bin/bash
ipt4='/sbin/iptables'
ipt6='/sbin/ip6tables'
for i in $ipt4 $ipt6; do
# Flush Rules
echo 'Flushing IPTables: ' $i
$i -F
$i -X
# If there is a parameter, then disable outbound
if test $# -gt 0; then
if [[ "$1" == "start" ]]; then
# Block Rules
echo 'Blocking outbound traffic'
$i -A OUTPUT -j DROP
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment