返回列表 發帖

[VPN] 利用PPTP或L2TP建立Layer2隧道

本帖最後由 gfx86674 於 2018-7-1 00:54 編輯

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

BCP能取代EoIP隧道,提供另一種layer2界面,穿越nat透傳二層資料.

BCP需要在兩邊同時啟用才能工作(伺服器和用戶端):
  1. Office1 配置:
  2. /interface bridge add name=bridge-lan protocol-mode=rstp
  3. /interface bridge port add bridge=bridge-lan interface=ether2
  4. #bridge-lan是本範例Office1 Lan使用的bridge名稱
  5. #ether2是本範例Office1 LAN的其中一個接口(其它的port也可以)

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

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

  12. #建議將pptp-server的mrru提升至1600,否則bcp可能丟失封包
  13. /interface pptp-server server set enabled=yes mrru=1600
複製代碼
  1. Office2 配置:
  2. /interface bridge add name=bridge-bcp protocol-mode=rstp
  3. /interface bridge port add bridge=bridge-bcp interface=ether5
  4. #bridge-bcp是新增的bridge,目的是透過bcp將ether5橋接到server端
  5. #ether5不屬於Lan,會因bcp橋接到server端

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

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

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

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

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

本帖最後由 gfx86674 於 2018-2-9 11:08 編輯
谢谢CHing的信息,有空我会把香港和大陆用你的方法连起来,看看效果。

不过我有个问题,CHing你的Script是 ...
角色 發表於 2018-2-9 09:05

在香港或其它國家用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專用的.
就如此,沒其它的了

TOP

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

TOP

本帖最後由 gfx86674 於 2018-2-23 17:13 編輯
這裡有說明L2 Layer EOIP 同 BCP 的配置。SSTP over BCP 是支持的。
配置好像簡單,但配置完如何用在翻 - ...
yiucsw 發表於 2018-2-23 10:22

非常容易,我拿自身當例子.
住家(RouterA)網段是192.168.88.0/24 ;辦公室(RouterB)是192.168.1.0/24
使用eoip當layer2橋接工具,eoip在辦公室那邊已經與lan端橋接了.

所以在住家(RouterA)的eoip給個地址,就可以連接的到辦公室了(RouterB)
住家RouterA 新增:


但還不夠,還不算Site-to-Site ,還有辦公室(RouterB)的路由要新增.
辦公室RouterB 新增:


這樣我就可以在家連接RouterB與其他的電腦了.


若家裡的電腦(192.168.88.100)要使用辦公室網路翻牆怎麼做?
住家RouterA:
/ip route rule 新增:


/ip route 新增:

住家的nat不用新增任何東西,因為nat偽裝RouterB(辦公室)會代勞.

辦公室RouterB:
不需要再新增任何東西,您只要確定RouterB NAT偽裝src-address關閉就好.

若辦公室電腦(192.168.1.2)要透過RouterA(住家)翻牆,
基本上與上面192.168.88.100差不多,差別僅在於/ip route新增的策略...
gateway不是輸入192.168.88.1(RouterA) ,而是192.168.1.254(RouterA eoip的地址)

TOP

本帖最後由 gfx86674 於 2018-2-24 11:16 編輯

回復 9# yiucsw
用樓上方式來解釋:
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的電腦是住家的區網及網路

TOP

本帖最後由 gfx86674 於 2018-2-24 12:46 編輯

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

TOP

本帖最後由 gfx86674 於 2018-2-24 23:57 編輯

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的格式,所以不會有影響

TOP

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

從HK-1 SSTP server : 192.168.5.X
Ping 192.168. ...
yiucsw 發表於 2018-2-25 01:53

別試了,sstp真的沒辦法橋接lan...wiki說的很明白

site-to-site 請用layer3的方式做 ,要橋接ethernet請開eoip 或換openvpn連線.
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

本帖最後由 gfx86674 於 2018-2-25 10:26 編輯
Secure Socket Tunneling Protocol (SSTP) transports a PPP tunnel over a TLS channel.
yiucsw 發表於 2018-2-25 03:04

換個方式,用IPSec架Site to Site:
假設
Server地址:123.123.123.123 / 192.168.5.0/24
Client地址:無公網地址 / 192.168.1.0/24
  1. #Server
  2. /ip pool
  3. add name=rw-pool ranges=192.168.4.254/32

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

  6. /ip ipsec policy group
  7. add name=rw-group

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

  10. /ip ipsec peer
  11. 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

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

  14. /ip ipsec user
  15. add name=rw password=rw

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

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

  21. /interface bridge
  22. add fast-forward=no name=remotebridge

  23. /interface bridge port
  24. add bridge=localbridge interface=eoip-local
  25. add bridge=remotebridge interface=eoip-remote
  26. add bridge=remotebridge interface=ether5

  27. /ip address
  28. add address=192.168.1.254/24 interface=eoip-remote network=192.168.1.0
複製代碼
  1. #Client
  2. /ip ipsec peer
  3. 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

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

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

  9. /interface bridge
  10. add fast-forward=no name=remotebridge

  11. /interface bridge port
  12. add bridge=localbridge interface=eoip-local
  13. add bridge=remotebridge interface=eoip-remote
  14. add bridge=remotebridge interface=ether5

  15. /ip route
  16. add distance=1 dst-address=192.168.5.0/24 gateway=192.168.1.254
複製代碼

TOP

看到 VLAN over eoip 的文章。

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

現在想做是 VLAN over BCR.  ...
yiucsw 發表於 2018-2-25 14:09

先用sstp做出bcp隧道好嗎? 直接跳到vlan切bcp隧道會不會越級打怪,早了些...

TOP

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

TOP

本帖最後由 gfx86674 於 2018-2-25 16:27 編輯

回復 25# yiucsw
您成功建立bcp了,給您100個讚

目前您唯一的工作是盡量省缺您嘗試過的環境(能省缺代表某些步驟是多餘的),
看還能不能讓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已否成立.

TOP

SSTP-BCP:

client:可以對192.168.32.1(RouterA)與192.168.32.114(PC)試ping
server:可以對192.168.32.126(RouterB)試ping

BCP建立後 ,Server與Client端在/ip arp都會有相同mac-address紀錄
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

返回列表