本指南涵盖 MikroTik 路由器的基础安全配置建议,适用于 RouterOS。请根据实际网络需求合理取舍。
1. 用户管理
新建管理员用户
创建一个新的全权限用户并使用强密码:
/user add name=YOUR_ADMIN_USER password=YOUR_STRONG_PASSWORD group=full
建议用户名不要使用 admin,并使用高强度密码。
禁用默认 admin 用户
禁用内置 admin 用户可减少暴力破解风险:
/user disable admin
2. 关闭不必要的服务
禁用默认开启的管理服务
以下命令关闭 API、FTP、SSH、Telnet、HTTP 等不常用或高风险服务:
/ip service disable api,api-ssl,ftp,ssh,telnet,www
如果保留 winbox 管理入口,建议修改默认端口。
修改 WinBox 管理端口
避免使用默认端口 8291:
/ip service set winbox port=YOUR_WINBOX_PORT
3. 关闭 MAC 层服务
这些服务常被用于同一网段管理,但也容易被扫描。
禁用 MAC Telnet
/tool mac-server set allowed-interface-list=none
禁用 MAC WinBox
/tool mac-server mac-winbox set allowed-interface-list=none
禁用 MAC Ping
/tool mac-server ping set enabled=no
4. 邻居发现协议设置
禁用 IPv4 邻居发现协议
/ip neighbor discovery-settings set discover-interface-list=none
禁用 IPv6 邻居发现协议
/ipv6 nd set [find] disabled=yes
5. 禁用默认服务和代理
禁用带宽服务器
用于测试吞吐的服务,建议测试后关闭:
/tool bandwidth-server set enabled=no
禁用 UPnP
UPnP 会自动开放端口,易被滥用:
/ip upnp set enabled=no
禁用 VPN 服务
如果未部署 VPN 功能,可关闭所有相关服务:
/interface l2tp-server server set enabled=no
/interface pptp-server server set enabled=no
/interface sstp-server server set enabled=no
/interface ovpn-server server set enabled=no
启用 NTP 时间同步
确保设备时间准确:
/system/ntp/client set enabled=yes servers=ntp.ntsc.ac.cn,cn.ntp.org.cn,time.pool.aliyun.com,cn.pool.ntp.org
禁用代理和 Socks 服务
/ip proxy set enabled=no
/ip socks set enabled=no
6. 防火墙配置
建议结合实际接口名称设置 in-interface=LAN 或使用 interface list。
阻止高危端口访问
防止外部访问常见攻击端口:
/ip firewall filter add chain=input protocol=tcp dst-port=20,21,22,23,135,137,138,139,445,3389 action=drop comment="Block High Risk TCP"
/ip firewall filter add chain=input protocol=udp dst-port=20,21,22,23,135,137,138,139,445,3389 action=drop comment="Block High Risk UDP"
禁止公网 DNS 查询
阻止非内网访问 DNS 服务:
/ip firewall filter add chain=input protocol=udp dst-port=53 in-interface=!LAN action=drop comment="Block external DNS"
禁止外网 Ping
/ip firewall filter add chain=input protocol=icmp in-interface=!LAN action=drop comment="Block external ICMP"
丢弃无效连接包
输入链丢弃:
/ip firewall filter add chain=input connection-state=invalid action=drop comment="Drop invalid input"
转发链丢弃:
/ip firewall filter add chain=forward connection-state=invalid action=drop comment="Drop invalid forward"
7. 关闭 IPv6 功能
如果网络不启用 IPv6,可以关闭:
/ipv6/settings/set disable-ipv6=yes forward=no accept-redirects=no accept-router-advertisements=no
如果使用 IPv6,请保留并配置对应地址段、路由和防火墙规则。
总结建议
- 启用
/system logging,观察是否有未经授权的访问行为。 - 所有接口建议配置
interface list并用于服务允许条件。 - 定期升级 RouterOS 到稳定版本。