Ell[ca] | Él[es] | He/Him[en]

  • 0 Posts
  • 4 Comments
Joined 3 years ago
cake
Cake day: June 25th, 2023

help-circle

  • You can use iptables to block connections, by example, using ufw the uncomplicated firewall:

    # apt install ufw bind9-dnsutils  #  Install ufw and nslookup
    # uIPs=$((nslookup reddit.com && \
      nslookup www.reddit.com && \
      nslookup redd.it && \
      nslookup redditstatic.com && \
      nslookup www.redditstatic.com) \
      | awk '/^Address: / { print $2 }' | sort -u); \
    for uip in ${uIPs}; do \
      echo -n "${uip} " &&  \
      ufw deny from "${uip}" comment 'deny reddit.com'; \
      ufw deny out to "${uip}" from any comment 'deny reddit.com'; \
    done;
    # ufw enable
    # ufw status numbered
    

  • You can also use a firewall to deny/reject outgoing and incoming traffic to those IPs. By example, with ufw:

    # apt install ufw bind9-dnsutils  # install Uncomplicated Firewall and dig
    # ufw enable  # activate the firewall
    # dig +short reddit.com  # get reddit A IPs
    151.101.65.140
    151.101.1.140
    151.101.193.140
    151.101.129.140
    # ufw deny in on all from 151.101.65.140 comment 'deny in connections to reddit'
    # ufw deny out on all to 151.101.65.140 comment 'deny out connections to reddit'
    . . . 
    

    Or in only one line:

    uIPs=$(dig +short reddit.com); for uip in "${uIPs}"; do echo "$uip"; done;