Last active
June 3, 2019 14:28
-
-
Save ericpulvino/bc741227efe4a8b3bdd229e4f4fef40b to your computer and use it in GitHub Desktop.
Quick Script to Emulate Basic DHCP Trusted Ports / DHCP Snooping / DHCP Filtration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Root Check | |
if [ $(whoami) != 'root' ]; then | |
echo "ERROR: Must be root to run $0" | |
exit 1; | |
fi | |
TRUSTED_PORTS=( swp1 swp3 ) | |
SNOOPFILE=/etc/cumulus/acl/policy.d/90dhcp_snooping.rules | |
echo "###########################" | |
echo " Writing new DHCP Rules to: $SNOOPFILE" | |
echo "###########################" | |
echo "[iptables]" > $SNOOPFILE | |
for port in "${TRUSTED_PORTS[@]}"; do | |
echo "-A FORWARD -i $port -p udp -m udp --sport 67 -j ACCEPT" >> $SNOOPFILE | |
done | |
echo "-A FORWARD -i swp+ -p udp -m udp --sport 67 -j DROP" >> $SNOOPFILE | |
echo " done." | |
echo "###########################" | |
echo " Applying New DHCP Rules..." | |
echo "###########################" | |
cl-acltool -i | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment