RouterOS 安装完成后的通用基础配置命令

通用基础配置

功能 状态
PPPoE 拨号 :white_check_mark:
LAN DHCP 分配 :white_check_mark:
上网 NAT :white_check_mark:
防火墙保护 :white_check_mark:
udpxy IPTV :white_check_mark: 只要旁路由 IGMP 请求发出
OpenWrt 可用 :white_check_mark: 作为旁路由接 IPTV

一、系统基础设置

设置系统标识

/system identity set name=MyRouter

设置管理员密码(请更改为你自己的密码)

/user set admin password=你的安全密码

设置时区 & SNTP 同步

/system clock
set time-zone-name=Asia/Shanghai

执行后可以查看
/system clock print

启用 NTP 客户端
/system ntp client
set enabled=yes
设置 NTP 服务器(推荐国内)
/system ntp client servers
add address=ntp.aliyun.com
add address=ntp.tencent.com
add address=cn.pool.ntp.org
查看同步状态
/system ntp client print
关键字段:
enabled: yes
status: synchronized
如果看到:status: synchronized  ,说明时间已经对准了。


可以把 RouterOS 作为 NTP 服务器
启用 NTP Server
/system ntp server
set enabled=yes
允许内网访问(防火墙)
/ip firewall filter
add chain=input protocol=udp dst-port=123 src-address=10.0.0.0/8 action=accept comment="NTP Server"

二、重命名 + 桥接 + LAN 设置(LAN)

---------- 接口重命名 ----------

/interface ethernet
set [find default-name=ether1] name=ETH0
set [find default-name=ether2] name=ETH1
set [find default-name=ether3] name=ETH2
set [find default-name=ether4] name=ETH3
set [find default-name=ether5] name=ETH4
set [find default-name=ether6] name=ETH5

假设 ETH5 接光猫用于 PPPoE 拨号。

---------- 创建桥接接口 ----------

/interface bridge
add name=bridge1 comment="LAN Bridge"

---------- 添加 LAN 口进桥接 ----------

/interface bridge port
add interface=ETH0 bridge=bridge1
add interface=ETH1 bridge=bridge1
add interface=ETH2 bridge=bridge1
add interface=ETH3 bridge=bridge1
add interface=ETH4 bridge=bridge1

保留 ETH5 给光猫拨号,不加入桥。

---------- 给桥接接口分配 IP ----------

/ip address add address=10.10.10.1/24 interface=bridge1

三、PPPoE 拨号设置(WAN)

创建 PPPoE 客户端(假设 ether5 直连光猫)

/interface pppoe-client
add name=pppoe-out1 interface=ether5 user=你的拨号账号 password=你的拨号密码 add-default-route=yes use-peer-dns=yes disabled=no

四、NAT(源地址伪装)

/ip firewall nat
add chain=srcnat out-interface=pppoe-out1 action=masquerade comment="NAT:LAN 出口伪装"

五、防火墙基础规则

允许已建立、相关连接

/ip firewall filter
add chain=input connection-state=established,related action=accept comment="允许已建立连接"
add chain=forward connection-state=established,related action=accept comment="转发:已建立连接"

拒绝无效连接

add chain=input connection-state=invalid action=drop comment="拒绝无效连接"
add chain=forward connection-state=invalid action=drop comment="转发:拒绝无效连接"

允许 LAN 访问路由器

add chain=input in-interface=bridge1 action=accept comment="允许 LAN 访问路由器"

拒绝 WAN 访问路由器

add chain=input in-interface=pppoe-out1 action=drop comment="拒绝 WAN 登录"

允许 LAN → WAN 上网

add chain=forward in-interface=bridge1 out-interface=pppoe-out1 action=accept comment="允许 LAN 上网"

拒绝 WAN → LAN

add chain=forward in-interface=pppoe-out1 out-interface=bridge1 action=drop comment="拒绝外网访问内网"

六、IGMP Proxy(给 IPTV/udpxy 用)

配置 IGMP Proxy

/ip igmp-proxy interface
add interface=pppoe-out1 upstream=yes
add interface=bridge1 upstream=no

配置防火墙允许 IGMP 和组播流

/ip firewall filter
add chain=forward protocol=igmp action=accept comment="允许 IGMP"
add chain=forward dst-address=224.0.0.0/4 action=accept comment="允许组播流"
add chain=forward in-interface=bridge1 out-interface=pppoe-out1 protocol=igmp action=accept comment="允许 IGMP 请求"
add chain=forward in-interface=pppoe-out1 out-interface=bridge1 dst-address=224.0.0.0/4 action=accept comment="允许 WAN → LAN 组播"

启用桥接防火墙控制

/interface bridge settings set use-ip-firewall=yes
/interface bridge set bridge1 igmp-snooping=no

七、DHCP 服务(LAN 地址分配)

配置 DHCP 地址池

/ip pool add name=lan-pool ranges=10.10.10.100-10.10.10.200

配置 DHCP 服务器

/ip dhcp-server
add name=lan-dhcp interface=bridge1 address-pool=lan-pool disabled=no

配置 DHCP 网络信息

/ip dhcp-server network
add address=10.10.10.0/24 gateway=10.10.10.1 dns-server=114.114.114.114,223.5.5.5

八、调试建议(抓包、日志)

抓包查看是否有组播

/tool sniffer quick interface=bridge1 ip-address=224.0.0.0/4

查看防火墙日志

/log print

总结

以上配置涵盖了从系统标识设置、PPPoE 拨号、NAT、防火墙设置到 DHCP 服务、IGMP Proxy 的配置。通过这些步骤,你可以确保路由器具备基本的网络功能,并可以通过防火墙规则保护网络安全。