電訊茶室's Archiver

gfx86674 發表於 2015-1-2 01:05

黑貓VPN pptp-client的pcc,並搭配Script修正!

[i=s] 本帖最後由 gfx86674 於 2015-1-13 19:01 編輯 [/i]

小弟試做二個黑貓VPN pptp-client的pcc,並搭配Script做修正!
有興趣可以參考:
[img]http://i.imgur.com/XZXSwCZ.png[/img]

二個黑貓VPN帳號 pptp-client /route /nat /mangle設定:
[img]http://i.imgur.com/B61yHdM.png[/img]

二條pptp-client做pcc ,怕的是其中一個斷線,均分會出問題.
斷線的流量會分到default route ,而非另一個pptp-client遞補..

且斷線的pptp-client會不斷的重新連線 ,若伺服器掛點
必造成log不斷的被pptp-client重新連線資訊給洗版.

所以搭配腳本修正,
若其中一條pptp-client斷線便自動修正成單線負載.
斷線的pptp-client會自動關閉,定時透過ping來測試伺服器反應.
等伺服器有回應時再重新嘗試連接.
等pptp-client上線後,待腳本恢復原本的pcc負載即可.:D
[img]http://i.imgur.com/lzsLdkF.png[/img]
目前黑貓是屬於斷網的狀態,所有的VPN設定將被腳本干預全部關閉.
就算您手動enable部份功能,下一秒也會被腳本disable:L

角色 發表於 2015-1-2 01:17

你的OS是哪个version?,我的6.23 local只能single line 用,而不可以跨越":".

gfx86674 發表於 2015-1-2 02:10

[i=s] 本帖最後由 gfx86674 於 2015-1-4 12:48 編輯 [/i]

v6.24
要在new terminal視窗宣告:local 前,
第一行要先執行 "{"這個符號代表開始,最後一行輸入 "}"代表結束.

所以在terminal視窗run腳本要這麼做:
[img]http://i.imgur.com/SGTPuuj.png[/img]

若是將Script存到排程,腳本開始的"{" 與尾端的"}"可以忽略.
但請依官網指示在尾端加2行空白行.

角色 發表於 2015-1-2 13:45

明白。CHing,你是怎样run script呢?我好像用import sample.rsc

gfx86674 發表於 2015-1-2 15:20

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

把Script貼到排程去,設定每次循環的時間就可以上工了:D
[img]http://i.imgur.com/HojN88a.png[/img]

如前所述Script頭尾不用再補上"{"與"}" ,但最後要加兩行空白行.

gfx86674 發表於 2015-1-4 00:47

[i=s] 本帖最後由 gfx86674 於 2015-1-4 01:48 編輯 [/i]

與一樓同,但改用迴圈編譯.
參數是從address-list抓取衍生.
[img]http://i.imgur.com/gl5iD7L.png[/img]
因不像一樓名稱與地址是手動直接給的,
所以每次循環都要重新搜尋值,導致路由器執行腳本時CPU負載偏高.

從另一面來看,或許是Mikrotik RB450G該汰換升級了{:5_178:}
[img]http://i.imgur.com/IKJGeAX.png[/img]

yiucsw 發表於 2015-1-13 17:25

有没有其他VPN 例如SSTP的自动更新Script.

gfx86674 發表於 2015-1-13 17:45

[i=s] 本帖最後由 gfx86674 於 2015-1-13 18:09 編輯 [/i]

