Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 4, 2020 13:12
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 peter279k/a148d7bbc0c262f7efa4e29d6943f9b2 to your computer and use it in GitHub Desktop.
Save peter279k/a148d7bbc0c262f7efa4e29d6943f9b2 to your computer and use it in GitHub Desktop.
Disable ping
# Referenced by: https://linuxconfig.org/how-to-deny-icmp-ping-requests-on-ubuntu-18-04-bionic-beaver-linux
which ufw 2>&1 > /dev/null
if [[ $? != 0 ]]; then
echo 'Please install ufw package'
exit 1;
fi;
sudo_prefix=''
echo 'Check whether the user should add sudo prefix...'
if [[ $USER != 'root' ]]; then
sudo_prefix='sudo'
fi;
${sudo_prefix} sed -i '/ufw-before-input.*icmp/s/ACCEPT/DROP/g' /etc/ufw/before.rules
${sudo_prefix} ufw enable
${sudo_prefix} ufw reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment