@usex/mikrotik-mcp 4.7.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -28
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/shared/{cli-38m6waxx.js → cli-s2s6hryh.js} +4689 -3226
- package/dist/shared/{cli-jd7xqp2f.js → cli-xfa5x65h.js} +1 -1
- package/dist/shared/{library-31wz8hdh.js → library-6zh75zhp.js} +1 -1
- package/dist/shared/{library-fs4nps73.js → library-wm3vc8kq.js} +4689 -3226
- package/package.json +1 -1
- package/prompts/security-hardening-sweep.md +132 -0
- package/prompts/setup-eoip-tunnel-between-sites.md +119 -0
- package/prompts/setup-gre-tunnel-between-sites.md +163 -0
- package/prompts/setup-ipip-tunnel-between-sites.md +110 -0
- package/prompts/setup-openvpn-tunnel-between-sites.md +136 -0
- package/prompts/setup-sstp-tunnel-between-sites.md +136 -0
- package/prompts/setup-tunnel-between-sites.md +55 -8
- package/prompts/setup-v2ray-container-proxy.md +203 -0
- package/prompts/setup-vxlan-tunnel-between-sites.md +129 -0
- package/prompts/setup-wireguard-tunnel-between-sites.md +183 -0
- package/schemas/README.md +1 -1
- package/schemas/tool-catalog.json +658 -2
- package/schemas/tools/add_firewall_default_deny.json +25 -0
- package/schemas/tools/apply_security_hardening_fixes.json +25 -0
- package/schemas/tools/audit_account_hygiene.json +7 -0
- package/schemas/tools/audit_address_list_enforcement.json +7 -0
- package/schemas/tools/audit_certificate_hygiene.json +7 -0
- package/schemas/tools/audit_connection_tracking_helpers.json +7 -0
- package/schemas/tools/audit_dns_resolver_exposure.json +7 -0
- package/schemas/tools/audit_firewall_default_deny.json +7 -0
- package/schemas/tools/audit_ip_service_exposure.json +7 -0
- package/schemas/tools/audit_ipv6_firewall_baseline.json +7 -0
- package/schemas/tools/audit_kernel_ip_hardening.json +7 -0
- package/schemas/tools/audit_management_plane_exposure.json +7 -0
- package/schemas/tools/audit_network_segmentation.json +7 -0
- package/schemas/tools/audit_ssh_hardening.json +7 -0
- package/schemas/tools/bootstrap_ipv6_firewall_baseline.json +25 -0
- package/schemas/tools/enforce_address_list_blocking.json +25 -0
- package/schemas/tools/fix_certificate_crl_policy.json +25 -0
- package/schemas/tools/fix_password_policy.json +25 -0
- package/schemas/tools/harden_connection_tracking_helpers.json +25 -0
- package/schemas/tools/harden_dns_resolver_exposure.json +25 -0
- package/schemas/tools/harden_ip_service_exposure.json +25 -0
- package/schemas/tools/harden_kernel_ip_settings.json +25 -0
- package/schemas/tools/harden_management_plane_exposure.json +25 -0
- package/schemas/tools/harden_ssh_service.json +25 -0
- package/schemas/tools/run_security_hardening_audit.json +29 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-openvpn-tunnel-between-sites
|
|
3
|
+
title: Build an OpenVPN (TLS) tunnel between two MikroTik devices
|
|
4
|
+
description: Configure a MikroTik-to-MikroTik OpenVPN site-to-site link — certificates, PPP profile + secret, server + client, L3 (ip) or L2 (ethernet) mode, routing, firewall — over TCP/UDP 443 for HTTPS-like camouflage. Verified end to end, with DPI/censorship-bypass guidance.
|
|
5
|
+
arguments:
|
|
6
|
+
- name: server_device
|
|
7
|
+
description: The device that will run the OpenVPN SERVER — reachable public IP/DDNS + a certificate. Config key or label from list_mikrotik_devices.
|
|
8
|
+
required: false
|
|
9
|
+
- name: client_device
|
|
10
|
+
description: The device that will run the OpenVPN CLIENT (may be behind NAT). Config key or label.
|
|
11
|
+
required: false
|
|
12
|
+
- name: mode
|
|
13
|
+
description: Tunnel mode — "ip" (L3 routed, default) or "ethernet" (L2 TAP, bridgeable across sites). Omit for ip.
|
|
14
|
+
required: false
|
|
15
|
+
- name: protocol
|
|
16
|
+
description: Transport — "tcp" (works with 443 camouflage, survives more DPI) or "udp" (faster). Omit for tcp when bypassing blocks, udp otherwise.
|
|
17
|
+
required: false
|
|
18
|
+
- name: port
|
|
19
|
+
description: Port for OpenVPN. 1194 is default; use 443 to look like HTTPS through restrictive networks. Omit for 1194.
|
|
20
|
+
required: false
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
You are building an **OpenVPN site-to-site tunnel between two MikroTik routers**.
|
|
24
|
+
OpenVPN is a mature TLS VPN: it can be **L3 routed (`mode=ip`)** or **L2 bridgeable
|
|
25
|
+
(`mode=ethernet`/TAP)**, over **TCP or UDP**, and on **any port** — running it on
|
|
26
|
+
**TCP 443** makes it look like HTTPS, a strong DPI-bypass option (a different TLS
|
|
27
|
+
fingerprint than SSTP). It is client↔server: one device is the **server** (reachable
|
|
28
|
+
endpoint + certificate), the other the **client** (NAT-friendly). Drive both via the
|
|
29
|
+
`device` argument. Confirm before writing — this touches certificates, PPP, and the
|
|
30
|
+
firewall.
|
|
31
|
+
|
|
32
|
+
Server device: {{server_device}}
|
|
33
|
+
Client device: {{client_device}}
|
|
34
|
+
Mode: {{mode}}
|
|
35
|
+
Protocol: {{protocol}}
|
|
36
|
+
Port: {{port}}
|
|
37
|
+
|
|
38
|
+
## 0. Discover and assign roles (FIRST)
|
|
39
|
+
|
|
40
|
+
- `list_mikrotik_devices`; resolve {{server_device}}/{{client_device}} — never
|
|
41
|
+
substitute a similar name; ask which is which if omitted.
|
|
42
|
+
- The **server** must be reachable on the chosen `port`/`protocol` (static WAN or
|
|
43
|
+
DDNS). The **client** only needs outbound reach. Confirm roles.
|
|
44
|
+
- Choose `mode`: **ip** for routed site-to-site (recommended default — cleaner,
|
|
45
|
+
faster); **ethernet** only if the user needs a stretched L2 domain (then bridge the
|
|
46
|
+
interface at both ends, with the same STP / single-DHCP warnings as EoIP/VXLAN).
|
|
47
|
+
|
|
48
|
+
## 1. Facts (read-only, per device)
|
|
49
|
+
|
|
50
|
+
Per side: `get_system_identity`, `list_ip_addresses`, `get_routing_table`,
|
|
51
|
+
`get_ip_cloud`, and on the server `list_certificates`. Record server public
|
|
52
|
+
address/DDNS, LAN subnets (must not overlap for `mode=ip`), and existing certs.
|
|
53
|
+
|
|
54
|
+
## 2. Certificates
|
|
55
|
+
|
|
56
|
+
OpenVPN needs a server certificate; with `require_client_certificate=true` it also
|
|
57
|
+
needs a client cert (recommended — stronger than username/password alone):
|
|
58
|
+
|
|
59
|
+
- If absent: `create_certificate` a CA → `sign_certificate` (self-signed); then a
|
|
60
|
+
**server** cert (CN=server address) and a **client** cert, each `sign_certificate`
|
|
61
|
+
by the CA.
|
|
62
|
+
- `import_certificate` the CA (and client cert) onto the client. RouterOS OpenVPN
|
|
63
|
+
historically wants explicit certs on both ends — plan for it rather than relying on
|
|
64
|
+
username/password only.
|
|
65
|
+
|
|
66
|
+
## 3. PPP profile + secret (server side)
|
|
67
|
+
|
|
68
|
+
- `create_ppp_profile` — `local-address`=server tunnel IP, `remote-address`=client
|
|
69
|
+
tunnel IP or pool; optional DNS/routes.
|
|
70
|
+
- `create_ppp_secret` — strong `name`/`password`, `service=ovpn`, `profile`=above.
|
|
71
|
+
|
|
72
|
+
## 4. Enable the OpenVPN server (server side)
|
|
73
|
+
|
|
74
|
+
`add_ovpn_server` (`device={{server_device}}`) — `name`=`ovpn-srv`, `port`={{port}}
|
|
75
|
+
or (443 for camouflage / 1194 default), `protocol`={{protocol}} or tcp,
|
|
76
|
+
`mode`={{mode}} or ip, `certificate`=<server cert>, `require_client_certificate=true`,
|
|
77
|
+
`auth=sha256`, `cipher=aes256-gcm,aes256-cbc`, `tls_version=only-1.2`,
|
|
78
|
+
`default_profile`=the profile, `enabled` (or `enable_ovpn_server`). Strong cipher +
|
|
79
|
+
TLS 1.2 both hardens and looks like modern HTTPS.
|
|
80
|
+
|
|
81
|
+
## 5. Client (client side)
|
|
82
|
+
|
|
83
|
+
`create_ovpn_client` (`device={{client_device}}`) — `name`=`ovpn-{{server_device}}`,
|
|
84
|
+
`connect_to`=server public IP/DDNS, `port`={{port}} or match, `protocol`=match,
|
|
85
|
+
`mode`=match, `user`/`password`=the PPP secret, `certificate`=<client cert>,
|
|
86
|
+
`verify_server_certificate=true`, `cipher`/`auth`/`tls_version` matching the server.
|
|
87
|
+
Use `route_nopull=true` if you want to control routing manually (recommended for
|
|
88
|
+
site-to-site), else the server can push routes.
|
|
89
|
+
|
|
90
|
+
## 6. Route (mode=ip) or bridge (mode=ethernet)
|
|
91
|
+
|
|
92
|
+
- **mode=ip:** transit link is up once connected; `add_route` far LAN on each side
|
|
93
|
+
(server→client-LAN, client→server-LAN) via the tunnel interface / transit IP. Or
|
|
94
|
+
push routes from the server profile.
|
|
95
|
+
- **mode=ethernet:** add the OVPN interface as a **bridge port** on each side's LAN
|
|
96
|
+
bridge (one L2 domain) — enable STP, single DHCP authority, watch MTU.
|
|
97
|
+
|
|
98
|
+
## 7. Firewall — safely
|
|
99
|
+
|
|
100
|
+
Under Safe Mode per device: server `input` accept `protocol={{protocol}} (tcp)
|
|
101
|
+
dst-port={{port}}` (443/1194) from the client's source (any if dynamic), high in the
|
|
102
|
+
chain; both sides `forward` allow the two LANs.
|
|
103
|
+
|
|
104
|
+
## 8. MTU / MSS
|
|
105
|
+
|
|
106
|
+
OpenVPN adds notable overhead; TCP mode risks TCP-in-TCP stalls. Set the client
|
|
107
|
+
`max_mtu` conservatively (~1400), clamp MSS on `forward`. UDP mode is faster where
|
|
108
|
+
it isn't blocked; TCP/443 is for reachability.
|
|
109
|
+
|
|
110
|
+
## 9. Verify
|
|
111
|
+
|
|
112
|
+
- Server: `list_ovpn_servers`/`get_ovpn_server` running; the client appears as a
|
|
113
|
+
connected session. Client: `get_ovpn_client` status `connected`, address assigned.
|
|
114
|
+
- `ping` (`device=server`) client tunnel/LAN (with `src_address`=server-LAN), repeat
|
|
115
|
+
from client. For `mode=ethernet`, prove same-subnet L2 reachability + DHCP. Large-
|
|
116
|
+
payload ping to confirm MTU.
|
|
117
|
+
|
|
118
|
+
## Bypassing country / DPI restrictions (legitimate circumvention)
|
|
119
|
+
|
|
120
|
+
Lawful privacy/accessibility only; comply with local law and terms. OpenVPN on
|
|
121
|
+
**TCP 443** presents a TLS session on the HTTPS port — a strong native bypass with a
|
|
122
|
+
**different fingerprint from SSTP**, so it's the natural second option if SSTP is
|
|
123
|
+
blocked. Maximize blend-in: `protocol=tcp`, `port=443`, `tls_version=only-1.2`, AES-
|
|
124
|
+
GCM, valid-looking cert. Note: classic OpenVPN has a recognizable TLS handshake that
|
|
125
|
+
sophisticated DPI (active probing / TLS-fingerprint allow-lists) can still flag —
|
|
126
|
+
if that's the adversary, escalate to **container-based obfuscation** (XRay/VLESS+
|
|
127
|
+
Reality, sing-box, Shadowsocks, obfs4) in a RouterOS `/container` or a VPS (not
|
|
128
|
+
native, heaviest, most robust), or run WireGuard _inside_ this OpenVPN link. Compare
|
|
129
|
+
with `setup-sstp-tunnel-between-sites` and pick the transport the local DPI doesn't
|
|
130
|
+
recognize. Never present obfuscation as a guarantee — it's an arms race.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
Report: certs used, PPP profile/secret, server + client settings (mode/protocol/port),
|
|
135
|
+
routing or bridging, firewall added, MTU/MSS, verification results. State which device
|
|
136
|
+
each change ran on. Never apply changes the user hasn't approved.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-sstp-tunnel-between-sites
|
|
3
|
+
title: Build an SSTP (TLS/443) tunnel between two MikroTik devices
|
|
4
|
+
description: Configure a MikroTik-to-MikroTik SSTP site-to-site link — server certificate, PPP profile + secret, client, routing, firewall — over TCP 443 so it looks like HTTPS. The go-to transport for bypassing VPN blocks / DPI. Verified end to end.
|
|
5
|
+
arguments:
|
|
6
|
+
- name: server_device
|
|
7
|
+
description: The device that will run the SSTP SERVER — the one with a reachable public IP / DDNS and (ideally) a certificate. Config key or label from list_mikrotik_devices.
|
|
8
|
+
required: false
|
|
9
|
+
- name: client_device
|
|
10
|
+
description: The device that will run the SSTP CLIENT (may be behind NAT). Config key or label.
|
|
11
|
+
required: false
|
|
12
|
+
- name: tunnel_subnet
|
|
13
|
+
description: Transit subnet for the PPP link, e.g. 10.255.255.0/30 (server=.1 local, client=.2 remote). Omit to let you pick one that collides with neither LAN.
|
|
14
|
+
required: false
|
|
15
|
+
- name: port
|
|
16
|
+
description: TCP port for SSTP. Default and recommended 443 (looks like HTTPS, survives most DPI). Omit for 443.
|
|
17
|
+
required: false
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
You are building an **SSTP site-to-site tunnel between two MikroTik routers**. SSTP
|
|
21
|
+
is **PPP inside TLS over TCP (default 443)** — on the wire it is nearly
|
|
22
|
+
indistinguishable from an HTTPS session, which makes it the **best native RouterOS
|
|
23
|
+
choice for bypassing VPN blocks and DPI**. It is client↔server (asymmetric): one
|
|
24
|
+
device is the **server** (needs a reachable endpoint + a TLS certificate), the other
|
|
25
|
+
is the **client** (can be behind NAT). Drive both via the `device` argument. This
|
|
26
|
+
touches certificates, PPP, and the firewall — go carefully and confirm before writing.
|
|
27
|
+
|
|
28
|
+
Server device: {{server_device}}
|
|
29
|
+
Client device: {{client_device}}
|
|
30
|
+
Transit subnet: {{tunnel_subnet}}
|
|
31
|
+
Port: {{port}}
|
|
32
|
+
|
|
33
|
+
## 0. Discover and assign roles (FIRST)
|
|
34
|
+
|
|
35
|
+
- `list_mikrotik_devices`; resolve {{server_device}}/{{client_device}} — never
|
|
36
|
+
substitute a similar name; ask which is which if omitted.
|
|
37
|
+
- The **server** must be reachable on the chosen TCP `port` (static WAN or DDNS via
|
|
38
|
+
`/ip cloud`). The **client** only needs outbound TCP to that port — NAT-friendly.
|
|
39
|
+
Confirm roles with the user before proceeding.
|
|
40
|
+
|
|
41
|
+
## 1. Facts (read-only, per device)
|
|
42
|
+
|
|
43
|
+
Per side (`device=<name>`): `get_system_identity`, `list_ip_addresses`,
|
|
44
|
+
`get_routing_table`, `get_ip_cloud`, and on the server `list_certificates`. Record
|
|
45
|
+
the server's public address/DDNS, each LAN subnet (must not overlap), and whether a
|
|
46
|
+
usable server certificate already exists.
|
|
47
|
+
|
|
48
|
+
## 2. Server certificate (server side)
|
|
49
|
+
|
|
50
|
+
SSTP requires a TLS certificate on the server. If none exists:
|
|
51
|
+
|
|
52
|
+
- `create_certificate` a local CA, then `create_certificate` a server cert (common-
|
|
53
|
+
name = the server's public IP/DDNS the client will connect to), `sign_certificate`
|
|
54
|
+
both (CA self-signed, server signed by the CA). Note the server cert name.
|
|
55
|
+
- The client should trust that CA: either `import_certificate` the CA on the client,
|
|
56
|
+
or set the client's `verify_server_certificate=false` (simpler, but skips
|
|
57
|
+
authenticity — acceptable only if the PSK-like PPP credentials are strong; state
|
|
58
|
+
the trade-off). A publicly-trusted (Let's Encrypt) cert avoids this — see
|
|
59
|
+
`manage-certificates`.
|
|
60
|
+
|
|
61
|
+
## 3. PPP profile + secret (server side)
|
|
62
|
+
|
|
63
|
+
- `create_ppp_profile` — set `local-address`=server transit IP (e.g. `10.255.255.1`),
|
|
64
|
+
`remote-address`=client transit IP (e.g. `10.255.255.2`) or a small pool. Optionally
|
|
65
|
+
set DNS. This profile defines the tunnel's L3 endpoints.
|
|
66
|
+
- `create_ppp_secret` — `name`/`password` (strong), `service=sstp`, `profile`=the
|
|
67
|
+
profile above. These are the client's login credentials.
|
|
68
|
+
|
|
69
|
+
## 4. Enable the SSTP server (server side)
|
|
70
|
+
|
|
71
|
+
`set_sstp_server` (`device={{server_device}}`) — `enabled=true`,
|
|
72
|
+
`certificate`=<server cert>, `port`={{port}} or 443, `default_profile`=the profile,
|
|
73
|
+
`authentication=mschap2` (drop weaker methods), `tls_version=only-1.2`, `pfs=true`,
|
|
74
|
+
`force_aes=true`. Strong ciphers + TLS 1.2-only both hardens and makes the flow look
|
|
75
|
+
like modern HTTPS.
|
|
76
|
+
|
|
77
|
+
## 5. Client (client side)
|
|
78
|
+
|
|
79
|
+
`create_sstp_client` (`device={{client_device}}`) — `name`=`sstp-{{server_device}}`,
|
|
80
|
+
`connect_to`/server address = the server's public IP/DDNS, `port`={{port}} or 443,
|
|
81
|
+
`user`/`password` = the PPP secret from step 3, `verify_server_certificate` per step 2,
|
|
82
|
+
`tls_version=only-1.2`, `pfs=true`, `authentication=mschap2`. The client auto-creates
|
|
83
|
+
the PPP interface and gets the transit `remote-address`.
|
|
84
|
+
|
|
85
|
+
## 6. Route each far LAN
|
|
86
|
+
|
|
87
|
+
The transit /30 is connected once the PPP link is up. Add routes for the far LANs:
|
|
88
|
+
|
|
89
|
+
- On the server: `add_route` dst=client-LAN gw=the client's transit IP (or the
|
|
90
|
+
dynamic SSTP interface).
|
|
91
|
+
- On the client: `add_route` dst=server-LAN gw=the server's transit IP (or the SSTP
|
|
92
|
+
interface). Or push routes via the PPP profile.
|
|
93
|
+
|
|
94
|
+
## 7. Firewall — safely
|
|
95
|
+
|
|
96
|
+
Under Safe Mode per device (`enable_safe_mode`→edits→verify→`commit_safe_mode`):
|
|
97
|
+
|
|
98
|
+
- Server `input`: accept `protocol=tcp dst-port={{port}}` (443) from anywhere the
|
|
99
|
+
client may source from (dynamic clients ⇒ from any), placed above any default drop.
|
|
100
|
+
- Both sides `forward`: allow the two LANs both directions.
|
|
101
|
+
|
|
102
|
+
## 8. MTU / MSS
|
|
103
|
+
|
|
104
|
+
SSTP over TCP/TLS adds overhead and is prone to TCP-in-TCP meltdown on lossy links.
|
|
105
|
+
Set the client `max_mtu`/`max_mru` conservatively (~1400) and clamp MSS on `forward`.
|
|
106
|
+
Prefer this transport for _reachability_, not raw throughput.
|
|
107
|
+
|
|
108
|
+
## 9. Verify
|
|
109
|
+
|
|
110
|
+
- Server: `get_sstp_server` enabled; check active PPP (the client should appear as a
|
|
111
|
+
connected session). Client: `get_sstp_client` — status `connected`, transit IP
|
|
112
|
+
assigned.
|
|
113
|
+
- `ping` (`device=server`) the client transit IP then a client-LAN host with
|
|
114
|
+
`src_address`=server-LAN IP; repeat from the client. `traceroute` if a path is off.
|
|
115
|
+
|
|
116
|
+
## Why this is the bypass workhorse (legitimate circumvention)
|
|
117
|
+
|
|
118
|
+
Lawful privacy/accessibility only; comply with local law and terms. SSTP on TCP 443
|
|
119
|
+
**is** the DPI-bypass technique for native RouterOS — it presents as a standard TLS
|
|
120
|
+
session to a common HTTPS port, so it passes most "block VPN protocols" filters that
|
|
121
|
+
stop WireGuard/IKE/GRE. To maximize blend-in: keep `port=443`, `tls_version=only-1.2`,
|
|
122
|
+
strong AES + PFS, and a certificate with a plausible CN. If SSTP itself is
|
|
123
|
+
fingerprinted/blocked (active probing, TLS-fingerprint allow-lists), escalate to:
|
|
124
|
+
**OpenVPN TCP/443** (`setup-openvpn-tunnel-between-sites`) for a different TLS
|
|
125
|
+
signature, or **container-based obfuscation** (XRay/VLESS+Reality, sing-box,
|
|
126
|
+
Shadowsocks, obfs4) run in a RouterOS `/container` or a VPS — not native, heaviest,
|
|
127
|
+
most robust. You can also run WireGuard _inside_ this SSTP link so the WG handshake
|
|
128
|
+
never touches the open internet. Never present obfuscation as a guarantee — it's an
|
|
129
|
+
arms race.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
Report: server cert used, PPP profile/secret, server settings, client status, routes
|
|
134
|
+
|
|
135
|
+
- firewall added, MTU/MSS, verification results. State which device each change ran
|
|
136
|
+
on. Never apply changes the user hasn't approved.
|
|
@@ -4,19 +4,29 @@ title: Build a tunnel between two MikroTik devices
|
|
|
4
4
|
description: Configure BOTH routers of a site-to-site tunnel from one conversation, then verify it end to end.
|
|
5
5
|
arguments:
|
|
6
6
|
- name: device_a
|
|
7
|
-
description:
|
|
8
|
-
required:
|
|
7
|
+
description: First configured device (config key or label from list_mikrotik_devices), e.g. site-a. Omit to discover and choose.
|
|
8
|
+
required: false
|
|
9
9
|
- name: device_b
|
|
10
|
-
description:
|
|
11
|
-
required:
|
|
10
|
+
description: Second configured device, e.g. site-b. Omit to discover and choose.
|
|
11
|
+
required: false
|
|
12
12
|
- name: technology
|
|
13
|
-
description: Tunnel type
|
|
13
|
+
description: Tunnel type — wireguard, ipsec, gre, ipip, eoip, vxlan, sstp, ovpn, or "recommend" to let you choose. For a deep, tech-specific walkthrough use setup-wireguard-tunnel-between-sites or setup-gre-tunnel-between-sites.
|
|
14
14
|
required: false
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
You are configuring a **site-to-site tunnel between two MikroTik routers** that
|
|
18
18
|
this server can both reach. You will drive BOTH devices in one flow by passing
|
|
19
|
-
the `device` argument on each tool call.
|
|
19
|
+
the `device` argument on each tool call. This is the general chooser-and-builder;
|
|
20
|
+
for a detailed, tech-specific flow prefer the dedicated per-technology prompts,
|
|
21
|
+
which cover keys/certs, MTU/MSS, and DPI-bypass transports in depth:
|
|
22
|
+
**`setup-wireguard-tunnel-between-sites`** (WireGuard),
|
|
23
|
+
**`setup-gre-tunnel-between-sites`** (GRE + IPsec),
|
|
24
|
+
**`setup-ipip-tunnel-between-sites`** (IP-in-IP),
|
|
25
|
+
**`setup-eoip-tunnel-between-sites`** (L2 bridgeable),
|
|
26
|
+
**`setup-vxlan-tunnel-between-sites`** (L2 overlay / multipoint),
|
|
27
|
+
**`setup-ipsec-site-to-site`** (IKEv2 policy-based),
|
|
28
|
+
**`setup-sstp-tunnel-between-sites`** and
|
|
29
|
+
**`setup-openvpn-tunnel-between-sites`** (TLS/443 — the bypass workhorses).
|
|
20
30
|
|
|
21
31
|
Device A: {{device_a}}
|
|
22
32
|
Device B: {{device_b}}
|
|
@@ -24,6 +34,13 @@ Requested technology: {{technology}}
|
|
|
24
34
|
|
|
25
35
|
Work in this order, confirming the plan before any change:
|
|
26
36
|
|
|
37
|
+
0. **Discover both endpoints.** Call `list_mikrotik_devices` first and resolve
|
|
38
|
+
{{device_a}} / {{device_b}} against it — never substitute a similar name (these
|
|
39
|
+
are different physical routers). If either was omitted, ask which two devices to
|
|
40
|
+
connect. Note which side (if any) has a reachable public endpoint vs. is behind
|
|
41
|
+
NAT — if **both** are behind NAT with no forward, a direct tunnel can't form
|
|
42
|
+
(use a reachable side or a relay/VPS).
|
|
43
|
+
|
|
27
44
|
1. **Inventory both ends.** Call `list_mikrotik_devices` first. Then, for each of
|
|
28
45
|
{{device_a}} and {{device_b}}, gather facts with `device=<name>`:
|
|
29
46
|
`get_system_identity`, `list_interfaces`, `list_ip_addresses`,
|
|
@@ -48,10 +65,40 @@ Work in this order, confirming the plan before any change:
|
|
|
48
65
|
(`device=<name>`) per device before firewall edits, verify, then
|
|
49
66
|
`commit_safe_mode` — Safe Mode is tracked per device, so each router commits
|
|
50
67
|
independently.
|
|
51
|
-
5. **
|
|
68
|
+
5. **MTU / MSS.** Every tunnel shrinks the usable MTU (WireGuard ~60 B, GRE 24 B,
|
|
69
|
+
GRE+IPsec ~70+ B), so small pings pass but large TLS/file flows stall. Set the
|
|
70
|
+
tunnel interface MTU accordingly (WG 1420, GRE 1476, lower on PPPoE / when also
|
|
71
|
+
IPsec-wrapped) and clamp TCP MSS (`clamp-tcp-mss` on the tunnel, or a `forward`
|
|
72
|
+
mangle `change-mss new-mss=clamp-to-pmtu tcp-flags=syn`). Confirm non-overlapping
|
|
73
|
+
LANs before routing — overlap makes the far route ambiguous.
|
|
74
|
+
6. **Verify end to end.** From {{device_a}} run `ping` (`device={{device_a}}`) to
|
|
52
75
|
the far tunnel address and a host in B's LAN (set `src_address` to A's LAN IP);
|
|
53
76
|
repeat from {{device_b}}. For IPsec, check `get_ipsec_active_peers` on both.
|
|
54
|
-
|
|
77
|
+
Test a large payload (ping size 1400, do-not-fragment) to catch MTU issues. Use
|
|
78
|
+
`traceroute` if a path is wrong.
|
|
79
|
+
|
|
80
|
+
## Bypassing country / DPI restrictions (legitimate censorship circumvention)
|
|
81
|
+
|
|
82
|
+
For lawful privacy / accessibility on networks you're authorized to use — comply
|
|
83
|
+
with local law and service terms. Escalate only as far as the block requires:
|
|
84
|
+
|
|
85
|
+
- **Port camouflage** — run the encrypted tunnel on a rarely-filtered port (UDP/443
|
|
86
|
+
for WireGuard, UDP 4500 for IPsec NAT-T). Cheapest; hides the port, not the
|
|
87
|
+
handshake.
|
|
88
|
+
- **TLS-looking transport** — where DPI fingerprints WireGuard/IKE, wrap the routed
|
|
89
|
+
tunnel in **SSTP** (PPP-over-TLS, TCP 443 — looks like HTTPS) or **OpenVPN TCP/443**
|
|
90
|
+
(`create_sstp_client` / `create_ovpn_client`) and route the far LANs over that, or
|
|
91
|
+
run WG/GRE inside it. Trades throughput for reachability.
|
|
92
|
+
- **Alternate fingerprint** — if one protocol is specifically blocked, switch: WG↔
|
|
93
|
+
IKEv2↔SSTP present different signatures on the wire.
|
|
94
|
+
- **Container-based obfuscation (advanced)** — the strongest anti-DPI tools
|
|
95
|
+
(XRay/VLESS+Reality, sing-box, Shadowsocks, obfs4) are **not native** to RouterOS;
|
|
96
|
+
run one in a **`/container`** or on a VPS you control and route the site tunnel
|
|
97
|
+
through it. Confirm container support and spare resources first.
|
|
98
|
+
|
|
99
|
+
Recommend the lightest option that works; never present obfuscation as a guarantee.
|
|
100
|
+
The dedicated `setup-wireguard-tunnel-between-sites` and
|
|
101
|
+
`setup-gre-tunnel-between-sites` prompts cover these transports in more depth.
|
|
55
102
|
|
|
56
103
|
Report the tunnel parameters used on each side, the verification results, and any
|
|
57
104
|
follow-ups (e.g. routes still needed). Never apply changes the user hasn't approved.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-v2ray-container-proxy
|
|
3
|
+
title: Run V2Ray/Xray (VLESS·Reality·VMess·Trojan·Shadowsocks) in a MikroTik container and route traffic through it
|
|
4
|
+
description: Deploy an Xray / V2Ray / sing-box client inside a RouterOS /container, wire its VETH into the router, and selectively (or fully) route LAN traffic through the encrypted VLESS-Reality / VMess / Trojan / Shadowsocks / Hysteria tunnel — with device-mode, disk, MTU, DNS-leak and kill-switch handling. For lawful privacy / censorship circumvention on networks you are authorized to use.
|
|
5
|
+
arguments:
|
|
6
|
+
- name: device
|
|
7
|
+
description: Which configured MikroTik to run the proxy container on (config key or label from list_mikrotik_devices). Omit to discover and choose.
|
|
8
|
+
required: false
|
|
9
|
+
- name: protocol
|
|
10
|
+
description: V2Ray-family protocol the tunnel will use — vless-reality (recommended), vless-vision, vmess, trojan, shadowsocks, or (sing-box) hysteria2/tuic. This is configured INSIDE the container image, not on RouterOS.
|
|
11
|
+
required: false
|
|
12
|
+
- name: image
|
|
13
|
+
description: Container image to run (e.g. gritsenko/xray-mikrotik:latest, or a sing-box image). Omit to let you recommend one matching the device architecture and chosen protocol.
|
|
14
|
+
required: false
|
|
15
|
+
- name: scope
|
|
16
|
+
description: What to route through the tunnel — "selective" (only domains/IPs on an address-list, default and recommended) or "all" (default route via the tunnel, with a kill-switch).
|
|
17
|
+
required: false
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
You are deploying a **V2Ray / Xray-core (or sing-box) client inside a MikroTik
|
|
21
|
+
RouterOS `/container`** and routing LAN traffic through its encrypted tunnel. This
|
|
22
|
+
is the _native-RouterOS_ way to run the modern censorship-resistant protocols —
|
|
23
|
+
**VLESS (+Vision/XTLS), VLESS + Reality, VMess, Trojan, Shadowsocks**, and (with a
|
|
24
|
+
sing-box image) **Hysteria2 / TUIC** — that RouterOS has no built-in support for.
|
|
25
|
+
The router runs the client; a remote V2Ray/Xray **server (a VPS you control)** is
|
|
26
|
+
the other end. This flow configures the RouterOS side; the tunnel's crypto
|
|
27
|
+
parameters live in the container image's config/env.
|
|
28
|
+
|
|
29
|
+
**Legality & scope.** This is for **lawful privacy and accessibility** on networks
|
|
30
|
+
and services you are authorized to use — comply with local law and provider terms.
|
|
31
|
+
Confirm the user understands this before proceeding. Treat the remote server
|
|
32
|
+
address, UUIDs, keys and short-ids as **secrets** — never log or echo them back in
|
|
33
|
+
full; mask them in your reports.
|
|
34
|
+
|
|
35
|
+
Target device: {{device}}
|
|
36
|
+
Protocol: {{protocol}}
|
|
37
|
+
Image: {{image}}
|
|
38
|
+
Routing scope: {{scope}}
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 0. Discover the device and confirm it CAN run containers (do this FIRST)
|
|
43
|
+
|
|
44
|
+
- Call `list_mikrotik_devices`; resolve `{{device}}` (never substitute a similar
|
|
45
|
+
name). If omitted, present the inventory and ask which router. Pass `device=` on
|
|
46
|
+
every subsequent call.
|
|
47
|
+
- **Prerequisite check (read-only)** — containers have hard requirements; verify all
|
|
48
|
+
before proposing changes:
|
|
49
|
+
- `get_system_resources` (`device=<name>`) — confirm **architecture** is `arm`,
|
|
50
|
+
`arm64`, or `x86` (**MIPS/SMIPS cannot run containers** — stop and say so), and
|
|
51
|
+
that there is spare **RAM/CPU**.
|
|
52
|
+
- `list_containers` — if it errors, the **`container` package isn't installed**.
|
|
53
|
+
- Confirm an **external disk** (USB/NVMe, ext4) exists for the container root-dir —
|
|
54
|
+
running container images off internal flash wears it out fast. Check with
|
|
55
|
+
`run_routeros_command` `/disk print`.
|
|
56
|
+
- **Two prerequisites need out-of-band action — flag, do NOT silently attempt:**
|
|
57
|
+
1. **device-mode = container=yes.** Enabling it (`/system/device-mode/update
|
|
58
|
+
mode=advanced container=yes`) requires **physical confirmation** (press the
|
|
59
|
+
reset button or power-cycle within the timeout). You cannot complete this
|
|
60
|
+
remotely — tell the user they must do the physical step.
|
|
61
|
+
2. **Installing the `container` package** requires uploading the `.npk` and
|
|
62
|
+
`/system/package/apply-changes` (7.18+) which **reboots** the router. Get
|
|
63
|
+
explicit approval; note the device will drop offline during reboot.
|
|
64
|
+
|
|
65
|
+
Do not proceed to container creation until architecture, disk, package, and
|
|
66
|
+
device-mode are all satisfied.
|
|
67
|
+
|
|
68
|
+
## 1. Choose image and protocol
|
|
69
|
+
|
|
70
|
+
- **Protocol** (`{{protocol}}`): recommend **VLESS + Reality** as the default —
|
|
71
|
+
Reality forges the TLS handshake of a real public site (no certificate to obtain,
|
|
72
|
+
no domain to burn, strongest anti-DPI of the family). VLESS+Vision/XTLS, VMess,
|
|
73
|
+
Trojan, and Shadowsocks are alternatives; sing-box images add Hysteria2/TUIC
|
|
74
|
+
(QUIC-based, good on lossy/throttled links). The choice is realised in the
|
|
75
|
+
container's config — RouterOS just carries the encapsulated traffic.
|
|
76
|
+
- **Image** (`{{image}}`): pick one matching the device architecture (map:
|
|
77
|
+
`arm→linux/arm/v7`, `arm64→linux/arm64`, `x86→linux/amd64`). Community images
|
|
78
|
+
(e.g. `gritsenko/xray-mikrotik`) bundle **xray-core + tun2socks** so the
|
|
79
|
+
container's VETH acts directly as a routable gateway — simplest. Otherwise the
|
|
80
|
+
**two-container** pattern (below) is the general form. **Read the specific image's
|
|
81
|
+
README for its exact env-var names** — they differ per image; do not assume.
|
|
82
|
+
- **RouterOS local-import caveat:** `add_container remote_image=` pulls from a
|
|
83
|
+
registry (needs `set_container_config registry-url=... tmpdir=disk1/pull` and
|
|
84
|
+
internet). A local `.tar` must be **single-layer, uncompressed, Docker-v1** — most
|
|
85
|
+
people pull from a registry.
|
|
86
|
+
|
|
87
|
+
## 2. Two deployment shapes (pick one, explain to the user)
|
|
88
|
+
|
|
89
|
+
**A — All-in-one image (recommended, simplest).** One container running xray-core +
|
|
90
|
+
tun2socks. Its VETH IP becomes the gateway you route through. Example env schema
|
|
91
|
+
(gritsenko/xray-mikrotik — verify against the image):
|
|
92
|
+
`SERVER_ADDRESS`, `SERVER_PORT`, `USER_ID`, `ENCRYPTION`, `FINGERPRINT_FP`,
|
|
93
|
+
`SERVER_NAME_SNI`, `PUBLIC_KEY_PBK`, `SHORT_ID_SID`.
|
|
94
|
+
|
|
95
|
+
**B — Two-container (general, more control).** Container 1 = xray-core exposing a
|
|
96
|
+
**SOCKS5** inbound (e.g. `172.17.0.2:1080`); Container 2 = **tun2socks /
|
|
97
|
+
hev-socks5-tunnel** turning that SOCKS5 into a routable gateway on its own VETH.
|
|
98
|
+
Typical env — xray: `REMOTE_ADDRESS,REMOTE_PORT,ID,FLOW,PUBLIC_KEY,SHORT_ID,
|
|
99
|
+
SERVER_NAME`; tun: `SOCKS5_ADDR=172.17.0.2,SOCKS5_PORT=1080,LOCAL_ROUTE` (so LAN
|
|
100
|
+
subnets return via the router, not the tunnel). _Note: original tun2socks has arm64
|
|
101
|
+
issues — use an arm64-built image._
|
|
102
|
+
|
|
103
|
+
## 3. Container networking (VETH + NAT + DNS)
|
|
104
|
+
|
|
105
|
+
There is **no dedicated VETH tool** — create it with `run_routeros_command`
|
|
106
|
+
(approve each raw command). Example for shape A on a /30:
|
|
107
|
+
|
|
108
|
+
- `/interface veth add name=veth-xray address=172.18.20.6/30 gateway=172.18.20.5`
|
|
109
|
+
- `add_ip_address` `address=172.18.20.5/30 interface=veth-xray` (router side).
|
|
110
|
+
- `create_nat_rule` `chain=srcnat action=masquerade out-interface=veth-xray` (so the
|
|
111
|
+
container reaches the internet / the remote server).
|
|
112
|
+
- Container `dns` = the router's veth IP (`172.18.20.5`) or a resolver you trust.
|
|
113
|
+
(Shape B: put both VETHs on a `containers` bridge, `172.17.0.1/24` gateway.)
|
|
114
|
+
|
|
115
|
+
## 4. Create and start the container
|
|
116
|
+
|
|
117
|
+
- If pulling from a registry: `set_container_config` `registry-url=https://registry-1.docker.io tmpdir=disk1/pull`.
|
|
118
|
+
- Env vars: either inline via `add_container` `env="SERVER_ADDRESS=...,USER_ID=..."`
|
|
119
|
+
(7.21+) or as a named list with `add_container_env` (`envlists=`). **Mask the
|
|
120
|
+
secret values in anything you print back.**
|
|
121
|
+
- `add_container` (`device=<name>`) — `remote_image={{image}}`, `interface=veth-xray`,
|
|
122
|
+
`root_dir=disk1/xray`, `dns=172.18.20.5`, `logging=yes`, `start_on_boot=yes`,
|
|
123
|
+
`hostname=xray`, and the env.
|
|
124
|
+
- `start_container`; then `get_container` / `list_containers` until it shows
|
|
125
|
+
**running**, and read startup output with the container-log (it must show a
|
|
126
|
+
successful outbound handshake to your server before routing anything through it).
|
|
127
|
+
|
|
128
|
+
## 5. Route traffic through the tunnel
|
|
129
|
+
|
|
130
|
+
**Selective (`scope=selective`, recommended)** — only chosen destinations go through
|
|
131
|
+
the proxy; everything else uses the normal WAN (fast, low-risk, defeats geo-blocks
|
|
132
|
+
for the sites that need it):
|
|
133
|
+
|
|
134
|
+
1. `add_address_list_entry` — build a list `via_proxy` of the domains/IPs to tunnel
|
|
135
|
+
(RouterOS resolves domain entries to IPs automatically).
|
|
136
|
+
2. `add_routing_table` — `name=proxy fib`.
|
|
137
|
+
3. `create_mangle_rule` — `chain=prerouting action=mark-routing
|
|
138
|
+
new-routing-mark=proxy dst-address-list=via_proxy passthrough=no`
|
|
139
|
+
(add `src-address=<LAN>` to scope to LAN clients; exclude the router's own/ the
|
|
140
|
+
container subnet to avoid loops).
|
|
141
|
+
4. `add_route` — `dst-address=0.0.0.0/0 gateway=172.18.20.6 routing-table=proxy`
|
|
142
|
+
(gateway = the container's VETH IP, shape A; the tun container's IP, shape B).
|
|
143
|
+
|
|
144
|
+
**All traffic (`scope=all`)** — default route via the tunnel. Same routing table but
|
|
145
|
+
mark all LAN traffic (or set the container gateway as the main default). **Mandatory
|
|
146
|
+
kill-switch:** add a low-priority `forward` **drop** for the LAN when the tunnel
|
|
147
|
+
interface is down, so a container crash can't silently leak traffic out the clear
|
|
148
|
+
WAN. Also pin a **higher-priority route to the remote server's IP via the real WAN**
|
|
149
|
+
so the tunnel's own packets don't recurse into itself.
|
|
150
|
+
|
|
151
|
+
## 6. DNS-leak & MTU handling
|
|
152
|
+
|
|
153
|
+
- **DNS leaks:** if clients query a public resolver directly, the destination is
|
|
154
|
+
exposed even though the payload is tunnelled. Redirect LAN DNS (dst-nat UDP/TCP 53
|
|
155
|
+
to the router or the container's resolver) so lookups for proxied domains resolve
|
|
156
|
+
through the tunnel, or run the resolver inside/behind the container.
|
|
157
|
+
- **MTU/MSS:** encapsulation shrinks usable MTU — add a `create_mangle_rule`
|
|
158
|
+
`chain=forward action=change-mss new-mss=clamp-to-pmtu tcp-flags=syn` (and/or lower
|
|
159
|
+
the veth MTU). This is the #1 "handshake works, big pages hang" cause.
|
|
160
|
+
|
|
161
|
+
## 7. Firewall — safely
|
|
162
|
+
|
|
163
|
+
Under Safe Mode (`enable_safe_mode` `device=<name>` → edits → verify →
|
|
164
|
+
`commit_safe_mode`): allow the container subnet outbound, keep the masquerade from
|
|
165
|
+
step 3, and (scope=all) install the kill-switch drop. Do not expose the container's
|
|
166
|
+
SOCKS5 port to the WAN.
|
|
167
|
+
|
|
168
|
+
## 8. Verify end to end
|
|
169
|
+
|
|
170
|
+
- `get_container` shows **running**; the container log shows a completed handshake to
|
|
171
|
+
your server (no repeated dial errors).
|
|
172
|
+
- From a **marked** LAN source, check the **egress IP** changed: fetch an "what is my
|
|
173
|
+
IP" service from a proxied client (or `run_routeros_command` a `/tool fetch` bound
|
|
174
|
+
to the proxy path) — it should show the **VPS** IP, not the local WAN IP.
|
|
175
|
+
- Confirm a **non-proxied** destination still exits the normal WAN (selective scope).
|
|
176
|
+
- `ping`/`traceroute` a proxied target; test a large HTTPS page (MTU sanity).
|
|
177
|
+
- Reboot-persistence: `start_on_boot=yes` and the routing rules survive a reboot.
|
|
178
|
+
|
|
179
|
+
## 9. Family notes, hardening & honest caveats
|
|
180
|
+
|
|
181
|
+
- **VLESS + Reality**: no cert/domain needed; set a believable `SERVER_NAME_SNI`
|
|
182
|
+
(a real, unrelated HTTPS site the censor won't block) and matching public-key/
|
|
183
|
+
short-id from the server. Strongest default against active-probing DPI.
|
|
184
|
+
- **VMess/Trojan/Shadowsocks**: pair with TLS/WebSocket/gRPC transports on 443 for
|
|
185
|
+
camouflage; plain Shadowsocks is weaker against modern DPI.
|
|
186
|
+
- **Hysteria2/TUIC** (sing-box image): QUIC/UDP — great on lossy or throttled links,
|
|
187
|
+
but blocked where UDP is throttled.
|
|
188
|
+
- **Trust**: you are running a third-party image with your keys and all your traffic.
|
|
189
|
+
Prefer images you can inspect/build; pin a digest; keep it updated.
|
|
190
|
+
- **Reality/DPI is an arms race** — never present it as a guarantee. Keep a fallback
|
|
191
|
+
(a second protocol/port, or an SSTP/OpenVPN-443 transport per
|
|
192
|
+
`setup-sstp-tunnel-between-sites`).
|
|
193
|
+
- **Resource reality**: containers are RAM/CPU/disk heavy on small routers; on very
|
|
194
|
+
low-end boards run the client on a VPS/box and point the router at it instead.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
Report: device, architecture, image + protocol, VETH/NAT, container status, the
|
|
199
|
+
routing-table + mangle + route rules and the address-list scope, DNS/MTU/kill-switch
|
|
200
|
+
handling, and the verification results (egress-IP proof) — with **all secrets
|
|
201
|
+
masked**, and a note of every `run_routeros_command` step used (VETH, device-mode).
|
|
202
|
+
Flag the physical device-mode step and any reboot explicitly. Never apply changes the
|
|
203
|
+
user hasn't approved.
|