電訊茶室's Archiver

gfx86674 發表於 2015-2-6 17:00

透過VPN 建立Site to Site

[i=s] 本帖最後由 gfx86674 於 2015-2-19 23:34 編輯 [/i]

[color=Blue]前言:[/color]
Site to Site的定義就是把VPN當做兩地的橋樑,讓兩分享器的網域可彼此連接.
如果橋樑是可以通行的 ,誰當Server誰當Client一點都不重要.

只要VPN這一條橋樑建立的起來,
封包就可以從client往server送,或者server往client送.

無需分享器A當client 往分享器B server連接 ,
再把分享器B當client 往分享器A server連接.
這樣做等於建兩座橋樑,說真的效率不會比較高.

所以只要VPN橋樑建立的起來,用什麼VPN協定都不管.

而做Site to Site 的事前基本工即是讓VPN能直接對Server或Client網域做讀取.
設定方式很簡單,只要將Server與Client區網interface裡arp設定為proxy-arp即可.
[attach]3447[/attach]
[attach]3448[/attach]
若您只是希望單向Client對Server ,或Server對Client網域讀取.
您只要啟用一方的proxy-arp即可 ,無需雙方的都選擇開啟.
-------------------------------------
接下來是正式的Site to Site教學 ,小弟是設定home to office ,選用sstp做連接.
小弟選用office當Server ;Home當client.

office啟用 sstp-server:
[attach]3449[/attach]
[attach]3451[/attach]
請明確定義Local/Remote Address ,以利後續設定.

Home設定 sstp-client:
[attach]3465[/attach]

Server端(office)顯示DR <sstp-office>,代表遠端(Home)成功撥接.
[attach]3452[/attach]

若您事前有設定proxy-arp ,兩分享器透過命令視窗應該ping得到彼此的區網裝置.
[attach]3454[/attach][attach]3455[/attach]
但就是局限於ROS主機 ,網域的電腦還是ping不到遠方.

這時後我們就得用偽裝.
但為何得偽裝 ,即是將區網ip偽裝成vpn的local address ,這樣就讀得到遠端了.
所以在設定vpn server時強調要定義明確的值,就在這個用意.

而偽裝需設定route與nat ,設定如下:
Client (Home):
/ip route
[attach]3456[/attach]

/ip firewall nat
[attach]3457[/attach]
[attach]3458[/attach]

Server (office):
/ip route
[attach]3459[/attach]

/ip firewall nat
[attach]3460[/attach]
[attach]3461[/attach]

基本上述即完成Sito to Site ,還是得需注意Server NAT這邊的設定.
尤於Site to Site 的VPN橋接通道並非永遠存在 ,當斷線再重新連接時.
NAT 裡的out-interface會變成[color=Red]unknow[/color] ,造成Server to Client的偽裝失能.

所以要透過腳本(Script) ,每3秒檢驗out-interface名稱一次.
若out-interface 發生錯誤自動從[color=Red]unknow[/color]再修正回[color=Blue]<sstp-office>[/color][code]:if ([/ip firewall nat get [find to-addresses="10.0.200.1"] out-interface]!="<sstp-office>") \
    do={/ip firewall nat set [find to-addresses="10.0.200.1"] out-interface="<sstp-office>"}
[/code]若還需使用Policy Routing ,即讓Home的特定電腦(192.168.2.4)透過office翻網,
只要接著做:
/ip firewall mangle
[attach]3462[/attach]
[attach]3463[/attach]

/ip route
[attach]3464[/attach]

這樣大致所有設定就結束囉 :)

gfx86674 發表於 2015-2-6 22:25

[i=s] 本帖最後由 gfx86674 於 2015-2-6 22:31 編輯 [/i]

或許有人會發現當使用Policy Routing後,怎麼本地/遠端的區網都找不到了.
理由是沒先將區域網路排除在外,所有封包都往網際網路送了.
所以您需先建立您個人的區網address-list名單. [color=Pink](小弟命名All-Lan)[/color]
[attach]3468[/attach]
address-list至少要有著本地(Home),也要有遠端區網(office)才行.

然後在/ip firewall mangle 新增例外:
[attach]3469[/attach]
[attach]3470[/attach]
[attach]3471[/attach]

新增完還要移到Policy Routing的mangle之前,代表這是優先的Rule
[attach]3472[/attach]

之後您可再試連接區域網路,封包就會不再被Policy Routing丟到公用網路囉:D

角色 發表於 2015-2-6 23:00

CHing你那么熟RouterOS,你上过RouterOS的courses?还是上过CCNA,CCNP?

gfx86674 發表於 2015-2-6 23:02

[i=s] 本帖最後由 gfx86674 於 2015-2-6 23:03 編輯 [/i]

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40537&ptid=6548]3#[/url] [i]角色[/i] [/b]
師承Google搜尋 ,至於進修課程...沒有{:5_175:}