[quote]有没有其他VPN 例如SSTP的自动更新Script.
[size=2][color=#999999]yiucsw 發表於 2015-1-13 17:25[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40170&ptid=6500][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
[color=Blue]自動從address-list挑選筑波大學的SSTP-Server, 若是伺服器無法使用休息2小時後再重新連接.[/color]
[img]http://i.imgur.com/ySmGWU5.png[/img]
[img]http://i.imgur.com/BOd5EPe.png[/img]

yiucsw 發表於 2015-1-13 19:02

今晚试试

yiucsw 發表於 2015-1-13 19:06

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

在中国移动宽带,PPTP 被block. 所有只能用其他。SSTP/openvpn 等。现在试SSTP。

gfx86674 發表於 2015-1-13 19:24

[quote]回復  gfx86674

在中国移动宽带,PPTP 被block. 所有只能用其他。SSTP/openvpn 等。现在试SSTP。 ...
[size=2][color=#999999]yiucsw 發表於 2015-1-13 19:06[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40173&ptid=6500][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
若要引用我編輯的腳本,先注意名稱與Script對應的內容!!
[img]http://i.imgur.com/CFdP7YO.png[/img]
[img]http://i.imgur.com/cQDoi69.png[/img]
[img]http://i.imgur.com/Ll2zXyI.png[/img]
圈起來的24 28 代表抓取address-list註解內的24~28符號 ,
也就是sstp-vpn port號.

若您的環境不同 ,部份內容也要跟著做修正!!

yiucsw 發表於 2015-1-26 23:56

我刚买多一个RB951,变成(2 X SSTP client (RB2011) 对 1 X RB2011 Server +1 X RB951 Server.
想用你的Script 但发现下载不了。可以Upload AS Text format 吗?
我的想法比较简单。Load Balance 2 SSTP channel by address list。 要是一条SSTP 断开,用IP  route 的将另一个都route 到没有问题的SSTP tunnel?
还是有其他的建议?

gfx86674 發表於 2015-1-29 19:11

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40385&ptid=6500]12#[/url] [i]yiucsw[/i] [/b]
前幾天小弟用兩台Rb450g的GRE功能建site to site,很讚:D

只要設定interface/address/route/nat就好,很容易。
不會像pptp/l2tp/sstp/ovpn 這些site to sito建立後,除route/nat外,
sever to client還得需編寫script自動修改nat腳本。

免得vpn斷線重接的過程,server這邊nat的out-interface會從原本設定的名稱,變為unknow發生錯誤。

yiucsw 發表於 2015-1-29 23:28

GRE 不是在中国不能用吗?我尝试一下。有没有Screen Capture. 可以跟一下

yiucsw 發表於 2015-1-29 23:39

peer IP 是什么?现在我的SSTP连到Server 是用DDNS。GRE可以一样吗。
在Client (中国) 是没有Public IP address. 好像缺了一点。

yiucsw 發表於 2015-1-31 17:18

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

我发现SSTP Dynamic interface 常常自动启动。所有的Firewall Rule 变得有问题。
[attach]3445[/attach][attach]3445[/attach]

想自动disable Dynamic, 不知道如何写Script,以下的script 有什么问题。在CLI 打find name="<sstp-hksstp>" 没有Return.
if ([/interface sstp-server get [find name="<sstp-hksstp>"] running]=true) \
do=(/interface sstp-server disable [find name="<sstp-hksstp>"])

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

没法找到/interface sstp-server get XXX running 的 Status.最终是以下的Script。
每5分钟看到dynamic Interface, 便Remove 一次。static interface 便会连接。
/interface sstp-server remove [find name=<sstp-xxsstp>]

我猜主要原因是RB不Stable,太重的Workload 便会Reset一般分Resource。(BT 时发现)。Reset Resource 后SSTP 会连到Dynamic interface。所有要remove Dynamic interface.

gfx86674 發表於 2015-2-2 01:02

[i=s] 本帖最後由 gfx86674 於 2015-2-2 01:04 編輯 [/i]

[quote]回復  gfx86674

我发现SSTP Dynamic interface 常常自动启动。所有的Firewall Rule 变得有问题。


想自 ...
[size=2][color=#999999]yiucsw 發表於 2015-1-31 17:18[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40467&ptid=6500][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
您這何需用到Script ?
會出現<sstp-hksstp> 代表遠端連進您本地的hksstp帳號 ,
您把hksstp帳號給關了遠端自然連不進來,自然不會有<sstp-hksstp>

另外srcipt的:if ()是判斷true 才會run do={}
像running的真/否 本身即true/false.
所以[color=SeaGreen]:if ([/interface sstp-server get [find name="<sstp-hksstp>"] running]=true) \
do=(/interface sstp-server disable [find name="<sstp-hksstp>"])
[/color]語法是正確的,但您可以省略 running]=true ,直接
[color=Red]:if ([/interface sstp-server get [find name="<sstp-hksstp>"] running]) \
do=(........)[/color]即可.

假如是希望running]=false
則[color=Blue]:if (![/interface sstp-server get [find name="<sstp-hksstp>"] running]) \
do=(........)[/color]
前面加個"!"就可以了:)

yiucsw 發表於 2015-2-2 08:55

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

hksstp 是Static/Dynamic sstp 帐号。 不知道如何只删掉动态的帐号?

yiucsw 發表於 2015-2-2 08:58

:if ([/interface sstp-server get [find name="<sstp-hksstp>"] running]) \
do=(........)

好像 get 没有 Status 回来,如何了解Get 有没有Return?

gfx86674 發表於 2015-2-2 11:35

[i=s] 本帖最後由 gfx86674 於 2015-2-2 11:57 編輯 [/i]

[quote]回復  gfx86674

hksstp 是Static/Dynamic sstp 帐号。 不知道如何只删掉动态的帐号? ...
[size=2][color=#999999]yiucsw 發表於 2015-2-2 08:55[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40500&ptid=6500][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
那有所謂的固定/浮動帳號?
出現<名稱>這是別人透過你開放的sstp帳號進入Route主機的,
只要你關閉帳號或變更密碼,對方進得了主機嗎?

yiucsw 發表於 2015-2-2 12:33

从以下的文本看到的。 静态/动态的 Interface 的用户名是一样的。都在PPP内设定的。我是 Site to Site 的 SSTP。 通过Server 的Interface 回到中国的Client。

[url]http://wiki.mikrotik.com/wiki/Manual:Interface/SSTP#Site-to-Site_SSTP[/url]
SSTP Server
Sub-menu: /interface sstp-server
This sub-menu shows interfaces for each connected SSTP client.
An interface is created for each tunnel established to the given server. There are two types of interfaces in SSTP server's configuration
Static interfaces are added administratively if there is a need to reference the particular interface name (in firewall rules or elsewhere) created for the particular user.
Dynamic interfaces are added to this list automatically whenever a user is connected and its username does not match any existing static entry (or in case the entry is active already, as there can not be two separate tunnel interfaces referenced by the same name).
Dynamic interfaces appear when a user connects and disappear once the user disconnects, so it is impossible to reference the tunnel created for that use in router configuration (for example, in firewall), so if you need a persistent rules for that user, create a static entry for him/her. Otherwise it is safe to use dynamic configuration.

fems 發表於 2015-2-4 04:52

[i=s] 本帖最後由 fems 於 2015-2-4 04:54 編輯 [/i]

[quote]我的想法比较简单。Load Balance 2 SSTP channel by address list。 要是一条SSTP 断开,用IP  route 的将另一个都route 到没有问题的SSTP tunnel?  ...
[size=2][color=#999999]yiucsw 發表於 2015-1-26 23:56[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40385&ptid=6500][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]

简单点增加备份route就可以了,仅供参考:
[url]http://forum.mikrotik.com/viewtopic.php?f=9&t=90342&p=452393&hilit=PCC#p452395[/url]

czjlj 發表於 2015-2-9 10:37

请问楼主能放出脚本吗,这个是图片啊,非常感谢!

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

[b]回復 [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=40519&ptid=6500]23#[/url] [i]fems[/i] [/b]


    现在是将unblockIPlist 来分,现在想改Interface有问题是Route 的第二Interface。还有没有时间做。

yiucsw 發表於 2015-6-29 06:41

刚上多一条Broadband (中国电信)线。现在是一条中国移动宽带(ADSL)加一条中国电信(ADSL)。在RB如何Setup?
要是加了SSTP, 如何LoadBalance?

gfx86674 發表於 2015-6-29 10:35

[i=s] 本帖最後由 gfx86674 於 2015-6-29 10:42 編輯 [/i]

[quote]刚上多一条Broadband (中国电信)线。现在是一条中国移动宽带(ADSL)加一条中国电信(ADSL)。在RB如何Set ...
[size=2][color=#999999]yiucsw 發表於 2015-6-29 06:41[/color] [url=http://www.telecom-cafe.com/forum/redirect.php?goto=findpost&pid=41478&ptid=6500][img]http://www.telecom-cafe.com/forum/images/common/back.gif[/img][/url][/size][/quote]
在設定之前您要思考中國移動寬帶 與中國電信 這兩個通道,
只允許一個從外面進入,還是兩個都開放?
如VPN連入,是開放中國移動寬帶 當入口;還是中國電信 ? 還是兩者皆可?

連接ADSL所設置PPPoE,算是PPP工具的一份子.
所以等於Router內有三個連線隧道,分別是 中國移動寬帶/中國電信/sstp
不曉得您做LoadBalance時 ,是只考慮 中國移動寬帶/中國電信 ;還是把sstp也納進去?

另外您有開放web-proxy給外地用戶使用嗎?
若沒開放,您只需做內部DHCP用戶的LoadBalance即可;

若有使用web-proxy ,則LoadBalance還必需考量Router ,
這樣web-proxy用戶連接時 ,Router才會做LoadBalance .

或許您會問為何LoadBalance需區分DHCP用戶與Router ??
這與路由判斷有關:
[attach]3623[/attach]

您從圖表中看到封包進入,從第一次路由判斷後被區分成路徑A 與路徑B.
DHCP用戶即路徑B ,Router即路徑A ...所以這兩個規劃是不同的.

平常用戶只需做路徑B即可看到LoadBalance的效果 ;

但使用web-proxy時,因為是Router先連接處理,再將封包轉送代理用戶.
所以這時您就必須思考除DHCP用戶外 ,路徑A (Router)是否也得做LoadBalance.

雯雯 發表於 2015-6-29 16:53

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

中國移動好像沒有真IP吧? 但是中國移動出海較快.

yiucsw 發表於 2015-6-29 17:35

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

现在已有VPN,中国移动打入。有两个问题所有加中国电信宽带:1)DNS/HTTP - 中国移动Block太多DNS,HTTP 地址。2)不稳定,在本地都常常断线。

现在想
是中国电信有路由猫,分两条Network 到RB Router同TV Box。
是中国移动,PPOE连到RB。
SSTP 是打出。

yiucsw 發表於 2015-6-29 17:36

主要是 Load Balance SSTP。
同用中国电信的DNS
中国电信 是 12M, 中国移动是20M

頁: [1] 2

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