月度归档:2024年01月

RouterOS 导入 USTC IP 黑名单

将 中科大 USTC IP Blacklist 转换成 RouterOS 格式并导入。

黑名单列表介绍:
https://blackip.ustc.edu.cn/

使用方法:
访问 https://vsean.net/routeros/black_ip.php 下载脚本并导入即可。

导入脚本时会先清空同名列表里的现有列表项。如有自定义需求建议建立多个地址列表。
默认 address-list 的列表名为 black_ip

如需自定义列表名,只需要在 url 后面跟上 ?list_name=[your list name]
例如: https://vsean.net/routeros/black_ip.php?list_name=Block

也可以使用脚本的方式自动导入:

# 黑名单列表名称
:local listName "Block";
:local url ("https://vsean.net/routeros/black_ip.php?list_name=" . $listName);
/tool fetch url=$url mode=https output=file dst-path="black_ip.rsc";
import file=black_ip.rsc

示例防火墙脚本

/ip firewall filter
add action=reject chain=input comment="reject blocked" connection-state=new reject-with=icmp-network-unreachable \
    src-address-list=black_ip
add action=reject chain=forward comment="reject blocked" connection-state=new reject-with=icmp-network-unreachable \
    src-address-list=black_ip

/ipv6 firewall filter
add action=reject chain=input comment="reject blocked" connection-state=new reject-with=icmp-address-unreachable \
    src-address-list=black_ip
add action=reject chain=forward comment="reject blocked" connection-state=new reject-with=icmp-address-unreachable \
    src-address-list=black_ip