use iptables to block ip range

To block 116.10.191.* addresses:

$ sudo iptables -A INPUT -s 116.10.191.0/24 -j DROP

To block 116.10.*.* addresses:

$ sudo iptables -A INPUT -s 116.10.0.0/16 -j DROP

To block 116.*.*.* addresses:

$ sudo iptables -A INPUT -s 116.0.0.0/8 -j DROP

But be careful what you block using this method. You don’t want to prevent legitmate traffic from reaching the host.

edit: as pointed out, iptables evaluates rules in sequential order. Rules higher in the ruleset are applied before rules lower in the ruleset. So if there’s a rule higher in your ruleset that allows said traffic, then appending (iptables -A) the DROP rule will not produce the intended blocking result. In this case, insert (iptables -I) the rule either:

  • as the first rule

sudo iptables -I ...

  • or before the allow rule

sudo iptables --line-numbers -vnL

say that shows rule number 3 allows ssh traffic and you want to block ssh for an ip range. -Itakes an argument of an integer that’s the location in your ruleset you want the new rule to be inserted

iptables -I 2 ...

AliOSS如何避免误删?

  • 利用OSS数据复制和备份管理机制。
    • 利用跨区域复制的写同步(增、改)功能,自动做异地备份。
    • 定期使用OSS API、SDK、工具,将数据备份到OSS另一个Bucket。
  • 使用OSS访问控制权限管理机制,参考权限管理说明
    • 不使用主账号访问OSS。
    • 读写分离,对于只需要读数据的业务,只使用具有读权限的子账号或STS临时凭证。
    • 使用STS的临时凭证来访问OSS。
    • Bucket权限分离,针对不同的业务,只授权“够用且最小的范围”的Bucket、目录、操作权限。
    • 妥善保管数据访问的凭据,如阿里云账号密码、RAM子账号访问凭据。