hey thanks, so how do i set this up so resources can be accessed from an Android phone or Windows? If I understand it, I need a config file (public & private keys?) from the clients that I upload and that's it? Then I just hit connect on the client? Can I set up access from specific MAC addresses or would it have to be by IP?wIreguard
depend of the situation.wIreguard
....depend of the situation.wIreguard
Regarding the performance - I will alway go with WG, however if the IPS is blocking the ports, then OVPN is better solution, as no one is blocking 443.
One more note, OVPN interface is exactly the same as physical interface (mac-address), capable for vlans.
It depens on OVPN server mode, ethernet is L2 and ip is L3. It is not clear by OP is this is for site-to-site connection or for connection directly from remote non router clients (aka BTH), in such case ip mode needs to be used if mobile clients needs to be connected because OVPN cliient for moble devices doesn't support ethernet mode.One more note, OVPN interface is exactly the same as physical interface (mac-address), capable for vlans.
Is your OVPN server running on TCP? Wireguard works only on UDP. If such is the case, hotspot is probably allowing only TCP 443 connections.For some reason that will not work.
I've tested today, OVPN does.
i'm connected to public internet(hotspot), where all the ports have been disabled except 443
Sounds like a personal problem, no reason why 443 UDP should not work, unless its a company that restricts ports.......@anav
i was waiting you there.
For some reason that will not work.
I've tested today, OVPN does.
i'm connected to public internet(hotspot), where all the ports have been disabled except 443
For some reason that will not work.
Are you stating that on the same port and with same protocol OpenVPN will work while Wireguard does (sometimes) not?If the IPS is blocking the ports , and even if you play with 443 that will not help to establish connections. Not sure why is that,
/interface/ovpn-server/server export
/interface ovpn-server server
set auth=sha1,sha256 certificate=Server cipher=aes128-cbc default-profile=ovpn enabled=\
yes netmask=22 port=443
So above assumptions regarding different protocols are in use (TCP vs UDP) where correct.protocol (tcp | udp; Default: tcp) Indicates the protocol to use when connecting with the remote endpoint.
/ip firewall nat
add action=dst-nat chain=dstnat dst-port=443 in-interface-list=WAN protocol=tcp to-addresses=192.168.200.6
/interface wireguard
add listen-port=12884 mtu=1300 name=wireguard2 private-key="<wg_priv_key>"
/interface wireguard peers
add allowed-address=192.168.203.2/32 interface=wireguard2 name=peerX public-key="<wg_pub_key>"
[Interface]
PrivateKey = <wg_peer_priv_key>
Address = 192.168.203.2/32
DNS = <my_dns_in_container_or_any...>
MTU = 1300
[Peer]
PublicKey = <wg_peer_pub_key>
AllowedIPs = <ip_range_excluding_server_side_ip>
Endpoint = 127.0.0.1:12884
PersistentKeepalive = 25
Can you add configuration for client side if client is another Mikrotik device?I'm tunneling WG with Xray running in container with this image without modifications. Tunneling is performed over Xray XTLS protocol, a custom TLS (REALITY) with SNI spoofing (from www.microsoft.com in my case). Xray config mostly is taken from here, on this page are more details about how it works and limitations regarding mobile devices for direct connection - in such case RoadWarrior router can be configured for tunneling ROS-to-ROS.
For configs .txt extension is added for .json files to be able to attach.
Server side config - ROS
Xray (in container): xray_config_server.json.txt
File is actually placed in container on path /etc/xray/config.json, and /etc/xray dir. is mounted for presistance.
Nat rule for Xray port forward:
Code: Select all/ip firewall nat add action=dst-nat chain=dstnat dst-port=443 in-interface-list=WAN protocol=tcp to-addresses=192.168.200.6
Wireguard:
ROS firewall, routing and other rules for WG depends on use case, in my case there are no special rules just because of Xray tunnel except that Xray container has access on input chain for UDP 12884 (WG port) for establishing connection to ROS WG, also WG port in such case doesn't need to be open for public access if only over tunnel will be used.Code: Select all/interface wireguard add listen-port=12884 mtu=1300 name=wireguard2 private-key="<wg_priv_key>" /interface wireguard peers add allowed-address=192.168.203.2/32 interface=wireguard2 name=peerX public-key="<wg_pub_key>"
Client side config - MacOS
Xray (cli tool from MacPorts):
xray_config_client.json.txt
Wireguard (App Store app):
Code: Select all[Interface] PrivateKey = <wg_peer_priv_key> Address = 192.168.203.2/32 DNS = <my_dns_in_container_or_any...> MTU = 1300 [Peer] PublicKey = <wg_peer_pub_key> AllowedIPs = <ip_range_excluding_server_side_ip> Endpoint = 127.0.0.1:12884 PersistentKeepalive = 25
When all is configured, first Xray connection needs to be established and tunnel port on localhost (127.0.0.1:12884) on client side will be open, then it is possible to connect WG over it.
If you want connection as regular TLS with own cert/key (no SNI spoof) I can write Xray configs for that...
Finaly found a little time to check this.Unfortunately I don't have ROS device or CHR running on remote site, to do it in local CHR is a bit complicated because I need to create some routing rules on host computer to test routing over CHR running locally, don't have time to play with now...
I can give some tips related to site-to-site client side configuration:
- add Xray container and put client config json at same name and path mentioned as for server setup
- create ROS wireguard client peer configuration based on wg configuration in above post, some notes:
- Address in wg config is Allowed Address in ROS wg peer config
- Endpoint shuld be Xray container IP and Endpoint Port Xray tunnel port (12884 in example)
- AllowedIPs from wg config must be handled with routing rules in ROS (connection to Xray server IP must be excluded from routing over wg)
- add firewall rule to allow ROS wg peer connection to Xray container IP/tunnel port
- add routing rules in ROS - assuming you want internet connections to be routed over this created wg peer - seek topics on this forum how to setup internet connection routing over wg with some notes:
- connections to Xray server IP must be excluded from routing over wg and must be always over WAN gateway (direct connection) because wg is tunneled over it
- if FQDN is used in for connection to Xray server then DNS server used by Xray for resolving (DoH 1.1.1.1 in my config example, can be any public DNS) must be also excluded for routing over wg (same as Xray server IP because Xray needs to resolve IP before wg connection is established), be careful how this rule is setup to avoid leaking connection to DNS over WAN from other IPs, connections needs to be routed only for container IP
# apk uppdate
# apk install curl
# curl -vvv -x socks5://127.0.0.1:1080 https://www.google.com
curl -vvv -x socks5://127.0.0.1:1080 https://www.google.com
09:32:28.767893 [0-x] == Info: [READ] client_reset, clear readers
09:32:28.774195 [0-0] == Info: [HTTPS-CONNECT] added
09:32:28.778786 [0-0] == Info: [HTTPS-CONNECT] connect, init
09:32:28.784225 [0-0] == Info: [HTTPS-CONNECT] connect, check h21
09:32:28.790230 [0-0] == Info: Trying 127.0.0.1:1080...
09:32:28.791491 [0-0] == Info: [HTTPS-CONNECT] connect -> 0, done=0
09:32:28.792638 [0-0] == Info: [HTTPS-CONNECT] adjust_pollset -> 1 socks
09:32:28.793827 [0-0] == Info: [HTTPS-CONNECT] connect, check h21
09:32:28.794908 [0-0] == Info: connect to 127.0.0.1 port 1080 from 127.0.0.1 port 39890 failed: Connection refused
09:32:28.796788 [0-0] == Info: Failed to connect to 127.0.0.1 port 1080 after 26 ms: Could not connect to server
09:32:28.798564 [0-0] == Info: [HTTPS-CONNECT] connect, all failed
09:32:28.799608 [0-0] == Info: [HTTPS-CONNECT] connect -> 7, done=0
09:32:28.800444 [0-0] == Info: [WRITE] cw-out done
09:32:28.800879 [0-0] == Info: closing connection #0
09:32:28.801320 [0-0] == Info: [HTTPS-CONNECT] close
09:32:28.801752 [0-0] == Info: [SETUP] close
09:32:28.802126 [0-0] == Info: [SETUP] destroy
09:32:28.802509 [0-0] == Info: [HTTPS-CONNECT] destroy
curl: (7) Failed to connect to 127.0.0.1 port 1080 after 26 ms: Could not connect to ser
{
"listen": "127.0.0.1",
"port": 1080,
"protocol": "socks",
"settings": {
"udp": true
}
},
2024/11/30 18:05:57 from tcp:127.0.0.1:39920 accepted tcp:142.251.39.68:443 [proxy]
0000: ...J...F0D. i.x....4..-.?.-...h..voN?....DD.. .....UfJ..,.D..O..
0040: -.=.R. s..H...
10:05:57.488608 [0-0] == Info: TLSv1.3 (IN), TLS handshake, Finished (20):
10:05:57.488907 [0-0] <= Recv SSL data, 52 bytes (0x34)
0000: ...0.i$...[.P.[."n..C.B8.lpu...BJ.u....K....uo.3...W
10:05:57.489649 [0-0] => Send SSL data, 5 bytes (0x5)
0000: .....
10:05:57.489927 [0-0] == Info: TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
10:05:57.490275 [0-0] => Send SSL data, 1 bytes (0x1)
0000: .
10:05:57.490688 [0-0] => Send SSL data, 5 bytes (0x5)
0000: ....E
10:05:57.490946 [0-0] => Send SSL data, 1 bytes (0x1)
0000: .
10:05:57.491188 [0-0] == Info: TLSv1.3 (OUT), TLS handshake, Finished (20):
10:05:57.491471 [0-0] => Send SSL data, 52 bytes (0x34)
0000: ...0.&I....uh.ql...cd.i^... .......E.*.(+Z.d.....u.T
10:05:57.492026 [0-0] == Info: [SSL] ossl_bio_cf_out_write(len=80) -> 80, err=0
10:05:57.492468 [0-0] == Info: SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / x25519 / id-ecPublicKey
10:05:57.492890 [0-0] == Info: ALPN: server accepted h2
10:05:57.493106 [0-0] == Info: Server certificate:
10:05:57.493314 [0-0] == Info: subject: CN=www.google.com
10:05:57.493547 [0-0] == Info: start date: Oct 21 08:38:45 2024 GMT
10:05:57.493805 [0-0] == Info: expire date: Jan 13 08:38:44 2025 GMT
10:05:57.494087 [0-0] == Info: subjectAltName: host "www.google.com" matched cert's "www.google.com"
10:05:57.494485 [0-0] == Info: issuer: C=US; O=Google Trust Services; CN=WR2
10:05:57.494780 [0-0] == Info: SSL certificate verify ok.
10:05:57.495017 [0-0] == Info: Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using sha256WithRSAEncryption
10:05:57.495560 [0-0] == Info: Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
10:05:57.496070 [0-0] == Info: Certificate level 2: Public key type RSA (4096/152 Bits/secBits), signed using sha384WithRSAEncryption
10:05:57.496579 [0-0] == Info: [SSL] cf_connect() -> 0, done=1
10:05:57.496821 [0-0] == Info: [HTTPS-CONNECT] connect+handshake h21: 1173ms, 1st data: 5ms
10:05:57.497204 [0-0] == Info: [HTTP/2] [0] created h2 session
10:05:57.497472 [0-0] == Info: [HTTP/2] [0] -> FRAME[SETTINGS, len=18]
10:05:57.497742 [0-0] == Info: [HTTP/2] [0] -> FRAME[WINDOW_UPDATE, incr=1048510465]
10:05:57.498062 [0-0] == Info: [HTTP/2] cf_connect() -> 0, 1,
10:05:57.498330 [0-0] == Info: [HTTPS-CONNECT] connect -> 0, done=1
10:05:57.498602 [0-0] == Info: Connected to 127.0.0.1 (127.0.0.1) port 1080
10:05:57.498886 [0-0] == Info: using HTTP/2
10:05:57.499105 [0-0] == Info: [HTTP/2] [1] OPENED stream for https://www.google.com/
10:05:57.499430 [0-0] == Info: [HTTP/2] [1] [:method: GET]
10:05:57.499652 [0-0] == Info: [HTTP/2] [1] [:scheme: https]
10:05:57.499881 [0-0] == Info: [HTTP/2] [1] [:authority: www.google.com]
10:05:57.500170 [0-0] == Info: [HTTP/2] [1] [:path: /]
10:05:57.500377 [0-0] == Info: [HTTP/2] [1] [user-agent: curl/8.11.0]
10:05:57.500637 [0-0] == Info: [HTTP/2] [1] [accept: */*]
10:05:57.500856 [0-0] == Info: [HTTP/2] [1] submit -> 76, 0
10:05:57.501119 [0-0] == Info: [HTTP/2] [1] -> FRAME[HEADERS, len=31, hend=1, eos=1]
10:05:57.501481 [0-0] => Send SSL data, 5 bytes (0x5)
0000: ....y
10:05:57.501730 [0-0] => Send SSL data, 1 bytes (0x1)
0000: .
10:05:57.502028 [0-0] == Info: [SSL] ossl_bio_cf_out_write(len=126) -> 126, err=0
10:05:57.502286 [0-0] == Info: [HTTP/2] [0] egress: wrote 104 bytes
10:05:57.502608 [0-0] == Info: [HTTP/2] [1] cf_send(len=76) -> 76, 0, eos=1, h2 windows 65535-65535 (stream-conn), buffers 0-0 (stream-conn)
10:05:57.503134 [0-0] => Send header, 76 bytes (0x4c)
0000: GET / HTTP/2
000e: Host: www.google.com
0024: User-Agent: curl/8.11.0
003d: Accept: */*
004a:
10:05:57.503843 [0-0] == Info: [SSL] ossl_bio_cf_in_read(len=5) -> -1^C
For this I'm referring on server side where xray container must be able to connect to its router IP and WG port (for tunnel settings in dokodemo-door mentioned above), depends how your rules are currently made, is curently container isolated or not, etc... Maybe connection already works, try it, if not, you can try with rule on server side:How to enter this rule: "Xray container has access on input chain for UDP 12884 (WG port) for establishing connection to ROS WG" ?
/ip/firewall/filter add action=accept chain=input dst-port=<WG_LISTEN_PORT> protocol=udp src-address=<XRAY_SERVER_CONTAINER_IP>
{
"log": {
"error": "/var/log/Xray/error.log",
"access": "/var/log/Xray/access.log",
"loglevel": "debug"
},
"dns": {
"servers": [
{
"address": "https://1.1.1.1/dns-query",
"skipFallback": true,
"queryStrategy": "UseIPv4"
}
]
},
"routing": {
"rules": [
{
"ip": [
"1.1.1.1"
],
"outboundTag": "direct"
}
]
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 1080,
"protocol": "socks",
"settings": {
"udp": true
}
},
{
"listen":"0.0.0.0",
"port": 51822,
"protocol":"dokodemo-door",
"settings":{
"address":"10.20.20.1",
"port":51822,
"network":"udp"
}
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "*.sn.mynetname.net",
"port": 443,
"users": [
{
"id": "3b5390c5-52a2-472d-8dc2-103ef508be6c",
"encryption": "none",
"flow": ""
}
]
}
]
},
"streamSettings": {
"network": "h2",
"security": "reality",
"realitySettings": {
"show": false,
"fingerprint": "chrome",
"serverName": "www.microsoft.com",
"publicKey": "eZfl07Tg9UII29GaS23QXqB15aqrJ4Khm0vKJIcaMCo",
"shortId": "77c2358dc476ae9e",
"spiderX": ""
}
},
"tag": "proxy"
}
]
}
{
"log": {
"error": "/var/log/xray/error.log",
"access": "/var/log/xray/access.log",
"loglevel": "debug"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "3b5390c5-52a2-472d-8dc2-103ef508be6c",
"flow": ""
}
],
"decryption": "none"
},
"streamSettings": {
"network": "h2",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "www.microsoft.com:443",
"xver": 0,
"serverNames": [
"www.microsoft.com"
],
"privateKey": "QNraK6EdxPNOzfbL2G1BTl_OeMSxm49H5vps2qzQ3E0",
"shortIds": [
"77c2358dc476ae9e"
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
}
]
}
# xray --version
Xray 24.12.15 (Xray, Penetrates Everything.) Custom (go1.23.4 linux/arm)
A unified platform for anti-censorship.
Or Mikrotik just add AmneziaWG and/or XRay containers to docs as examples and to test/fix /container support for them better. There are several threads on this but none are clear/"cookie cutter"... while there are major problems with using plain WG (and other proxy/etc approaches) in certain countries.Also, I think it is enough of hijacking this topic, better open new one for Xray in ROS container in "3rd party tools" section, since this conversation is gone OT.