虽然说是一键,但其实需要运行这个脚本然后复制粘贴到terminal才可以用
#!/bin/sh
cd /tmp
wget https://www.cloudflare.com/ips-v4 -O ips-v4-$$.tmp
wget https://www.cloudflare.com/ips-v6 -O ips-v6-$$.tmp
for cfip in `cat ips-v4-$$.tmp`; do echo "sudo ufw allow from $cfip to any port 443"; done
for cfip in `cat ips-v6-$$.tmp`; do echo "sudo ufw allow from $cfip to any port 443"; done
由于我的服务器只开放443端口,并没有开放80端口,所以这里只添加443到白名单。当然如果想要添加80端口的话,改两个数就可以了。
Source: