Board logo

標題: 香港与大陆用MikroTik做HK-Gateway和CN-Gateway集中讨论POST [打印本頁]

作者: 张无忌    時間: 2025-1-15 12:12     標題: 香港与大陆用MikroTik做HK-Gateway和CN-Gateway集中讨论POST

本帖最後由 张无忌 於 2025-2-3 15:33 編輯

在香港的生活平时上网就要求有Wi-Fi,这里所指Wi-Fi就时香港Wi-Fi,而router之LAN ports就是香港IP,我们简单称为HK-Gateway。但是有时候上网大陆网如CCTV5,如果HK-Gateway就不能看到!如上大陆淘宝某些网站就不接受,因为你用的时HK-Gateway,为了解决这个问题,就是需要大陆的IP,就需要CN-Gateway,那么一个router同时有CN-Gateway又同时有HK-Gateway。

在大陆生活的老人家如深圳,珠海,中山等等,要上香港节目,听歌,上网都不行,如果大陆家里能安装HK-Gateway就很方便(Wi-Fi and LAN),再加上大陆网(CN-Gateway)都能同时用,那么大陆老人家,在大陆生活就非常方便,有HK-Gateway又有CN-Gateway。

1983 HD毕业后开始工作,主要电话,石油,电器控制,后来入两所大学工作,取得UK Engineering Council Part II,MSc and PhD。从中学习怎样专研,其中电脑方面从1983 modem 300 bps到现在光纤,中间信号怎样传输,后来信息加密等,当中virtual private network(VPN)最有兴趣。

在1994开始,大陆关注互联网的信息,从1996年开始有关于监管互联网法案,关于Great Firewall(GFW)的文件。而VPN便出现,最早Internet Protocol Security(IPsec)1992由The Internet Engineering Task Force (IETF)主导,IPsec(IKEv1)1998, Point-to-Point Tunneling Protocol (PPTP)主导由Microsoft 1999,继续由L2TP,L2TP/IPsec(2001),OpenVPN(2001),SSTP(2007),IPsec(IKEv2)2010,近期2015年WireGuard(WG)出现,而在2020 Linux 5.6中用WireGuard在kernal,在本章里主要WireGuard用途CN-Gateway,HK-Gateway的建造,可能将来还有US-Gateway。

在我在大陆2022年5月买了一台TV Box(MECOOL KM2)[1],主要出口的产品,在大陆根本用不上,如果要用手提电脑上HK网,然后送Wi-Fi到TV Box,连到Google Android,注册后,如果开始使用,但是一直提供香港IP接香港。但是后来知道用大陆宽频连TV Box,TV Box里的DNS修改,用阿里云的DNS server,TV Box里安装一个WireGuard连接香港,怎样输入WireGuard数据都要用过一些App,后来最后都成功了。如果需要改动就很麻烦,需要从网上看到一个文章[2] 2022年10月,需要从一个国家连到第二个国家看电视节目,他都是用MikroTik router v7.x来实现,而v7.x里就有WireGuard,v6.x是没有的,就是把MikroTik router的LAN + Wi-Fi变得到第二国家的IP。

我把MikroTik router的LAN + Wi-Fi跟据dimitrije [2]作出修改,变成今天我在大陆用的HK-Gateway [3]。为了减轻router的负担,就变成就两个Gateways合二为一,变成大陆用的CNG+CN-HK-Gateway,而香港用HKG-CN-HK-Gateway。

[1] MECOOL KM2 Android TV Box有Google 和 Netflix 认证 —— 第1集
[2] Wireless FOB with MikroTik and Wireguard
[3] Mainland China VPN Hong Kong via MikroTik and WireGuard
作者: 张无忌    時間: 2025-1-15 12:13

本帖最後由 张无忌 於 2025-5-2 05:23 編輯

过去的帖子:

家里路由器问题查找方法
回复fakeman意见,加上了2000-2025大陆Internet发展
WireGuard server setup and PC configuration setup
大陆的家里Mikrotik router在私网IP,在外面怎样连接家里的router?
如果router后面有其他device,我们可以利用port forwarding
Remote login WinBox from Internet
MikroTik routers CN to HK performance via WireGuard

CN-Gateway and HK-Gateway
Mainland China VPN Hong Kong via MikroTik and WireGuard
大陆MikroTik router建大陆CN-Gateway和香港HK-Gateway
香港MikroTik加WireGuard接大陆IP建立CN-Gateway
香港MikroTik有香港IP(HK-Gateway),同时有大陆IP(CN-Gateway)?

Additional:
Why and how , 回家/回國vpn xo_ox
大陸ip address 問題 jeffywm

Refereces:
Netgate Docs
香港人在中山 ZeroTier VPN TVB 小米AX3000T Part 23
香港人在中山 新板 JCG Q30 超易改教程 VPN TVB Part 27
DNS Leak Test
acwifi.net
作者: 张无忌    時間: 2025-1-15 12:13

本帖最後由 张无忌 於 2025-3-30 18:14 編輯

singbox
这可能是最好的ROS分流方法!RouterOS 搭配Singbox代理局域网设备|FakeIP分流法
极简ROS容器Singbox,再学不会你来打我!!
作者: 张无忌    時間: 2025-1-15 12:13

本帖最後由 张无忌 於 2025-2-19 20:34 編輯

大陆DNS和IP的问题

在大陆上网,如果全部都是大陆的话,DNS和IP非常干净。如果要香港的话就不同了,因为连香港的IP可能都有问题,有些可以,有些不可以,特别你那些有牌子的VPN很多都不行!如果家里的VPN就好很多,通常只有自己用,但是香港的Router IP怎样来?就是连VPN已经把你卡住。

连VPN都失败

是主你大陆用DNS不能查出正出的hostname IP,这就是DNS污染,可能你用的FQDN的server太多人用,唯一换一些不显眼和不出名的DNS server,自己买二级hostname(abc.xyz.com),应该没有问题。如果有问题,可以通过iMessage [1]或FaceTime [2]与香港亲友联系,用手机或电脑输入CheckIP.com,然后用IP代替hostname。或着IP被封就要换IP,这过程需要关路由器电源15分钟。

