summaryrefslogtreecommitdiff
path: root/functions/disable_ip.sh
blob: 0021b744e9810f642cbe1b2a451e82876a3ab0c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
disable_ip() {
  local ip="$1"

  if [[ -z "$ip" ]]; then
    echo "[!] No IP specified."
    exit 1
  fi

  echo "[*] Disabling access to VPS with IP: $ip"

  # Block all traffic to/from that IP via iptables
  iptables -A INPUT -s "$ip" -j DROP
  iptables -A OUTPUT -d "$ip" -j DROP

  echo "$ip - disabled on $(date)" >> /var/log/genesis-disabled.log

  echo "[✓] $ip has been blocked and logged."
}