Closed axrusar closed 2 months ago
Please upgrade to the latest version of wstunnel. See the FAQ section for using wireguard with wstunnel https://github.com/erebe/wstunnel?tab=readme-ov-file#wireguard
Ok i downloaded version 10 and trying the basics as per the instructions on that link. Here i start wstunnel on the server:
root@aws-ohio:~# wstunnel server --restrict-to localhost:51001 wss://[::]:4433
2024-08-28T15:02:28.262471Z INFO wstunnel::embedded_certificate: Generating self-signed tls certificate
2024-08-28T15:02:28.263152Z INFO wstunnel: Starting wstunnel server v10.1.0 with config WsServerConfig { socket_so_mark: None, bind: [::]:4433, websocket_ping_frequency: Some(30s), timeout_connect: 10s, websocket_mask_frame: false, restriction_config: None, tls: true, mTLS: false }
2024-08-28T15:02:28.263284Z INFO wstunnel::tunnel::server::server: Starting wstunnel server listening on [::]:4433
Port 4433 is open on the server. I also added the route using the local WAN ip of the server and the router gateway. Note i use port 51001 for the wireguard connections.
This is the client trying to connect:
root@mint22VM:/etc/wstunnel# wstunnel client -L 'udp://51001:localhost:51001?timeout_sec=0' wss://3.xx.xx.3:4433
024-08-28T15:08:39.506147Z INFO wstunnel::protocols::udp::server: New UDP connection from 127.0.0.1:34041
2024-08-28T15:08:39.506772Z INFO wstunnel::protocols::tcp::server: Opening TCP connection to 3.xx.xx.3:4433
2024-08-28T15:08:43.933434Z WARN wstunnel::protocols::tcp::server: Cannot connect to tcp endpoint 3.xx.xx.3:4433 due to timeout of 10s elapsed
2024-08-28T15:08:49.509066Z WARN wstunnel::protocols::tcp::server: Cannot connect to tcp endpoint 3.xx.xx.3:4433 due to timeout of 10s elapsed
2024-08-28T15:08:49.910477Z INFO wstunnel::protocols::tcp::server: Opening TCP connection to 3.xx.xx.3:4433
2024-08-28T15:08:59.912138Z WARN wstunnel::protocols::tcp::server: Cannot connect to tcp endpoint 3.xx.xx.3:4433 due to timeout of 10s elapsed
2024-08-28T15:09:00.713694Z INFO wstunnel::protocols::tcp::server: Opening TCP connection to 3.xx.xx.3:4433
Times out and keeps looping every 10 seconds.
I do not see any instructions on how to actually install wstunnel.. i just extracted it from the wstunnel_10.1.0_linux_amd64.tar.gz file and gave it +x permissions.
That's ok for the installation, only extracting and chmod +x is enough.
From the log it seems tve port 4433 is filtered/blocked between your client and server.
Check with another well known port, that is not filtered. i.e: 443, 995, 53, 8080,...
The ports are not filtered/blocked on the server. I have control of the firewall. To make it clear i ran another test on port 443 that i am currently using for v2ray and it is working.
While v2ray is active on the server on port 443, from the connecting client i run:
nc -zv 3.xx.xx.3 443
Connection to 3.xx.xx.3 443 port [tcp/https] succeeded!
Now confirmed there is no issues with port 443, I stop the v2ray service on the server to make the port available for wstunnel. So if i try again:
nc -zv 3.xx.xx.3 443
nc: connect to 3.xx.xx.3 port 443 (tcp) failed: Connection refused
This confirms port 443 is free and no services are using it now.
Then i run wstunnel on the server using port 443:
root@aws-ohio:~# wstunnel server --restrict-to localhost:51001 wss://127.0.0.1:443
2024-08-29T09:21:33.761772Z INFO wstunnel::embedded_certificate: Generating self-signed tls certificate
2024-08-29T09:21:33.762411Z INFO wstunnel: Starting wstunnel server v10.1.0 with config WsServerConfig { socket_so_mark: None, bind: 127.0.0.1:443, websocket_ping_frequency: Some(30s), timeout_connect: 10s, websocket_mask_frame: false, restriction_config: None, tls: true, mTLS: false }
2024-08-29T09:21:33.762556Z INFO wstunnel::tunnel::server::server: Starting wstunnel server listening on 127.0.0.1:443
and run nc again from the client:
nc -zv 3.xx.xx.3 443
nc: connect to 3.xx.xx.3 port 443 (tcp) failed: Connection refused
Same timeout in the client if i try to connect:
root@mint22VM:/etc/wstunnel# wstunnel client -L 'udp://51001:localhost:51001?timeout_sec=0' wss://3.xx.xx.3:443
024-08-29T09:32:56.155218Z WARN wstunnel::protocols::tcp::server: Cannot connect to tcp endpoint 3.xx.xx.3:443 due to timeout of 10s elapsed
2024-08-29T09:33:47.355691Z INFO wstunnel::protocols::tcp::server: Opening TCP connection to 3.xx.xx.3:443
2024-08-29T09:33:57.357163Z WARN wstunnel::protocols::tcp::server: Cannot connect to tcp endpoint 3.xx.xx.3:443 due to timeout of 10s elapsed
2024-08-29T09:35:39.758288Z INFO wstunnel::protocols::tcp::server: Opening TCP connection to 3.xx.xx.3:443
2024-08-29T09:35:45.325769Z ERROR tunnel{id="01919d79-1acd-7313-8305-afe60be5cb3b" remote="localhost:51001"}: wstunnel::tunnel::client::client: failed to get a connection to the server from the pool: TimedOut
although if i run netstat on the server while wstunnel is running it shows the port is in use:
root@aws-ohio:~# netstat -tuln | grep 443
tcp 0 0 127.0.0.1:443 0.0.0.0:* LISTEN
Server system information"
System:
Kernel: 6.5.0-1023-aws x86_64 bits: 64 Console: pty pts/0
Distro: Ubuntu 22.04.4 LTS (Jammy Jellyfish)
wstunnel v10.1.0
As mentioned earlier, i have control of the firewall and using any other port (4433, 44333) does not make a difference. I do have multiple other ports open on it and they all work. The server itself has the firewall disabled, the ports are opened from the inbound rules in the AWS security panel. The server does not have any special routing rules configuration that may be interfering, it is pretty much a vanilla Ubuntu server to run only wireguard and now v2ray while trying to setup wstunnel.
Thank you!!
in your last example, the server is listening only on the loopback interface (127.0.0.1)
root@aws-ohio:~# wstunnel server --restrict-to localhost:51001 wss://127.0.0.1:443
try with wss://[::]:443
or wss://0.0.0.0:443
Ok it looks like there is a connection now running:
root@aws-ohio:~# wstunnel server --restrict-to localhost:51001 wss://[::]:443
In the client i see the ping pong loop:
wstunnel client -L 'udp://51001:localhost:51001?timeout_sec=0' wss://3.xx.xx.3:443
2024-08-29T13:18:13.992370Z INFO tunnel{id="01919e42-7b2b-7ff3-b0fe-af5e07f5d913" remote="localhost:51001"}: wstunnel::tunnel::transport::websocket: received frame Ping
2024-08-29T13:18:14.134617Z INFO tunnel{id="01919e42-7b2b-7ff3-b0fe-af5e07f5d913" remote="localhost:51001"}: wstunnel::tunnel::transport::websocket: received frame Pong
2024-08-29T13:18:43.993501Z INFO tunnel{id="01919e42-7b2b-7ff3-b0fe-af5e07f5d913" remote="localhost:51001"}: wstunnel::tunnel::transport::websocket: received frame Ping
2024-08-29T13:18:44.134992Z INFO tunnel{id="01919e42-7b2b-7ff3-b0fe-af5e07f5d913" remote="localhost:51001"}: wstunnel::tunnel::transport::websocket: received frame Pong
But then i start the wireguard connection and i lose internet connection. There is no reply from the server and the client shows:
2024-08-29T13:10:42.731137Z INFO wstunnel::protocols::udp::server: New UDP connection from 127.0.0.1:34479
2024-08-29T13:10:42.731287Z INFO wstunnel::protocols::tcp::server: Opening TCP connection to 3.xx.xx.3:443
2024-08-29T13:10:52.499749Z INFO tunnel{id="01919e3b-be69-7713-8ab2-c41e1fefdcf1" remote="localhost:51001"}: wstunnel::tunnel::transport::websocket: received frame Ping
2024-08-29T13:10:52.733195Z WARN wstunnel::protocols::tcp::server: Cannot connect to tcp endpoint 3.xx.xx.3:443 due to timeout of 10s elapsed
I am using the same wireguard configuration that was working before the ISP started blocking the protocol. In the client looks like this:
[Interface]
PrivateKey = eDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2o=
Address = 192.168.69.9/32
#MTU = 1400
DNS = 1.1.1.1
[Peer]
PublicKey = osxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxn0=
Endpoint = localhost:51001
AllowedIPs = 0.0.0.0/0
So i only changed the endpoint to localhost. running wg on the server shows the wireguard server is active listening.
Server config:
[Interface]
PrivateKey=gBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxm3I=
Address=192.168.69.1/24
ListenPort=51001
PostUp=iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown=iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer]
## Home
PublicKey=SatxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEk=
AllowedIPs=192.168.69.9
you need to set a static route now to your server to avoid the loop https://github.com/erebe/wstunnel?tab=readme-ov-file#wireguard-and-wstunnel-
or in your client allowed ip exclude your server from it, instead of 0.0.0.0/0 check https://github.com/erebe/wstunnel/issues/252#issuecomment-2030281446
Thank you erebe for your patience and kindness. I got it going now, problem was i added the route to the server instead of the client. Good luck and thank you for your time.
(ノಠ益ಠ)ノ彡┻━┻
Describe the goal
Establish a wireguard connection with wstunnel 5.0
Describe what does not work
wstunnel[4113]: Rejecting connection wstunnel[4113]: Rejecting connection
Describe your wstunnel setup
Server: ubuntu server 22.04.4 client: Linux mint 20.3, Linux mint 22
Followed this guide: https://nerdonthestreet.com/wiki?find=Set+Up+a+WireGuard+VPN+Server+with+WebSocket+Tunneling
I am using wstunnel 5.0 because that is what is used in the guide linked above. When i tried to use the latest wstunnel version 10, the service does not start on the server. I have actually setup wstunnel using version 5 (on the same client i am currently using to connect and same server) in the past without issues, so i have been pulling my hairs for the past few days and i can not pinpoint where the issue is. I am testing from the same system (Mint 21.3 client) i was able to connect before and and 2 fresh VMs (another mint 20.3 and a new 22).
When i start the connection on the client i get (all sensitive IPs are masked with xx below):
but running wg shows no traffic (transfer: 0 B received, 148 B sent)
If i run the wireguard connection to the server without the wstunnel, the connection works. And the server seems to be receiving the requests on port 443 based on what i posted in the title. When i start the connection, the same error loops indefinitely
wstunnel[4113]: Rejecting connection
The wstunnel service on the server shows:
Here is the modified script i am using on the client to bypass hostname resolution as i do not use a domain (pre_up section where remote_ip=${remote} is added):
My ISP started blocking wireguard, the wireguard connections i mentioned working are the same i was using a week ago (same keys as before) so i need wstunnel to work. Thank you for any tips.