某些fixed IP被block
就上面DNS过关,你可以得到真的IP,如果时IP一些知名VPS/VPN,因为这些IP十年都不变,所以100% block!就算你要求新的IP,而新IP都在block范围里,除非你一些非常不出名的VPS/VPN,可能不被block,这是可能是可行,做好是家里的IP回比较好。

VPN
IPsec主要商业用比较多,他们用大陆连香港核准特变通道联网。而一般市民用PPTP和L2TP上网,在最初出现都能用,但是很快又不能用了。后来L2TP变成L2TP over IPsec(L2TP/IPsec)又好一点,很快又被block。大陆知道你的URL,上网的内有都能看到,如果一些违法行为就block,如果你要看大公报或者文汇报就不会被封。只要你连接的方法,内用都能看到,但是OpenVPN看不到内用,但是大陆知道你用OpenVPN,而不会是商业IPsec,所以都被block,在最后用IPsec IKEv2 或者WireGuard用的比较多。

其他方式
Shadowsocks (2012-2015)喝茶后,就出现V2Ray(2015-2019),后面更加多V2rayN,Clash等等。

References:
[1] 大陆iPhone iMessage不用VPN和SMS,可以跟香港iPhone iMessage互相交换
[2] iPhone FaceTime在大陆用,不用VPN,互相拨打香港、台湾、美国iPhone FaceTime
作者: 张无忌    時間: 2025-1-15 12:14

本帖最後由 张无忌 於 2025-2-19 20:33 編輯

用电脑上网:
PPTP 和 L2TP/IPsec [1]
IKEv2 [2]
WireGuard

其他如SSTP,OpenVPN的scripts弄好再刊登出来。

Others:
大陆私网IP的MikroTik router可遥远控制 [3]。

[1] 大陆Window 10 PPTP client连接香港陈旧的PPTP server能话多久?
[2] MikroTik RouterOS IKEv2 RSA VPN Settings for both Apple and Android devices
作者: 张无忌    時間: 2025-1-15 12:14

本帖最後由 张无忌 於 2025-2-3 14:30 編輯

一般MikroTik router有ether1、ether2、ether3、ether4、ether5、wlan1(2G)和wlan2(5G),通常ether1接ISP Internet,如果单独全香港做CN-Gateway或大陆做HK-Gateway,就用default settings。如果香港或大陆MikroTik路由器要两用,1/2做CN-Gateway(ether2、ether3、wlan1),1/2做HK-Gateway(ether4、ether5、wlan2)。

MikroTik routers有hAP ax3,hAP ax2,hAP ac3,hAP ac2,还有lower ends,但是性能比较弱一些。我用的hAP ac3买了US 109元,而hAP ax3 US 139元就最好,性价比为佳,它有2.5G Internet input,128M flash,1G RAM,5 ethernet ports,Wi-Fi 2.4G和5G [1]。

Reference:
[1] MikroTik hardware
作者: 张无忌    時間: 2025-1-15 12:14

本帖最後由 张无忌 於 2025-2-3 14:38 編輯

Location: 香港使用MikroTik
Objective: 把路由器LAN+Wi-Fi变成大陆IP--->CN-Gateway
Backup Code: HKG+CN-Gateway (Type A)[1]
##########################################

把香港的MikroTik router变成大陆IP的router [1],就是所有LAN and Wi-Fi ports变为大陆IP,用电脑上网犹如在大陆一样,如CCTV5,CCTV5+,CCTV16,爱奇艺软件都能正常上网,而大陆的电子产品,有的需要大陆IP的都可以用,但是你需要大陆的公网IP和WireGuard server。

[1] 香港MikroTik加WireGuard接大陆IP建立CN-Gateway

###########################################################
Location: 香港使用MikroTik
Objective: 把路由器LAN+Wi-Fi--->+ 1/2大陆CN-Gateway + 1/2香港HK-Gateway
Backup Code: HKG+CN-HK-Gateway(Type B )[2] ###########################################################

hAP ac lite: 已经建立CN-Gateway (ether2,ether3,wlan1=CN-2G),HK-Gateway(ether4,ether5,wlan2=HK-5G)

[2] 香港MikroTik有香港IP(HK-Gateway),同时有大陆IP(CN-Gateway)?
作者: 张无忌    時間: 2025-1-15 12:15

本帖最後由 张无忌 於 2025-2-19 20:36 編輯

Location:大陆使用MikroTik
Objective: 把路由器LAN+Wi-Fi变成香港IP--->HK-Gateway
Backup Code: CNG+HK-Gateway(Type C)[1]
#########################################

hAP ac2: 已经建立CN-Gateway (ether2,ether3,ether4,ether5,wlan1=CN-2G,wlan2=CN-5G)

RB951G-2HnD: 已经建立CN-Gateway (ether2,ether3,ether4,ether5,wlan1=CN-2G)

CCR1009-7G-1C-PC: 已经建立CN-Gateway (ether2,ether3,ether4,ether5,ether6,ether7,combo1)

[1] Mainland China VPN Hong Kong via MikroTik and WireGuard

#########################################################
Location: 大陆使用MikroTik
Objective: 把路由器LAN+Wi-Fi--->1/2大陆CN-Gateway + 1/2香港HK-Gateway
Backup Code: CNG+CN-HK-Gateway(Type D)[2]
##########################################################
hAP ac2: 已经建立CN-Gateway (ether2,ether3,wlan1=CN-2G)和HK-Gateway(ether4,ether5,wlan2=HK-5G)

RB951G-2HnD: 已经建立CN-Gateway (ether2,ether3,wlan1=CN-2G)和HK-Gateway(ether4,ether5,wlan2=HK-2G),where wlan2 is the virtual port of master wlan1

[2] 大陆MikroTik router建大陆CN-Gateway和香港HK-Gateway
作者: tol4kzk    時間: 2025-1-15 13:15

好煩...日日三幅被咁洗頻發埋O的old tech post.......
作者: xo_ox    時間: 2025-1-15 13:30

好煩...日日三幅被咁洗頻發埋O的old tech post.......
tol4kzk 發表於 2025-1-15 05:15


old tech ?
作者: pbodq    時間: 2025-1-15 14:00

回覆 9# tol4kzk


似係另一個bot account
作者: fakeman    時間: 2025-1-15 15:04

回覆  tol4kzk


似係另一個bot account
pbodq 發表於 2025-1-15 14:00



    唔係 bot account.....只係....除咗 Mikrotik 之外佢冇嘢 accept 咁滯,講來講去都係果幾樣嘢。另外係大陸翻牆本來就無固定必勝方式(有都會被 block),但只要佢成功到就覺得全人類都 work,唔 work 係人地問題咁啫
作者: tol4kzk    時間: 2025-1-15 15:20

本帖最後由 tol4kzk 於 2025-1-15 15:26 編輯
唔係 bot account.....只係....除咗 Mikrotik 之外佢冇嘢 accept 咁滯,講來講去都係果幾樣嘢。另外 ...
fakeman 發表於 2025-1-15 15:04


講得好中, 仲要教人用過時+已知最高風險工具去穿GFW, 真係誤人子弟..

仲公海教人做回國, 如果佢係大陸人, 應該都好快露頭被人請飲茶
作者: fakeman    時間: 2025-1-15 15:52

講得好中, 仲要教人用過時+已知最高風險工具去穿GFW, 真係誤人子弟..

仲公海教人做回國, 如果 ...
tol4kzk 發表於 2025-1-15 15:20



    我只可以講,固有嘅 PPTP/L2TP/WG/OVPN 果 d 係 "時得時唔得",如果唔係邊有人成日要研究乜乜 socks 點整丫
作者: javacomhk    時間: 2025-1-15 18:40

本帖最後由 javacomhk 於 2025-1-15 12:00 編輯

大家唔同需求啫,香港IP 已經唔值錢,我就鍾意番出去外國可以用chatGPT 或者 google ai gemini 啦!
作者: rfdingo    時間: 2025-1-15 18:52

.... 用番自己之前個貼續杯就可以
無需要係咁開新 post
作者: wongja    時間: 2025-1-20 13:29

本帖最後由 wongja 於 2025-1-20 13:31 編輯

已經喺大陸工作咗一年,一個半月番去五日嗰隻
都係openwrt + openclash + 機場算啦。
電話一樣,有錢啲嘅咪中移一卡兩地(我兩樣都有,但 local sim 快好多)
已經無動力去搞,實在太煩,香港又無人幫手maintain
作者: s84292    時間: 2025-1-20 13:42

香港IP仲有咩意思

租個US 或者日本做跳板仲好
香港IP買野仲貴過人呢
作者: 张无忌    時間: 2025-1-27 10:29

本帖最後由 张无忌 於 2025-2-18 13:01 編輯

回覆 12# fakeman

现在香港和大陆4种方(Type A,B,C,D)式都可以用,大陆2种(Type C and D)都测试过可以用,香港(Type A and  B)都在香港测试过可以用。

其实香港public IP,而大陆有部分private IP和public IP。现在香港去大陆,需要大陆要有public IP,而大陆连香港就没有,因为香港大部分是public IP。

现在用的方法只是要用WireGuard,其实还有很多种,这让大家可以用别的方法实现。

在本post第一页有更加多的连接信息。
作者: xo_ox    時間: 2025-1-27 11:30

本帖最後由 xo_ox 於 2025-1-27 03:31 編輯

更多美國公民購買中國 VPN中 ...

it is good , I got a Aliyun VPS @82/year ,
作者: murderfreaker    時間: 2025-1-27 12:33

講得好中, 仲要教人用過時+已知最高風險工具去穿GFW, 真係誤人子弟..

仲公海教人做回國, 如果 ...
tol4kzk 發表於 2025-1-15 15:20


仲要前文一堆學歷經驗
同主題完全無關。


最常見嗰啲高用量例如睇境外片一日超過10GB usage完全無涉及

全部咩Type A B C D都係硬闖GFW
抵被人話Old tech.
作者: tol4kzk    時間: 2025-1-27 13:28

本帖最後由 tol4kzk 於 2025-1-27 13:30 編輯
仲要前文一堆學歷經驗
同主題完全無關。


最常見嗰啲高用量例如睇境外片一日超過10GB usage完全無涉及

...
murderfreaker 發表於 2025-1-27 12:33

Old sea food 係到講返想當年啲威水史又hd 又 phd 遲啲可能講埋自己已經識用 pdd 買嘢添
但唔知已經同時代脫節

via HKEPC IRF 5.1.14 - iOS(5.1.1)
作者: 张无忌    時間: 2025-2-3 12:43

本帖最後由 张无忌 於 2025-2-18 13:02 編輯

Remote login WinBox from Internet

通常我们要调制MikroTik router,主要WinBox在PC Windows,PC里的LAN cable接去router的LAN port,然后输入local router,通常是192.168.88.1,admin and password。

如果在外地,我们怎样去login router呢?

下面需要下面的script:
  1. #Add WinBox
  2. /ip firewall filter
  3. add chain=input comment="WinBox Wan Administration" dst-port=8291 \
  4. protocol=tcp action=accept
複製代碼
用WinBox,去打开router,然后点击“New Terminal”,输入上面的script,然后在/ip/firwall/input打开,上面输入的script,rule table“/ip/firwall/filter print”,最后一条rule,然后把这条rule拖去适合的位置中。

在本post第一页有更加多的连接信息。
作者: 张无忌    時間: 2025-2-10 15:44

本帖最後由 张无忌 於 2025-2-18 13:02 編輯

如果router后面有其他device,我们可以利用port forwarding

例如我们在前router R1,后面再加一只router R2,在外面用电脑怎样呢?我们在R1加一条forwarding rule,在/ip firewall nat加入下面的script。在R1用8292指向10.0.88.254:8281,用WinBox terminal:host abc.xyz.org:8292,先去R1,然后经过/ip firewall nat,就会转为8291到R2。

在R1里安装/ip firewall nat
  1. #port forwarding
  2. /ip firewall nat
  3. add chain=dstnat protocol=tcp dst-port=8292 in-interface=ether1 action=dst-nat \
  4. to-address=10.0.88.254 to-port=8291
複製代碼
在本post第一页有更加多的连接信息。
作者: 张无忌    時間: 2025-2-12 15:50

本帖最後由 张无忌 於 2025-2-21 10:34 編輯

大陆的家里Mikrotik router在私网IP,在外面怎样连接家里的router?

因为家里没有公网IP,在外面是不能直接连到家里的router。

私网R1 ---> router(ISP)---> Internet ---> 公网R2 <--- notebook PC

