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

本帖最後由 张无忌 於 2025-1-21 18:32 編輯

香港人家里用电脑,iPad,Android,iPhone等等用普通router就可以,不需要安装买回就可以直接用。如果有些功能需要用大陆IP,才能正常使用。

需要大陆IP有如下:
1、 大陆打影器
2、 大陆扫垃圾的机器人
3、 大陆的插头
4、 大陆的CCTV5,CCTV5+,CCTV16
5、 大陆电影,爱奇艺
6、 大陆淘宝有得时候需要你又大陆IP才能正常下单

现在可以用MikroTik的router,安装(改firmware)后LAN ports + Wi-Fi port都是大陆的IP,而设备不要安装VPN,接入大陆的IP,即是CN-Gateway,就虚拟地在大陆生活一样!!

本帖最後由 张无忌 於 2025-1-17 19:26 編輯

在香港要上大陆网,有好有大陆公网IP,有朋友公网IP和router有WireGuard,就可以Table 1上网到深圳。如果私网就不行,如果没有你要向阿里云等要买的VPS,然后安装RouterOS,就可以有WireGuard的server,就有下面的参数,你在可以用PC Windows 10,通过WireGuard连深圳上大陆网。

Line 13: abc.xyz.org must be set to real hostname FQDN.

Table 1: PC Windows 10 WireGuard configuration
  1. ########################################
  2. #PC HK-->CN WireGuard Configuration
  3. ########################################
  4. [Interface]
  5. PrivateKey = yJQDHxkppPLTPx+2A54y4AWpcVpO0QLxIYoEsvRq6V0=
  6. Address = 10.2.88.3/32
  7. DNS = 223.5.5.5,119.29.29.29

  8. [Peer]
  9. PublicKey = vtWvAu10T0fVSfJ+X94gmnUPbUP6XTVXEBWtQF5YyHg=
  10. PresharedKey = QD4Z19XNa4bZ67789jeG3FWjOZuEk76sEwmLNzi7c38=
  11. AllowedIPs = 0.0.0.0/0
  12. Endpoint = abc.xyz.org:27051
  13. PersistentKeepalive = 25
複製代碼

TOP

本帖最後由 张无忌 於 2025-1-17 19:39 編輯

下面Table 2只要更改MikroTik router的参数:

1. "admin"的password=Admin-Password
2. 2G SSID=CN-2G, 5G SSID=CN-5G
3. Country="hong kong"
4. WiFi "SSID"=WiFi-Password

你又可以自己亲自手改,不需要理会Table 2。

Table 2: MikroTik initial configuration
  1. #/system reset-configuration
  2. #/system reboot

  3. /password old-password="" new-password=Admin-Password confirm-new-password=Admin-Password

  4. /interface wireless security-profiles
  5.   set number=0 name=default authentication-types=wpa-psk,wpa2-psk mode=dynamic-keys \
  6.   wpa2-pre-shared-key=WiFi-Password  wpa-pre-shared-key=WiFi-Password

  7. /interface wireless set wlan1 ssid=CN-2G country="hong kong" security-profile=default
  8. /interface wireless set wlan2 ssid=CN-5G country="hong kong" security-profile=default

  9. /system reboot
複製代碼

TOP

本帖最後由 张无忌 於 2025-1-16 10:28 編輯

Line 21: abc.xyz.org must be set to real hostname FQDN.

Table 3: MikroTik router configuration
  1. #################################################
  2. # Step One: Wireguard Tunnel Setup
  3. #################################################

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

  6. /interface wireguard
  7. add listen-port=13231 mtu=1420 name=wg-cn private-key=\
  8. "yJQDHxkppPLTPx+2A54y4AWpcVpO0QLxIYoEsvRq6V0=" \
  9. comment="WG CN"

  10. # Assign address to the router on the new interface.
  11. /ip address
  12. add address=10.2.88.3/32 comment="Wireguard" interface=wg-cn \
  13.     network=10.2.88.0

  14. # Set up CN peer
  15. /interface wireguard peers      
  16. add name=cn allowed-address=0.0.0.0/0 comment="cn" \
  17.     endpoint-address=abc.xyz.org endpoint-port=27051 \
  18.     interface=wg-cn public-key=\
  19.     "vtWvAu10T0fVSfJ+X94gmnUPbUP6XTVXEBWtQF5YyHg=" \
  20.     preshared-key="QD4Z19XNa4bZ67789jeG3FWjOZuEk76sEwmLNzi7c38="

  21. #################################################
  22. # Step Two: Routing the Traffic
  23. #################################################

  24. ###############################################
  25. # On HK MikroTik

  26. /routing table
  27. add comment="For use by local clients" disabled=no fib name=wg-vpn

  28. /routing rule
  29. add action=lookup-only-in-table \
  30.     comment="Local clients should use (only) Wireguard routing table" \
  31.     disabled=no interface=bridge src-address=192.168.88.0/24 table=wg-vpn

  32. /ip route
  33. add dst-address=0.0.0.0/0 gateway=wg-cn routing-table=wg-vpn

  34. /ip firewall nat \
  35. add chain=srcnat out-interface=wg-cn action=masquerade

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

  37. #################################################
  38. # Step Three: DNS
  39. #################################################

  40. # On China MikroTik
  41. /ip dns
  42. set allow-remote-requests=yes servers=223.5.5.5,119.29.29.29

  43. /ip dhcp-server network
  44. set 0 dns-server=223.5.5.5,119.29.29.29

  45. #must reboot once
  46. # /system reboot

  47. #################################################
  48. # Step Four
  49. #################################################

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

  53. /system reboot
複製代碼
上面说明可以在 https://www.hkepc.com/forum/viewthread.php?fid=12&tid=2736880

TOP

如果香港有房子,而安装宽频Internet,但是大部分是private IP,那怎么办?如果是public IP就简单,现在private IP!

可能在大陆家里先用WireGuard连香港,然后香港电脑连大陆(通过前面WireGuard),但是具体怎么弄?

TOP

备用

TOP