Skip to content

Instantly share code, notes, and snippets.

View risin42's full-sized avatar
😇

risin42

😇
  • Tokyo
  • 17:00 (UTC +09:00)
View GitHub Profile
@ushitora-anqou
ushitora-anqou / ban.sh
Last active October 31, 2022 04:49
GCPのファイアウォールに中国とオーストラリアからの上り通信を弾く設定を追加するシェルスクリプト
#!/bin/bash
#
# Shell script to add GCP's firewall to deny all ingress from China and Australia.
# Author: Ushitora Anqou
# License: MIT
#
curl https://ipv4.fetus.jp/cn.txt | grep -vE '#|^$' > cn.txt
curl https://ipv4.fetus.jp/au.txt | grep -vE '#|^$' > au.txt
for i in $(seq 1 250 $(wc -l cn.txt | cut -d' ' -f1)); do sed -n "$i,$((249 + i))p" cn.txt > cn-$(echo $i | awk '{printf "%02d", ($1-1)/250}'); done
for i in $(seq 1 250 $(wc -l au.txt | cut -d' ' -f1)); do sed -n "$i,$((249 + i))p" au.txt > au-$(echo $i | awk '{printf "%02d", ($1-1)/250}'); done