家里的router(R1)可以先连接外面一个公网IP router(R2),在外面的notebook PC(或desktop PC)的WirGuard Client又连接R2,在notebook PC里用WinBox去打开家里的R1。

在notebook PC开两个WireGuard,分别fs-gu-mt(Table 1)和fs-gu-us(Table 2)去到R2,我用MikroTik router,而你可以用别的WireGuard server也可以。在R2的两个clients,主要fs-gu-mt(10.2.100.5/32)and fs-gu-us(10.2.100.2/32)。Table 1用来写MikroTik R1 coding,它的script在Table 4。

R1: 10.2.100.5/32 --> 10.2.100.5/24

工具:
1、 PC Windows的WirGuard Client
2、 PC Windows的WinBox
3、 R2 WireGuard server(用MikroTik or others)
4、 R1 MikroTik router

行动:
1、 利用fs-gu-mt(10.2.100.5/32),变动10.2.100.5/24,做出Table 4: R1 WireGuard client后
2、 用notebook PC,先连fs-gu-us(10.2.100.2/32),到R2
3、 用notebook PC,运行WinBox login:10.2.100.5, admin/password
4、 如果隔了一天,routers会转了IP,可能要过自动几次connect才能成功,主要中间要routers需要好后,再connect就一次成功。

注意:大部分MikroTik routers要多加WinBox command,请看27#
作者: 张无忌    時間: 2025-2-12 15:51

本帖最後由 张无忌 於 2025-2-12 22:49 編輯

Table 1: PC连接公网IP的WireGuard设置1(for R1 not inside)
  1. #############################################
  2. #fs-gu-mt
  3. #PublicKey = 6SS1XAlmf2kYDr/tl0fHnVyTgWATeRyf/CKY1tgLTjE=

  4. [Interface]
  5. PrivateKey = mNFjsoTI5IQqMsRlT8uCN6Hkwd1s3J10QEYqOFI/pGU=
  6. Address = 10.2.100.5/32
  7. DNS = 223.5.5.5, 119.29.29.29

  8. [Peer]
  9. PublicKey = pHfm7nZ/PTR0A7ca5I5gVJqr1bTS6eXL0wB4v8cl+RU=
  10. PresharedKey = +LTmCJ3lK4HKRsDzBis4omPjMSLEIJ6qsUTxbwU6x1s=
  11. AllowedIPs = 0.0.0.0/0
  12. Endpoint = abc.xyz.org:60279
  13. PersistentKeepalive = 25
複製代碼
Table 2: PC连接公网IP的WireGuard设置2(for user)
  1. ####################################
  2. #fs-gu-us
  3. #PublicKey = 9XfvhtbOjt5f6R+KZptEuifQ9sTRPmPrmy2Tax0ZPhg=

  4. [Interface]
  5. PrivateKey = cIvH/Z9TIcp5EHRmUhyRnthUu2D5TQhVuuxshFrSPFc=
  6. Address = 10.2.100.2/32
  7. DNS = 223.5.5.5, 119.29.29.29

  8. [Peer]
  9. PublicKey = pHfm7nZ/PTR0A7ca5I5gVJqr1bTS6eXL0wB4v8cl+RU=
  10. PresharedKey = 4LHcT1qU4ybbILKpOWw2by/pQhVZt9jrApUC9NmDg3Q=
  11. AllowedIPs = 0.0.0.0/0
  12. Endpoint = abc.xyz.org:60279
  13. PersistentKeepalive = 25
複製代碼
Table 3: R2 WireGuard server
  1. ##########################################
  2. #R2 WireGuard server
  3. #PublicKey = pHfm7nZ/PTR0A7ca5I5gVJqr1bTS6eXL0wB4v8cl+RU=

  4. [Interface]
  5. PrivateKey = KPje8vVVILP7WeR9cOmlfYYfmcni1sCNeAFB61Hk/EA=

  6. [Peer]
  7. PublicKey = 6SS1XAlmf2kYDr/tl0fHnVyTgWATeRyf/CKY1tgLTjE=
  8. Address = 10.2.100.5/32
  9. PresharedKey = +LTmCJ3lK4HKRsDzBis4omPjMSLEIJ6qsUTxbwU6x1s=

  10. [Peer]
  11. PublicKey = 9XfvhtbOjt5f6R+KZptEuifQ9sTRPmPrmy2Tax0ZPhg=
  12. Address = 10.2.100.2/32
  13. PresharedKey = 4LHcT1qU4ybbILKpOWw2by/pQhVZt9jrApUC9NmDg3Q=
複製代碼
Table 4: R1 WireGuard client
  1. /interface wireguard
  2. add listen-port=13232 mtu=1420 name=wg-fs private-key=\
  3. "mNFjsoTI5IQqMsRlT8uCN6Hkwd1s3J10QEYqOFI/pGU=" \
  4. comment="WG FS"

  5. # Assign address to the router on the new interface.
  6. /ip address
  7. add address=10.2.100.5/24 comment="Wireguard" interface=wg-fs \
  8.     network=10.2.100.0

  9. # Set up FS peer
  10. /interface wireguard peers      
  11. add name=fs allowed-address=10.2.100.5/24 comment="fs" \
  12.     endpoint-address=abc.xyz.org endpoint-port=60279 \
  13.     interface=wg-fs public-key=\
  14.     "pHfm7nZ/PTR0A7ca5I5gVJqr1bTS6eXL0wB4v8cl+RU=" \
  15.     preshared-key="+LTmCJ3lK4HKRsDzBis4omPjMSLEIJ6qsUTxbwU6x1s=" \
  16.     persistent-keepalive=25
複製代碼

作者: 张无忌    時間: 2025-2-12 15:51

本帖最後由 张无忌 於 2025-2-18 13:02 編輯

在使用觉得非常有用,如果mobile notebook在大陆,可以快速remote login到家里MikroTik router。如果在香港也可以,但是速度可能有点慢,主要香港与大陆之间的Internet border。

其实最重要是Table 4的MikroTik router的settings。

CCR1009 was tested all right,因为没有default configuration,所有都是自己起,所以只要WireGuard互通,就不走firewall!!!这是合理的。

而RB5009,hAP ax lite,hAP ac2,hAP ac lite,RB951-2HnD, hAP ax3是由default configuration,有了WireGuard都要经过firewall,所以要firewall filter rules多加下面一句,这句在“defconf: accept ICMP”之下就可以(在ip>firewall>filter rules最低的用drag and pull)。对于为什么MikroTik这样做,其实我不懂,为什么WireGuard都要经过firewall呢?
  1. #Add WinBox
  2. /ip firewall filter
  3. add chain=input comment="WinBox Wan Administration" dst-port=8291 \
  4. protocol=tcp action=accept
複製代碼
在本post第一页有更加多的连接信息。
作者: 张无忌    時間: 2025-2-19 17:24

本帖最後由 张无忌 於 2025-3-4 22:28 編輯

大陆MikroTik router建大陆CN-Gateway和香港HK-Gateway

CNG+CN-Gateway+HK-Gateway

我现在用hAP ac2,有5 ports,5GHz,2.4GHz,5GHz wireless using "wireless" package。

5 ports中ether1-Internet
ether2,3(bridge port 0,1)=CN,2.4GHz=CN-2G(bridge port 4)
ether4,5(bridge port 2,3)=HK,5GHz=HK-5G(bridge port 5)

建好后,用手机点击WiFi SSID,选CN-2G,全选大陆CN网络;点击WiFi SSID,选HK-5G,全选香港HK网络。LAN port去插ether2或ether3,选大陆CN网络;LAN port去插ether4或ether5,选香港HK网络。

如果给大陆的老人家用WiFi特别方便。

你的电脑LAN port要插入到port ether5(HK-Gateway),如果你disable LAN转用HK-2G/HK-5G,然后WinBox输入
Connect to:192.168.88.89, admin/password,
Connect to:192.168.88.88, admin/password。
作者: 张无忌    時間: 2025-2-19 17:26

本帖最後由 张无忌 於 2025-2-27 10:32 編輯

Table 1: MikroTik password, wireless SSID password
  1. #hAP ac2
  2. #################################################
  3. #/system reset-configuration
  4. #/system reboot

  5. /password old-password="" new-password=admin-password \
  6. confirm-new-password=admin-password

  7. /interface wireless security-profiles
  8. set number=0 name=default authentication-types=wpa-psk,wpa2-psk \
  9. mode=dynamic-keys wpa2-pre-shared-key=wifi-password \
  10. wpa-pre-shared-key=wifi-password

  11. /interface wireless set wlan1 ssid=CN-2G country="china" security-profile=default
  12. /interface wireless set wlan2 ssid=HK-5G country="china" security-profile=default
  13. #/system/reboot
複製代碼
Table 2: CN and HK networks
  1. #################################################
  2. CN-Gateway (e2,e3,wlan1),HK-Gateway (e4,e5,wlan2), ,e1=Internet

  3. e2 - bridge port 0
  4. e3 - bridge port 1
  5. e4 - bridge port 2 (HK)
  6. e5 - bridge port 3 (HK)
  7. wlan1 - bridge port 4
  8. wlan2 - bridge port 5 (HK)

  9. #################################################
  10. # HK and CN network configuration

  11. /interface bridge set number=0 name=bridge-cn
  12. /interface bridge add name=bridge-hk

  13. /interface bridge port set number=2 bridge=bridge-hk
  14. /interface bridge port set number=3 bridge=bridge-hk
  15. /interface bridge port set number=5 bridge=bridge-hk

  16. /ip address add address=192.168.89.1/24 interface=bridge-hk

  17. /ip pool set number=0 name=dhcp-cn
  18. /ip pool add name=dhcp-hk range=192.168.89.2-192.168.89.254

  19. /ip dhcp set number=0 name=server-cn
  20. /ip dhcp add name=server-hk interface=bridge-hk address-pool=dhcp-hk

  21. /ip dhcp network add address=192.168.89.0/24 gateway=192.168.89.1 \
  22. dns-server=1.1.1.1,8.8.8.8

  23. /interface list member set numbers=0 list=LAN interface=bridge-hk
複製代碼
Table 3: Connect to HK WireGuard
  1. #################################################
  2. # Step One: Wireguard Tunnel Setup
  3. #################################################

  4. #################################################
  5. # On HK MikroTik

  6. /interface wireguard
  7. add listen-port=22555 mtu=1420 name=wg-china private-key=\
  8. "iBrbTYwkIK30+lDHMXlDWu9n3KUeA1XFJx+BjsbEHnA=" \
  9. comment="WG China"

  10. /ip address
  11. add address=10.1.200.1/24 comment="WG China" interface=wg-china \
  12.     network=10.1.200.0

  13. # The firewall filter must be placed before the drop line
  14. /ip firewall filter
  15. add action=accept chain=input comment="WG China" dst-port=22555 \
  16.     in-interface=ether1 protocol=udp

  17. # Set up China peer.
  18. /interface wireguard peers
  19. add name=china allowed-address=10.1.200.2/32 comment="WG China" \
  20.     interface=wg-china public-key=\
  21.     "+l7EoWoM3JIIRw2cKWZMPc/IdI4Qjrjt1YScZJ0ObmM=" \
  22.      preshared-key="qAnHo8uMf5CrgqFP0XzyFHsG1EZW8+BWG8I3GW/rPUQ="

  23. #################################################
  24. # On China MikroTik

  25. /interface wireguard
  26. add listen-port=13231 mtu=1420 name=wg-hk private-key=\
  27. "MADwYW6QTh77/z0fXN6kRdQIA+J7Q4dZURWHeoyi1GM=" \
  28. comment="WG HK"

  29. # Assign address to the router on the new interface.
  30. /ip address
  31. add address=10.1.200.2/32 comment="Wireguard" interface=wg-hk \
  32.     network=10.1.200.0

  33. # Set up HK peer
  34. /interface wireguard peers      
  35. add name=hk allowed-address=0.0.0.0/0 comment="hk" \
  36.     endpoint-address=abc.xyz.org endpoint-port=22555 \
  37.     interface=wg-hk public-key=\
  38.     "mE1t7D3LBfeJ8SkvVRyRsEuZhTo4gl59cgKFstYm92E=" \
  39.     preshared-key="qAnHo8uMf5CrgqFP0XzyFHsG1EZW8+BWG8I3GW/rPUQ="

  40. #################################################
  41. # Step Two: Routing the Traffic
  42. #################################################

  43. # On China MikroTik
  44. /routing table
  45. add comment="For use by local clients" disabled=no fib name=wg-vpn

  46. # bridge
  47. #/routing rule
  48. #add action=lookup-only-in-table \
  49. #    comment="Local clients should use (only) Wireguard routing table" \
  50. #    disabled=no interface=bridge src-address=192.168.88.0/24 table=wg-vpn

  51. # bridge --> bridge-hk
  52. /routing rule
  53. add action=lookup-only-in-table \
  54.     comment="Local clients should use (only) Wireguard routing table" \
  55.     disabled=no interface=bridge-hk src-address=192.168.89.0/24 table=wg-vpn

  56. /ip route
  57. add dst-address=0.0.0.0/0 gateway=wg-hk routing-table=wg-vpn

  58. /ip firewall nat \
  59. add chain=srcnat out-interface=wg-hk action=masquerade

  60. ### Open MSDOS  window input "curl http://myip.dnsomatic.com" to display HK IP address ###

  61. #################################################
  62. # Step Three: DNS
  63. #################################################

  64. # On China MikroTik
  65. /ip dns
  66. set allow-remote-requests=yes servers=1.1.1.1,8.8.8.8

  67. /ip dhcp-server network
  68. set 0 dns-server=1.1.1.1,8.8.8.8

  69. #must reboot once
  70. # /system reboot

  71. #################################################
  72. # Step Four
  73. #################################################

  74. /ip firewall mangle
  75.   add action=change-mss chain=forward new-mss=clamp-to-pmtu passthrough=yes protocol=tcp tcp-flags=syn
  76.   add action=change-mss chain=output new-mss=clamp-to-pmtu passthrough=no protocol=tcp tcp-flags=syn

  77. /system reboot
