Skip to content

Instantly share code, notes, and snippets.

@wesleyit
Created August 31, 2018 21:38
Show Gist options
  • Select an option

  • Save wesleyit/33441732270de3d201317296759d1323 to your computer and use it in GitHub Desktop.

Select an option

Save wesleyit/33441732270de3d201317296759d1323 to your computer and use it in GitHub Desktop.
Control/Block the internet access of specific programs and commands
#!/bin/bash
# Com este script você cria uma forma de executar comandos
# que não terão acesso à rede externa e Internet.
# Por exemplo, se você quiser forçar o Spotify a fica offline:
# offline spotify.bin
sudo groupadd offline
echo '#!/bin/bash' | sudo tee /usr/local/bin/offline
echo 'sg offline "$*"' | sudo tee -a /usr/local/bin/offline
sudo chmod a+x /usr/local/bin/offline
echo '#!/bin/bash' | sudo tee /etc/network/if-pre-up.d/iptables_offline_rule
echo 'iptables -A OUTPUT -m owner --gid-owner offline -j DROP' | sudo tee -a /etc/network/if-pre-up.d/iptables_offline_rule
sudo chmod +x /etc/network/if-pre-up.d/iptables_offline_rule
sudo /etc/network/if-pre-up.d/iptables_offline_rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment