systemctl ipblock
This commit is contained in:
@@ -9,9 +9,6 @@ SOURCES=(
|
||||
"https://raw.githubusercontent.com/mayaxcn/china-ip-list/master/chnroute.txt"
|
||||
)
|
||||
|
||||
echo "[*] Killing Steam..."
|
||||
pkill -9 -f steam || true
|
||||
|
||||
echo "[*] Downloading CN IP ranges..."
|
||||
for url in "${SOURCES[@]}"; do
|
||||
echo " Trying $url ..."
|
||||
@@ -46,8 +43,8 @@ iptables -t raw -A OUTPUT -m set --match-set "$IPSET_NAME" dst -j DROP
|
||||
|
||||
CIDR6_FILE="/tmp/cn6.cidr"
|
||||
SOURCES6=(
|
||||
"https://raw.githubusercontent.com/herrbischoff/country-ip-blocks/master/ipv6/cn.cidr"
|
||||
"https://www.ipdeny.com/ipv6/ipaddresses/blocks/cn.cidr"
|
||||
"https://raw.githubusercontent.com/gaoyifan/china-operator-ip/ip-lists/china6.txt"
|
||||
"https://raw.githubusercontent.com/ipverse/rir-ip/master/country/cn/ipv6-aggregated.txt"
|
||||
)
|
||||
|
||||
echo "[*] Downloading CN IPv6 ranges..."
|
||||
|
||||
18
iptables/install.sh
Normal file → Executable file
18
iptables/install.sh
Normal file → Executable file
@@ -1,10 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
install_() {
|
||||
install -m 755 china-block.sh /usr/local/sbin/china-block.sh
|
||||
install -m 755 china-unblock.sh /usr/local/sbin/china-unblock.sh
|
||||
install -m 644 china-block.service /etc/systemd/system/china-block.service
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now china-block
|
||||
echo "[+] china-block service installed and started."
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
systemctl disable --now china-block 2>/dev/null || true
|
||||
rm -f /usr/local/sbin/china-block.sh
|
||||
rm -f /usr/local/sbin/china-unblock.sh
|
||||
rm -f /etc/systemd/system/china-block.service
|
||||
systemctl daemon-reload
|
||||
echo "[+] china-block service removed."
|
||||
}
|
||||
|
||||
case "${1:-install}" in
|
||||
install) install_ ;;
|
||||
uninstall) uninstall ;;
|
||||
*) echo "Usage: $0 [install|uninstall]"; exit 1 ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user