複製代碼
在本post第一页有更加多的连接信息。
作者: 张无忌    時間: 2025-2-26 22:49

已經喺大陸工作咗一年,一個半月番去五日嗰隻
都係openwrt + openclash + 機場算啦。
電話一樣,有錢啲嘅咪 ...
wongja 發表於 2025-1-20 13:29


OpenWRT已经有多用途,现在加了OpenClash和机场就好,要学好OpenWRT要一定的Linux功底,加上OpenClash就更加好!!!想问你的OpenWRT + OpenClash安装后是否有HK-Gateway?可以用LAN connect到PC连到香港,用WiFi有HK-2G or HK-5G,那么iPAD,Android phone不需要VPN,就可以连到香港吗?

在15年前,有也接触OpenWRT,都是从Linksys router做起,还有其他DD-WRT, Gargoyle,那个时候都没有好的hardware,所以就停下,都后就在HKEPC里团购RB2011UiAS-2HnD,慢慢开始走上MikroTik的路上。

OpenWRT从Linxu开始develop,user利用Linux and 很多apps开始使用
MikroTik从Linux开始develop,做出RouterOS,user就基于RouterOS开始使用
Cisco从Linux开始develop,做出 IOS,user就基于IOS开始使用
作者: fakeman    時間: 2025-2-27 02:31

OpenWRT已经有多用途,现在加了OpenClash和机场就好,要学好OpenWRT要一定的Linux功底,加上OpenClash就更加好!!!想问你的OpenWRT + OpenClash安装后是否有HK-Gateway?

张无忌 發表於 2025-2-26 22:49


我發現你真係有 D 本末倒置,點解你要整 HK Gateway?咪就係為咗想係大陸通過境外連線去 D 大陸上唔到嘅網站,OpenClash 連 "機場" 駁出街都係做緊相同嘅嘢,你理得佢係用香港定美國 Gateway?小平哥都話 "唔理黑貓白貓,捉到老鼠就係好貓",最後大家都做到相同嘅嘢就得啦。

另外,你唔好拎 15 年前用過一下嘅經驗去繼續評論 OpenWrt 吧,同樣 Linux based 嘅 ROS 都可以耐不耐出下新 features 點解你覺得 OpenWrt 可以呢 15 年都冇進步?咩叫學好 OpenWrt 要一定 Linux 功底?我會建議你自己搵一個出來玩下先再講啦,事實上好多人 setup OpenWrt router 都係用佢哋 WebUI 就搞掂架喇。

15 年前可以用到 OpenWrt 嘅硬件真係唔多,當年我自己都用 m0n0wall(即係 pfSense 前身),亦有用 RouterBoard(我用 ROS 果陣你隻 RB2011 都未出),我絕對唔會話 ROS 係差(事實上如果佢哋解決到我呢度 IPv6 dual stack 問題可能一早就買佢個 license 裝 x86 VM 用),但你無需要神化到某 D 嘢只有 ROS 做到而 OpenWrt 做唔到,反而係因為 OpenWrt 更加 flexible 可以做到 D ROS 都做唔到嘅嘢。

講返轉頭,OpenWrt 用 OpenClash 嘅 proxy 然後 route 過去就已經可以 router based "過牆",所有 client 都可以強制經 "機場" 走,得閒上網睇下內地大神嘅教學,你會發現個 setup 比起你 ROS 整體設定簡單好多。

仲有,唔知點解你要分開 2.4GHz/5GHz 咁用,明明 2.4GHz 就係好慢,你研究咗 ROS 咁多年,唔諗吓 virtual SSID 分開唔同 VLAN?咁咪可以有多於一個 5GHz WiFi 分開幾邊用囉。
作者: linuxfans    時間: 2025-3-4 18:39

回覆 29# 张无忌


    您的脚本有缺陷,按您上面的方法设置ROS后,用Winbox无法搜索到ROS,用IP和MAC都不行。
作者: 张无忌    時間: 2025-3-4 21:36

本帖最後由 张无忌 於 2025-3-5 11:18 編輯
回覆  张无忌


    您的脚本有缺陷,按您上面的方法设置ROS后,用Winbox无法搜索到ROS,用IP和MAC都不行 ...
linuxfans 發表於 2025-3-4 18:39


你的电脑LAN port要插入到port ether5(HK-Gateway),如果你disable LAN转用HK-2G/HK-5G,然后WinBox输入
Connect to:192.168.88.89, admin/password,
Connect to:192.168.88.88, admin/password。

因为在大陆生活,先用PC WireGuard [1],用PC连好,转以MikroTik router。先建议CN-Gateway [2],所有LAN ports and Wi-Fi都能连去CN-Gateway,把configuration backup,再开始另外CN-Gateway + HK-Gateway [3]。

[1] WireGuard
[2] Mainland China VPN Hong Kong via MikroTik and WireGuard
[3] 大陆MikroTik router建大陆CN-Gateway和香港HK-Gateway
作者: 张无忌    時間: 2025-3-11 15:37

本帖最後由 张无忌 於 2025-3-11 15:52 編輯

WireGuard server setup and PC configuration setup

自己怎样set VPN server,你要有WireGuard server,如MikroTik,ASUS,OpenWRT,Linux。

打开“https://www.wireguard.com”到官网,再点击“Installation”,从里面选择适合WireGuard client,安装后等到WireGuard client。

WireGuard server
  1. [Interface]
  2. PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
  3. ListenPort = 51820

  4. [Peer]
  5. PublicKey = gN65BkIKy1eCE9pP1wdc8ROUtkHLF2PfAqYdyYBz6EA=
  6. AllowedIPs = 10.0.0.2/32
複製代碼
WireGuard client
  1. [Interface]
  2. PrivateKey = gI6EdUSYvn8ugXOt8QQD6Yc+JyiZxIhp3GInSWRfWGE=
  3. ListenPort = 21841

  4. [Peer]
  5. PublicKey = HIgo9xNzJMWLKASShiTqIybxZ0U3wGLiUeJ1PKf8ykw=
  6. Endpoint = 192.95.5.69:51820
  7. AllowedIPs = 0.0.0.0/0
複製代碼
在WireGuard server里,有两个rules要加入,下面是CLI输入方式,而在其他routers在不同的位置加入,在“/ip firewall filter”一定要适当位置,就是就input drop之前就可以。
  1. /ip address add address=10.0.0.1/24 interface=wireguard1

  2. # The firewall filter must be placed before the drop line
  3. /ip firewall filter
  4. add action=accept chain=input dst-port=51820 \
  5.     in-interface=ether1 protocol=udp
複製代碼
在手机输入的是扫描QR code,QR code把“WireGuard client”码放在下面:

https://www.wireguardconfig.com/qrcode

再按“Generate QR code”,就二维码展示出来,用手机的WireGuard app扫一下就OK。

在大陆就可以用WireGuard app,再点击在香港下载WireGuard就可以,比较之前用的IKEv2更加方便。

在WireGuard中64-bit码(PrivateKey,PublicKey)都是一对,共有两对:
  1. PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
  2. PublicKey = HIgo9xNzJMWLKASShiTqIybxZ0U3wGLiUeJ1PKf8ykw=
複製代碼
  1. PrivateKey = gI6EdUSYvn8ugXOt8QQD6Yc+JyiZxIhp3GInSWRfWGE=
  2. PublicKey = gN65BkIKy1eCE9pP1wdc8ROUtkHLF2PfAqYdyYBz6EA=
複製代碼
知道PrivateKey就可以generate新的对应PublicKey。

如果在WireGuard server要多加一个peer account,就如10.0.0.2/32-->10.0.0.3/32
  1. [Peer]
  2. PublicKey = gN65BkIKy1eCE9pP1wdc8ROUtkHLF2PfAqYdyYBz6EA=
  3. AllowedIPs = 10.0.0.2/32

  4. [Peer]
  5. PublicKey = <other public key>
  6. AllowedIPs = 10.0.0.3/32
複製代碼
在本post第一页有更加多的连接信息。
作者: 张无忌    時間: 2025-3-19 09:55

本帖最後由 张无忌 於 2025-3-22 13:31 編輯

回覆 31# fakeman

回复fakeman意见,加上了2000-2025大陆Internet发展

先感谢你给我的意见,因为我对OpenWrt不太了解,而中间我只用了MikroTik作我网络工具。

我本身身处大陆(大约2000年移民大陆生活),那2000年个时候在深圳,我的电脑用modem,dial-up到中国电信163,上什么一般都没有管制,2003开始有些网站管制,2008年发现有些网址打不开,所以要看就要VPN,那个时候用PPTP or L2TP。至于你说PPTP或L2TP之一有时不工作,主要是GFW作用,那个时候DNS已经polluted,直接IP也都polluted。后来在香港我把Linksys WRT54GL flashed DD-WRT,加入OpenVPN后,上大陆上香港网就好很多。2012年出现Shadowsocks,大陆人都用,而我用没有用。原作者Clowwindy在2015年被喝茶后,继而又出现V2Ray,在2015-2019中非常火,我在大陆Raspberry起一台V2Ray,而香港又repeat一台V2Ray,这样大陆与香港就可以联系起来。在2019年后V2Ray停止更新,之后又出现不同的软件,但是它们很多基于V2Ray。

在网上寻找资料OpenWrt在2004出现,指令用command-line interpreter (CLI)or command-line interface,像Cisco的CLI似的,全多text based;而Lua Control Interface (LuCI) or web control interface 在2008也开始加入。在2010年,我在香港把TP-Link TL-WR1043ND V1.x(TL-1043),flashed OpenWrt,再加上Asterisk,用CLI输入TL-1043,用SIP device做client也可以,之后用QNAP的Linux。在OpenWrt LuCI用过一下,具体没有详细用,所以OpenWrt之后发展就不再关注。

在2012年关注RB2011UiAS-2HnD(RB2011),而其HKEPC团购,我买了一台,那个时候开始RouterOS,之前HKEPC也讨论最多是RB450G。其实我对RouterOS的认识也很浅,其实见到的configure,在PPTP,L2TP,在RourtOS,可以很方便L2TP/IPsec,后来用SSTP给大陆和香港的MikroTik hAP ac2加入,因为两个MikroTik routers,用SSTP都可以不用certificates,就可以连接成功了。至于OpenVPN就之前的DD-WRT用过,我在RouterOS没有用过OpenVPN。之后MikroTik的官网有详实的L2TP over IPsec(L2TP/IPsec),IPsec IKEv2(IKEv2),又可以它(IKEv2)加入RouterOS里。后来RouterOS从v6.x提升了v7.x,Linux kernel由v3.x转v5.x,还加入WireGuard。

在使用RouterOS,最初都是用WinBox GUI的,就是用mouse click-click搞定,不用terminal。但是发现如果重新安装就比较麻烦,所以就改用terminal input(CLI)。IKEv2 and WireGuard大部分都写CLI scripts完成。

最初我用香港MikroTik hAP ac3 v7.x的WireGuard,设为server,我在大陆用Windows WireGuard client连去香港的WireGuard server,用起来都挺方便,在大陆也安装hAP ac3。在2022年,我在淘宝买MECOOL KM2 Android TV Box [1],在大陆根本就用不到,开机注册不成功;注册利用Macbook Pro开Wi-Fi,再连HK WireGuard,再把Macbook Pro的Wi-Fi调一下就能出HK IP Wi-Fi,于是TV Box可以用,详实不详说,请看 [1]。在浏览WireGuard看到dimitrije的文章 [2],经过我的修改便成为HK-Gateway [3]。

讲到我在大陆用MikroTik HK-Gateway是挺方便,又Wi-Fi和LAN ports全都是香港,用的都是WireGuard的,如果其他国家有WireGuard servers都可以连接,US-Gateway,JP-Gateway。你用OpenWrt-based或手机的app的机场,都可以连世界各地。如果只有HK-Gateway、US-Gateway、JP-Gateway或本地大陆其中一个,而不能做一个路由器有两个gateways出现,当然你用两个路由器也可以,但是为了省资料,我把两个gateways(如HK-Gateway用CN-Gateway)都在用以一个路由器出现,我都一个思路可以仨Gateways都可以。

为了多一些了解OpenWrt,我最近买了一台大陆的router,它可以有基本router功能,还有一个OpenWrt的功能,我可以从新学习OpenWrt。你说的OpenClash,我都有兴趣,希望日后你能多多指教。

至于你提及2.4GHz和5GHz,现在暂时是这样,因为去香港比较慢就用2.4GHz,而在大陆就用5GHz。而有一台RB951G-HnD就只有2.4GHz,于是用virtual Wi-Fi成为CN-2G,原本的Wi-Fi就做HK-2G。其实Wi-Fi不是很熟,希望能有更加多的应用,如VLAN等要多多学习。

References:
[1] MECOOL KM2 Android TV Box有Google 和 Netflix 认证 —— 第1集
[2] Wireless FOB with MikroTik and Wireguard
[3] Mainland China VPN Hong Kong via MikroTik and WireGuard

在本post第一页有更加多的连接信息。
作者: 张无忌    時間: 2025-3-27 10:44

家里路由器问题查找方法

我家里有路由器,一般主要的server都放在里面,有的时候都会动一下,一般都没有问题。但是最近有一件事,突然有的时候动了一下就出问题,下面是一个例子,从中大家知道怎样处理这件事。

发现不能上网,检查路由器不能PPPoE连接失败,下面是事情流程:

1、 整个网络都很好,在睡房的电脑都能用WinBox access到路由器,路由器正常。
2、 本人计划加一个CAP(Wi-Fi 6)放在我的房间,通过LAN network连去路由器。
3、 房间用WinBox改动路由器,突然不正常(可能改动一下settings,自己都不忘了),PPPoE连不到网。
4、 看见PPPoE拨号不成功,打中国电信电话10000号,电话说check过你的router没有问题,建议reset router and ISP modem电源,过了五分钟,但是PPPoE依然拨号不成功。
5、 因为我觉得好像路由器问题,计划打算换路由器,但是太晚了。
6、 第二天中国电信9点来到,他自己的目标是让我的电脑能上网。他首先disconnect router,把 ISP modem连接固有的wall LAN cable to room的socket,再用1条LAN cable接住socket和我的电脑,再用Windows 10的“宽带上网”,输入中国电信的user/password,把电脑拨通成功上网。中间不用我的router,在房里我其他设备,不要了;我说这样不行,家里电视不能用,另外房间打印机不能用,我的房间其他设备也不能用,我老婆手机不能上网。
7、 最后用我的hAP ax3代替,而我房间设备还原,其实他把我房间设备接ISP modem里。我连到别的房间AP,通过wall LAN cable接到hAP ax3,再接ISP modem,可以PPPoE,connected,可以上网。搞了一个小时,他说搞好后,赶紧离开。

中国电信的人走了,现在如下的问题要自我解决。首先我的房间设备,通过wall LAN cable接到ISP modem,是不对的,我把它连去路由器后就可以。因为hAP ax3是新的,而很多数都在hAP ac3里面,于是又把它对换,现在的hAP ac3又出现连不到网,我把最近backup file放进去,然后reboot一下就OK了。

事后检讨:

从事件1-4可以看出有问题出自路由器本身,因为在电信公司绕空来说,ISP modem上正常。出问题出自事件3,因为对settings有改动后,改什么自己都忘了,路由器开始不正常,其实在路由器应该在System -->Reset  Configuration --> Restore previous file。

不过想起25年前是笔记本PPPoE拨号方法,详实可以看看YouTube [1,2]。

Reference:
[1] 创建新的拨号宽带连接教程,电脑建立一个新的pppoe网络连接方法  老盖聊技术
[2] 1031WIN11电脑通过PPPOE拨号上网的设置方法

在本post第一页有更加多的连接信息。
作者: fakeman    時間: 2025-3-27 16:49

ching.....其實夠啦
你之前開 post 一次過 reserve N 個位出大堆文,而家因為想 keep 住篇文永遠不死係度唧牙膏每隔 5-7 日先去回覆等個 post 浮上面,D 回覆又係不著邊際
而家冇人回覆冇人續 post,你自己就係到開始寫 D 唔關事嘅嘢去幫個 post 續命,何必呢。

P.S. 我知道如果無其他人 post,你會等差唔多一星期後先回覆我呢個 post
作者: tol4kzk    時間: 2025-3-27 20:56

ching.....其實夠啦
你之前開 post 一次過 reserve N 個位出大堆文,而家因為想 keep 住篇文永遠不死係度唧 ...
fakeman 發表於 2025-3-27 16:49


老人刷存在感,佢呢個方式推POST留意左好耐,舉報俾ADMIN啦





歡迎光臨 電腦領域 HKEPC Hardware (https://www.hkepc.com/forum/) Powered by Discuz! 7.2