電訊茶室's Archiver

gfx86674 發表於 2018-2-9 07:17

利用PPTP或L2TP建立Layer2隧道

[i=s] 本帖最後由 gfx86674 於 2018-7-1 00:54 編輯 [/i]

ROS支援BCP(Bridge Control Protocol),
即在PPTP/L2TP/PPPoE介面上的橋接(OVPN和SSTP不支援).

BCP能取代EoIP隧道,提供另一種layer2界面,穿越nat透傳二層資料.
[img]https://i.imgur.com/FDtsjlX.png[/img]
BCP需要在兩邊同時啟用才能工作(伺服器和用戶端):[code]Office1 配置:
/interface bridge add name=bridge-lan protocol-mode=rstp
/interface bridge port add bridge=bridge-lan interface=ether2
#bridge-lan是本範例Office1 Lan使用的bridge名稱
#ether2是本範例Office1 LAN的其中一個接口(其它的port也可以)

#Office1 LAN的地址為192.168.88.1/24
/ip address add address=192.168.88.1/24 interface=bridge-lan

#因只做layer2傳輸,不需local/remote-address,
#所以新建profile(bcp-bridging)做特殊操作,以便和一般pptp傳輸做區隔
/ppp profile add name=bcp-bridging bridge=bridge-lan use-encryption=yes
/ppp secret add profile=bcp-bridging name=abc password=123

#建議將pptp-server的mrru提升至1600,否則bcp可能丟失封包
/interface pptp-server server set enabled=yes mrru=1600[/code][code]Office2 配置:
/interface bridge add name=bridge-bcp protocol-mode=rstp
/interface bridge port add bridge=bridge-bcp interface=ether5
#bridge-bcp是新增的bridge,目的是透過bcp將ether5橋接到server端
#ether5不屬於Lan,會因bcp橋接到server端

#指定bridge-bcp的地址為192.168.88.2/24
/ip address add address=192.168.88.2/24 interface=bridge-bcp

/ppp profile add name=bcp-bridging bridge=bridge-bcp use-encryption=yes
#profile與pptp-server雷同,方可回應橋接

/interface pptp-client add profile=bcp-bridging mrru=1600 connect-to=123.123.123.123 user=abc password=123 disabled=no
#對Office1(123.123.123.123)進行pptp撥號,mrru也設置相對應的1600[/code]雖然EoIP在設置上明顯比BCP簡易的多,但EoIP需雙向互撥號對接,
對於ISP提供的地址是虛擬ip的用戶是有那麼一點不便...

而PPTP或L2TP只要單方的WAN可供接入就可建立Layer2隧道,
所以因時地選擇橋接工具是很重要的:)

另外OVPN也有其ethernet mode ,也可用於建立Layer2隧道.

角色 發表於 2018-2-9 09:05

谢谢CHing的信息,有空我会把香港和大陆用你的方法连起来,看看效果。

不过我有个问题,CHing你的Script是从GUI过来?还是从新打入RouterOS里?

gfx86674 發表於 2018-2-9 11:07

[i=s] 本帖最後由 gfx86674 於 2018-2-9 11:08 編輯 [/i]

[quote]谢谢CHing的信息,有空我会把香港和大陆用你的方法连起来,看看效果。

