Skip to content

Instantly share code, notes, and snippets.

@vimagick
Created July 4, 2023 03:27
Show Gist options
  • Save vimagick/2ea71ca08dc7787ac5060043c27c3b79 to your computer and use it in GitHub Desktop.
Save vimagick/2ea71ca08dc7787ac5060043c27c3b79 to your computer and use it in GitHub Desktop.
#!/bin/bash
ufw status | awk '/telegram/ && /DENY FWD/{print $1}' | xargs -rt -n1 -I{} ufw route delete deny to {}
ufw status | awk '/telegram/ && /DENY OUT/{print $1}' | xargs -rt -n1 -I{} ufw rule delete deny out to {}
curl -s https://core.telegram.org/resources/cidr.txt | grep -v :: | xargs -rt -n1 -I{} ufw route insert 1 deny to {} comment telegram
curl -s https://core.telegram.org/resources/cidr.txt | grep -v :: | xargs -rt -n1 -I{} ufw rule insert 1 deny out to {} comment telegram
@vimagick
Copy link
Author

vimagick commented Jul 4, 2023

$ ./ufw-block-telegram.sh

$ ufw status

185.76.151.0/24            DENY OUT    Anywhere                   # telegram
91.108.20.0/22             DENY OUT    Anywhere                   # telegram
91.105.192.0/23            DENY OUT    Anywhere                   # telegram
149.154.160.0/20           DENY OUT    Anywhere                   # telegram
91.108.12.0/22             DENY OUT    Anywhere                   # telegram
91.108.16.0/22             DENY OUT    Anywhere                   # telegram
91.108.8.0/22              DENY OUT    Anywhere                   # telegram
91.108.4.0/22              DENY OUT    Anywhere                   # telegram
91.108.56.0/22             DENY OUT    Anywhere                   # telegram

185.76.151.0/24            DENY FWD    Anywhere                   # telegram
91.108.20.0/22             DENY FWD    Anywhere                   # telegram
91.105.192.0/23            DENY FWD    Anywhere                   # telegram
149.154.160.0/20           DENY FWD    Anywhere                   # telegram
91.108.12.0/22             DENY FWD    Anywhere                   # telegram
91.108.16.0/22             DENY FWD    Anywhere                   # telegram
91.108.8.0/22              DENY FWD    Anywhere                   # telegram
91.108.4.0/22              DENY FWD    Anywhere                   # telegram
91.108.56.0/22             DENY FWD    Anywhere                   # telegram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment