BCP 协议

RouterOS 支持 BCP(Bridge Control Protocol),即在 PPP、 PPTP、 L2TP 和 PPPoE 接口上的桥接( OVPN和 SSTP 不支持)。 BCP 协议通过 PPP 协议,将两个远端的以太网数据链路打通。 BCP 建立后独立于 PPP 隧道,将不会与任何 PPP 的 IP 地址接口有关系。 BCP 能用于替代 EoIP+VPN 隧道, EoIP 要求对等的网络连接,而BCP 为网络提供另一种方式的解决,特别是一端在 nat 网络内,经过测试能正常透过 nat 网络透传二层数据。
BCP (Bridge Control Protocol)需要在两边同时启用才能工作(PPP 服务器和 PPP 客户端)。 MikroTikRouterOS 也可应用于其他的 PPP 设备,要求这个设备支持标准的 BCP 协议。


配置事例

我们需要相互连接 2 个远程办公室,并让他们在同一个以太网内工作。我们要求使用加密( encryption)保护 2个办公室的数据交换。 如下图,我有 2 个办公室,办公室 1 设置为 PPTP 服务器,办公室 2 设置为 PPTP 客户端。下面通过 winbox和 CLI 介绍配置:

Office1 配置

首先我们需要建立一个桥接口,并确保桥接将一直有 MAC 地址存在。原因很简单,当 BCP 被使用 PPP 桥接 port中,不会有任何 MAC 地址生成。

1
2
3
/interface bridge add name=bridge_local protocol-mode=rstp
/interface bridge port add bridge=bridge_local interface=ether1_local
/interface bridge set bridge_local admin-mac=xx:xx:xx:xx:xx:xx

其中 xx:xx:xx:xx:xx:xx 是 ether1_local 的 MAC 地址 现在我们能分配本地和公网地址到相应的接口上:

1
2
/ip address add address=192.168.88.1/24 interface=bridge_local 
/ip address add address=1.1.1.1/24 interface=ether2_public

在这个事例中,仅使用 PPP 做桥接,PPP profile 和 secret 的配置非常简单-仅分配用户名和密码,并指定 profile的 bridge 选项。 PPP 桥接不需要任何 IP 地址,但正常的 PPP 是必需的,所以要指定 local 和 remote 地址在服务器上。

1
2
/ppp profile add name=ppp_bridging bridge=bridge_local use-encryption=yes
/ppp secret add profile=ppp_bridging name=ppp1 password=ppp1

当桥接的 PPP 隧道需要通过二层( MAC)数据包头部信息,由于默认的接口 MTU( PPTP 是 1460)不能满足这个的通讯,所以为确保适用运用环境,建议不用考虑 MTU 值,通过在服务器的 MRRU 选项设置更高的值。
MRRU 允许启用支持单连接协商的多重链路,奋力数据包到多个通道,因此增加 MTU 和 MRU(支持 65535 字节)

1
/interface pptp-server server set enabled=yes mrru=1600

Office2 配置

首先我们需要建立桥,并确定桥将有 MAC 地址存在,原因如上提到。

1
2
3
/interface bridge add name=bridge_local protocol-mode=rstp
/interface bridge port add bridge=bridge_local interface=ether1_local
/interface bridge set bridge_local admin-mac=xx:xx:xx:xx:xx:xx

其中 xx:xx:xx:xx:xx:xx 是 ether1_local 的 MAC 地址。 现在我们能分配本地和公网地址到相应的接口上:

1
2
/ip address add address=192.168.88.254/24 interface=bridge_local
/ip address add address=2.2.2.2/24 interface=ether2_public

配置 PPP Profile,回应在服务器端的配置

1
/ppp profile add name=ppp\_bridging bridge=bridge\_local use-encryption=yes

创建一个 pptp-client 接口,不要忘记配置 MRRU 选项,确保二层帧能通过 PPP 隧道。

1
/interface pptp-client add profile=ppp_bridging mrru=1600 connect-to=1.1.1.1 user=ppp1 password=ppp1 disabled=no

BCP winbox 配置

Office1 配置

在 bridge 中添加一个桥,并设置 rstp:


在 port 中, 添加桥接的接口,我们添加 ether1 到 port 用于连接内网:

设置静态的 MAC-address:

分配 IP addresses:

创建 PPP profile,并设置 bridge 参数

添加 PPP 客户端

启用 PPTP-server, PPTP 服务器的 MRRU 一定要设置为 1600,否则会导致网页无法打开的情况。


Office2 配置

客户端路由器配置相同,只是你需要配置并启用 PPTP 客户端, 添加 PPTP client,同样需要设置 MRRU=1600,然后配置 pptp 拨号信息:

在实际网络应用中,也可以将 vlan 和 ppp 做到一个 bridge 中,通过 vlan 来划分远端桥接的区域,桥接隧道的互联网应用有很多种,特别是互联网企业网络和运营网络涉及较多。