不过我有个问题,CHing你的Script是 ...
[size=2][color=#999999]角色 發表於 2018-2-9 09:05[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44170&ptid=7087][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
在香港或其它國家用bcp可以,但對中國...pptp應該穿不過gfw

我秀出的是cli,可以直接貼在命令視窗完成匯入.
但用gui操作或許更簡單,基本上分4個部份:

1.建立一個bridge ,然後把您想要橋接的interface在bridge port設定好.
interface的MAC鍵入bridge的MAC位置.

2.這部份可以省缺,因範例是橋接兩地的Lan所以設定192.168.88.1/24 ,
把192.168.88.1當區網的gateway
若interface是用來橋接IPTV,地址根本用不到也無需新增.

3.複製/ppp profile裡系統預設的default-encryption ,唯一不同的即bridge要設置步驟1新增的網橋.
pptp-server的/ppp secret除需新增 帳/密 ,profile也需指定bcp專用的

4.重點不管是pptp-server或client的mrru都需指定為1600 ,而pptp-client的profile指定bcp專用的.
就如此,沒其它的了{:5_186:}

yiucsw 發表於 2018-2-22 13:16

[i=s] 本帖最後由 yiucsw 於 2022-3-9 00:43 編輯 [/i]

SSTP/L2TP 支持BCP

gfx86674 發表於 2018-2-22 14:45

您可以試試,若可以Site-to-Site就可省缺eoip的步驟直接進行layer2橋接

yiucsw 發表於 2018-2-23 10:22

這裡有說明L2 Layer EOIP 同 BCP 的配置。SSTP over BCP 是支持的。
[url]https://www.youtube.com/watch?v=gahPNhbu2VA&ab_channel=MikroTik[/url]

配置好像簡單,但配置完如何用在翻 -- 牆?

角色 發表於 2018-2-23 12:15

Thank CHing for sharing this link for connect sites using BCP protocol.

gfx86674 發表於 2018-2-23 13:13

[i=s] 本帖最後由 gfx86674 於 2018-2-23 17:13 編輯 [/i]

[quote]這裡有說明L2 Layer EOIP 同 BCP 的配置。SSTP over BCP 是支持的。
配置好像簡單,但配置完如何用在翻 - ...
[size=2][color=#999999]yiucsw 發表於 2018-2-23 10:22[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44454&ptid=7087][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
非常容易,我拿自身當例子.
住家(RouterA)網段是192.168.88.0/24 ;辦公室(RouterB)是192.168.1.0/24
使用eoip當layer2橋接工具,eoip在辦公室那邊已經與lan端橋接了.

所以在住家(RouterA)的eoip給個地址,就可以連接的到辦公室了(RouterB)
[color=Blue][size=4]住家RouterA 新增:[/size][/color]
[img]https://i.imgur.com/78TvEBI.png[/img]

但還不夠,還不算Site-to-Site ,還有辦公室(RouterB)的路由要新增.
[color=Red][size=4]辦公室RouterB 新增:[/size][/color]
[img]https://i.imgur.com/j48lcwW.png[/img]

這樣我就可以在家連接RouterB與其他的電腦了.
[img]https://i.imgur.com/tdgP4wK.png[/img]

若家裡的電腦(192.168.88.100)要使用辦公室網路翻牆怎麼做?
[color=Blue][size=4]住家RouterA:[/size][/color]
/ip route rule 新增:
[img]https://i.imgur.com/lpYaYYs.png[/img]

/ip route 新增:
[img]https://i.imgur.com/GT4tlbp.png[/img]
住家的nat不用新增任何東西,因為nat偽裝RouterB(辦公室)會代勞.

[color=Red][size=4]辦公室RouterB:[/size][/color]
不需要再新增任何東西,您只要確定RouterB NAT偽裝src-address關閉就好.
[img]https://i.imgur.com/LxeEWjk.png[/img]
若辦公室電腦(192.168.1.2)要透過RouterA(住家)翻牆,
基本上與上面192.168.88.100差不多,差別僅在於/ip route新增的策略...
gateway不是輸入192.168.88.1(RouterA) ,而是192.168.1.254(RouterA eoip的地址)

yiucsw 發表於 2018-2-23 17:03

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44457&ptid=7087]8#[/url] [i]gfx86674[/i] [/b]

謝謝。有理解多點。
想問問BCP? 將兩個Bridge 加到SSTP後,變成BCP,然後如何處理? 一樣要Route?

gfx86674 發表於 2018-2-23 17:54

[i=s] 本帖最後由 gfx86674 於 2018-2-24 11:16 編輯 [/i]

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44459&ptid=7087]9#[/url] [i]yiucsw[/i] [/b]
用樓上方式來解釋:
bcp在server端(RouterB),會自動把<sstp-xxx>透過bridge與ethernet橋接.

在client端(RouterA)這邊如樓上做法,需把ether5設成192.168.1.254/24
然後在RouterB的路由表新增 dst-address=192.168.88.0/24 gateway=192.168.1.254
這樣192.168.88.0/24(RouterA) 才能與192.168.1.0/24(RouterB)互連.

若要翻牆,樓上已圖文並茂應改解釋的很清楚才是.

再強調一次,bcp在server(RouterB)這邊,
<sstp-xxx>是會主動會橋接辦公室Lan的,不是您手動做的.

若需要另一條layer2隧道 ,因上面site-to-site已完成,
您用192.168.88.1(RouterA)與192.168.1.1(RouterB)這兩個地址
當eoip-tunnel1的local-address與remote-address用,再把eoip與住家的Lan橋接在一起即可.

住家的ether5因bcp,所以接ether5的電腦是公司的區網及網路
公司的ether5手動橋接eoip-tunnel1後 ,接ether5的電腦是住家的區網及網路

yiucsw 發表於 2018-2-24 09:16

想問問:
/interface bridge port add bridge=bridge_bcp interface=ether2
的ether2 是要連到BCR的Port? 還是Master port?
那我是用ether5?wlan2?

gfx86674 發表於 2018-2-24 10:11

[i=s] 本帖最後由 gfx86674 於 2018-2-24 12:46 編輯 [/i]

深覺得先前1樓與10樓解釋容易造成您的誤會,感到抱歉{:5_233:}
所以有再修正過內容請您再閱讀看是否有不周全的地方.

yiucsw 發表於 2018-2-24 18:44

[i=s] 本帖最後由 yiucsw 於 2022-3-9 00:41 編輯 [/i]

duplicated

yiucsw 發表於 2018-2-24 18:52

[i=s] 本帖最後由 yiucsw 於 2018-2-25 12:06 編輯 [/i]

主要,
1) ROS V6 以上是不能 VPN pool, 用了不能過DHCP
2) 在System log 加Debug,看到BCP open ,BCP在啟動。
下圖是 看看 如何知道 BCR 在運行 ([url]http://rickfreyconsulting.com/wp-content/uploads/2015/04/PPP-Based-Tunnels-Bridging-BCP-Tutorial.pdf[/url])

[attach]4013[/attach]

yiucsw 發表於 2018-2-24 21:47

[i=s] 本帖最後由 yiucsw 於 2018-2-25 01:31 編輯 [/i]

CN#1 SSTP client 端:

Step 1) interface bridge add name=bridge-bcp protocol-mode=rstp
[attach]3976[/attach]

加了Bridge 有一個MAC address 不知道是什麼。
Step 2) interface bridge port add bridge=bridge-bcp interface=ether5
[attach]3977[/attach]
加了Port MAC address 改到Ether 5的MAC address

Step 3) interface bridge set bridge-bcp admin-mac=xx:xx:xx:xx:xx:xx
[attach]3978[/attach]
將Ether5的MAC address 拷貝到Admin-mac address.

Step 4) ip address add address=192.168.hk.2/24 interface=ether5
[attach]3991[/attach]

Step 4) /ppp profile add name=bcp-bridging bridge=bridge-bcp use-encryption=yes (沒有選encryption)
[attach]3992[/attach]

Step 5) interface pptp-client add profile=bcp-bridging mrru=1600 connect-to=my.hk.isp(ddns) user=abc password=123 disabled=no
[attach]4000[/attach]
[attach]4001[/attach]
[attach]4002[/attach]
SSTP 已連接。

gfx86674 發表於 2018-2-24 23:40

[i=s] 本帖最後由 gfx86674 於 2018-2-24 23:57 編輯 [/i]

1.請將bridge的fast-forward關閉,因目前功能還不完善,
會讓您的翻牆相關的設定失效

2.vpn指定ip註定只能用layer3,
vpn連線後您到/ip address看到的地址是192.168.5.1與192.168.5.50
非192.168.5.1/24與192.168.5.1/24

3.由vpn的地址可知非/24網域,而是/32 ,所以bcp根本沒成功

4.您ping的192.168.5.1是vpn-server(192.168.5.1/32),
不是localbridge的192.168.5.1/24
雖然地址同為192.168.5.1,但它們兩是不一樣的網域

5.原本192.168.5.50/32讀取192.168.5.1/24(localbridge)會有問題,
透過proxy-arp可以讓192.168.5.50/32偽裝成192.168.5.50/24
但這是layer3的方式,與原架設bcp(layer2)的方式背道而馳

6.您將192.168.5.1打成了191.168.5.1
不知道您有無察覺,但因ip是/32的格式,所以不會有影響

yiucsw 發表於 2018-2-25 01:53

[i=s] 本帖最後由 yiucsw 於 2018-2-27 12:57 編輯 [/i]

從CN-1 SSTP client : 192.168.4.X
Ping 192.168.5.1
[attach]4003[/attach]

直接將WLAN2 連到 BCR-Bridging
[attach]4010[/attach]
拿到HK1 的 IP address 192.168.5.X whatismyip 是HK 的ISP 地址。
[attach]4012[/attach]

Add route rule (不用)
[attach]4009[/attach]

Add route policy (不用)
[attach]4008[/attach]

從HK-1 SSTP server : 192.168.5.X
Ping 192.168.4.1
[attach]4004[/attach]

Route:
[attach]4005[/attach]

ping 192.168.5.2 (client ether5)
success.

Add route to 192.168.5.2 要在Server 端的Laptop 能Ping 192.168.4.x
[attach]4006[/attach]

可以ping 192.168.4.1 不知道Redirect host是什麼?
PING 192.168.4.1 (192.168.4.1): 56 data bytes
64 bytes from 192.168.4.1: icmp_seq=0 ttl=64 time=2.721 ms
92 bytes from router.lan (192.168.5.1): Redirect Host(New addr: 192.168.5.2)
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
4  5  00 0054 17ec   0 0000  3f  01 d89b 192.168.5.208  192.168.4.1

在测试机器(Mac) 上还有其他VPN, 影响Mac 从DHCP 拿 IP

gfx86674 發表於 2018-2-25 02:35

[quote]從CN-1 SSTP client : 192.168.4.X
Ping 192.168.5.1

從HK-1 SSTP server : 192.168.5.X
Ping 192.168. ...
[size=2][color=#999999]yiucsw 發表於 2018-2-25 01:53[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44498&ptid=7087][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
別試了,sstp真的沒辦法橋接lan...wiki說的很明白
[attach]4007[/attach]
site-to-site 請用layer3的方式做 ,要橋接ethernet請開eoip 或換openvpn連線.

yiucsw 發表於 2018-2-25 03:04

[i=s] 本帖最後由 yiucsw 於 2018-2-25 12:18 編輯 [/i]

[url]https://wiki.mikrotik.com/wiki/Manual:Interface/SSTP[/url]
Secure Socket Tunneling Protocol (SSTP) transports a PPP tunnel over a TLS channel.

謝謝你幫忙。看起來能用。
Wlan2 連到BCR-VPN bridge 已能從 HK1 SSTP-server 的 DHCP 那裏拿到IP。也能顯示ISP 是從 HK-1 SSTP- Server 那邊過。
以前的教材是用IP pool (VPN-pool)的, 但看到新的教材 都是用IP addressing...要是能用IP pool 少了一個要記的數字,不會有IP conflict.

gfx86674 發表於 2018-2-25 10:18

[i=s] 本帖最後由 gfx86674 於 2018-2-25 10:26 編輯 [/i]

[quote]Secure Socket Tunneling Protocol (SSTP) transports a PPP tunnel over a TLS channel.
[size=2][color=#999999]yiucsw 發表於 2018-2-25 03:04[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44502&ptid=7087][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
換個方式,用IPSec架Site to Site:
假設
Server地址:123.123.123.123 / 192.168.5.0/24
Client地址:無公網地址 / 192.168.1.0/24[code]#Server
/ip pool
add name=rw-pool ranges=192.168.4.254/32

/ip ipsec mode-config
add address-pool=rw-pool address-prefix-length=32 name=rw-cfg split-include=192.168.5.1/32 system-dns=no

/ip ipsec policy group
add name=rw-group

/ip ipsec proposal
add enc-algorithms=aes-128-cbc name=rw

/ip ipsec peer
add auth-method=pre-shared-key-xauth comment=rw dh-group=modp1024 enc-algorithm=aes-128 generate-policy=port-strict mode-config=rw-cfg passive=yes policy-template-group=rw-group secret=rw

/ip ipsec policy
add comment=rw dst-address=192.168.4.254/32  group=rw-group proposal=xauth src-address=192.168.5.1/32 template=yes

/ip ipsec user
add name=rw password=rw

/ip firewall nat
add action=accept chain=srcnat dst-address=192.168.4.254 src-address=192.168.5.1 place-before=0

/interface eoip
add allow-fast-path=no local-address=192.168.5.1 name=eoip-local remote-address=192.168.4.254 tunnel-id=100
add allow-fast-path=no local-address=192.168.5.1 name=eoip-remote remote-address=192.168.4.254 tunnel-id=200

/interface bridge
add fast-forward=no name=remotebridge

/interface bridge port
add bridge=localbridge interface=eoip-local
add bridge=remotebridge interface=eoip-remote
add bridge=remotebridge interface=ether5

/ip address
add address=192.168.1.254/24 interface=eoip-remote network=192.168.1.0[/code][code]#Client
/ip ipsec peer
add address=123.123.123.123/32 auth-method=pre-shared-key-xauth comment=rw dh-group=modp1024 disabled=no enc-algorithm=aes-128 generate-policy=port-strict mode-config=request-only secret=rw xauth-login=rw xauth-password=rw

/ip firewall nat
add action=accept chain=srcnat dst-address=192.168.5.1 src-address=192.168.4.254 place-before=0

/interface eoip
add allow-fast-path=no local-address=192.168.4.254 name=eoip-local remote-address=192.168.5.1 tunnel-id=200
add allow-fast-path=no local-address=192.168.4.254 name=eoip-remote remote-address=192.168.5.1 tunnel-id=100

/interface bridge
add fast-forward=no name=remotebridge

/interface bridge port
add bridge=localbridge interface=eoip-local
add bridge=remotebridge interface=eoip-remote
add bridge=remotebridge interface=ether5

/ip route
add distance=1 dst-address=192.168.5.0/24 gateway=192.168.1.254[/code]

yiucsw 發表於 2018-2-25 14:09

[i=s] 本帖最後由 yiucsw 於 2018-2-26 23:46 編輯 [/i]

看到 VLAN over eoip 的文章。
[url]http://www.mikrotik.co.id/artikel_lihat.php?id=20[/url]

好像沒有這樣簡單!

gfx86674 發表於 2018-2-25 14:39

[quote]看到 VLAN over eoip 的文章。

看到另一文章EOIP latency 大概是 20倍慢...

現在想做是 VLAN over BCR.  ...
[size=2][color=#999999]yiucsw 發表於 2018-2-25 14:09[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44507&ptid=7087][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
先用sstp做出bcp隧道好嗎? 直接跳到vlan切bcp隧道會不會越級打怪,早了些...

yiucsw 發表於 2018-2-25 15:01

如何知道是不是 BCP 成功?我已改了之前的發表。
我加了CN1 的 WLAN2 到 Bridge 已能拿到 HK DHCP 的 IP地址,也能用whatismyip 看到HKISP 地址。
在香港也能Winbox 到CN 1 Mikrotik.  
ping CN 有點奇怪,redirect host.. Traceroute 不成。是不是要加多一個Bridge 在HK1那邊 192.168.cn.2。那VLAN都不用。
在CN1 那邊 ping/tracerout HK1 都沒有問題。連BCR-VPN的 bridge 都沒有用。

gfx86674 發表於 2018-2-25 15:40

bcp成功的話 ,在client-router的ether5設定192.168.hk/24
可在server的/ip arp查到client-router remotebridge的mac-address

yiucsw 發表於 2018-2-25 16:01

[i=s] 本帖最後由 yiucsw 於 2022-3-9 00:50 編輯 [/i]

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44510&ptid=7087]24#[/url] [i]gfx86674[/i] [/b]

感謝
CN - Ether5
[attach]4014[/attach]

HK - IP ARP - 兩個 MAC 是一樣的
[attach]4015[/attach]

gfx86674 發表於 2018-2-25 16:23

[i=s] 本帖最後由 gfx86674 於 2018-2-25 16:27 編輯 [/i]

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44511&ptid=7087]25#[/url] [i]yiucsw[/i] [/b]
您成功建立bcp了,給您100個讚:D

目前您唯一的工作是盡量省缺您嘗試過的環境(能省缺代表某些步驟是多餘的),
看還能不能讓server arp抓到mac-address與192.168.5.2

直到您覺得到差不多時,
再到server的路由表將dst-address=192.168.cn.0/24 gateway=192.168.5.2加入

然後兩端互ping對方網段的電腦ip ,看site-to-site已否成立.

yiucsw 發表於 2018-2-25 22:58

[i=s] 本帖最後由 yiucsw 於 2022-3-9 00:52 編輯 [/i]

Duplicated

kmc87 發表於 2018-4-18 09:51

因想學習 BCP pptp, 我在香港用兩部 RB750Gr3 在不同地點,根據#1 gfx86674 的 script 方法,設定BCP pptp ,看起來 BCP 能順利連上。

Location A, Server, Router A, 基本網段 192.168.80.1/24,   BCP interface ether5, 192.168.50.1

Location B, Client, Router B, 基本網段 192.168.82.1/24,   BCP interface ether5, 192.168.50.3

問題是,如 gfx86674 在 #10 所說, Router B,Client,ether 5 不需任何設定已能經 Router A, 翻墻上網。
但 Router A, ether5 能上網,但不是經 Router B  翻墻上網。


雖然在上面有多方面討論,但因我水平不足,沒能理解 sstp, eiop 等與 pptp BCP 的對應,多次嘗試用我理解的對應設定路由,始終未能成功。

故希望大家能給我一點指導,我要怎樣設定才可以在 Server,Router A 經 Client Router B,翻墻上網 還是我這樣的網段設定不對 或要再加Eoip。其實,BCP 是不是site-to-site ?   謝謝。

yiucsw 發表於 2018-4-24 10:48

[i=s] 本帖最後由 yiucsw 於 2022-3-9 00:54 編輯 [/i]

duplicated

kmc87 發表於 2018-4-25 09:58

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=44829&ptid=7087]29#[/url] [i]yiucsw[/i] [/b]


根據上面 #10 的設定方法,我重新輸入後,已能解決問題。兩邊的 Router 已能正常互通和經對方 ip 上網。謝謝。

BCP 是互聯兩地 router 的好東西。謝謝你們的介紹和指導。

頁: [1] 2

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.