yiucsw 發表於 2015-2-8 17:34

有点模糊,为什么有第一步proxy-arp。是Site to Site? 要是翻墙是不是不用?

gfx86674 發表於 2015-2-8 23:49

[quote]有点模糊,为什么有第一步proxy-arp。是Site to Site? 要是翻墙是不是不用?
[size=2][color=#999999]yiucsw 發表於 2015-2-8 17:34[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40564&ptid=6548][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
設定proxy-arp 是VPN重要的第一步 ,它決定了您的VPN能不能讀到Server的區域網路.
它的重要性凌架所有的VPN之上!!

先不管Site to Site ,您手機看是用PPTP /L2TP /OVPN任何一種都隨便,
VPN連到Server後 ,試讀您的區網看看.

若proxy-arp不開,頂多只是VPN上網的功能正常,
但也保證Server區域內的電腦都會讀不到.

而proxy-arp開啟,
這才除VPN上網外 ,Server內的區網才能正常讀取.

若您的proxy-arp不開 ,VPN就幾乎等同於半殘狀態 ,更惶乎透過VPN做Site to Site :D

gfx86674 發表於 2015-2-9 02:34

Site to Site最大的目的是將兩地的區域網路連接起來,Policy Routing倒是其次。
若只是透過RouteOS主機代為翻牆,那就只能算是建個人的代理伺服器,算不上Site to Site。

yiucsw 發表於 2015-2-9 17:19

明白,因为有其他人用我的网站来翻墙,所有不能用Proxy-Arp. 但我可以看到Remote Router。

yiucsw 發表於 2015-2-12 19:40

偽裝需設定的route與nat  因为翻墙的原因有点不一样。
Client (Home):
/ip route
[attach]3477[/attach]
[attach]3478[/attach]

Server site 的SSTP Interface还是试 Static SSTP Client Interface,这样不会有“unknown"
一会试Schedule.

yiucsw 發表於 2015-2-12 20:08

想了想,你的Script有点启发,但想改点逻辑。Dynamic SSTP interface不是每次都是<sstp-office> 会变成<sstp-office01>等等。IP firewall内的interface 不见的原因是Interface断掉。NAT -out interface到不存在的SSTP interface有用吗?

用                                                                                                                                      是Static interface 会 有以下的 log
SSTP-in1 terminating - Connection timeout.
SSTP-in1  - Disconnected.

现在是用我用以下的Script。只有看到<sstp-office>....dynamic interface 都会删掉。
/interface sstp-server remove [find name=<sstp-xxsstp>]

gfx86674 發表於 2015-2-12 22:13

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40599&ptid=6548]10#[/url] [i]yiucsw[/i] [/b]
會出現<sstp-office01> ,多出01是因為多人同時登入同個帳號...其它的VPN也會喔!

您想看看,帳/密 是不是被別人竊取了:o

yiucsw 發表於 2015-2-13 11:41

我猜<SSTP-office>的资源还没有释放。而SSTP Client已重试(dial-out),所以有《SSTP-office01>

gfx86674 發表於 2015-2-13 15:25

[i=s] 本帖最後由 gfx86674 於 2015-2-13 15:26 編輯 [/i]

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40606&ptid=6548]12#[/url] [i]yiucsw[/i] [/b]
那您觀察/ip firewall connection ,先前未釋放sstp-connect會標示invalid嗎?
會的話用腳本自動執行[b][color=Red] /ip firewall connection remove [find tcp-static="invalid"][/color][/b]

gfx86674 發表於 2015-3-3 10:31

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40606&ptid=6548]12#[/url] [i]yiucsw[/i] [/b]
在 PPP > Interface > add 裡面可以新增一 PPTP server,
但它的右側卻又有一 PPTP Server 的選項. 這兩者到底有何不同.
[attach]3496[/attach]
[url=http://wiki.mikrotik.com/wiki/Manual:Interface/PPPoE]後來看了官方的文件, 才瞭解了這兩者的不同[/url]
例如:
server 和 client 以 SSTP 建立 tunnel, 在 server 上建立一 static interface.
[attach]3495[/attach]
但如果是使用 dynamic interface. 系統在連線時才自動產生一個界面(如下 sstp-sstp1),
而前方的'D'代表這是 dynamic, 當連線中斷後, 這個 Interface 也會自動刪除.
[attach]3494[/attach]

yiucsw 發表於 2015-3-4 15:13

是,我是用static interface, 所有没有Invalid的问题。但一样要是connection timeout, Client 会重试,这个时刻 Server 的Static Inteface是 Pending,所有一个Dynamic interface会建立。我每两分钟看到Dynamic Interface 会remove, 然后, 一个新的 Static interface 的Tunnel会建立。 没有想到更好的办法

gfx86674 發表於 2015-3-4 16:56

[attach]3497[/attach]
小弟補充的資料您有試過嗎?

頁: [1]

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