wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
From: Saeid Akbari <saeidscorp@yahoo.com>
To: Adrian Sevcenco <adrian.sev@gmail.com>
Cc: wireguard@lists.zx2c4.com
Subject: Re: match on wg packets and redirect
Date: Mon, 05 Nov 2018 17:52:06 +0330	[thread overview]
Message-ID: <7729526.hCRZ1bQ3Gc@scorpbook> (raw)

Hi,

I understand you're multiplexing kind of thought (like sslh), so I did some 
experiments with u32 module, and came up on this:

iptables -t nat -A PREROUTING -i eth0 \! -f -p udp \! --dport 51820 -m length 
--length 176 -m u32 --u32 "0 >> 22 & 0x3C @ 8 = 0x1000000" -j DNAT --to-
destination :51820

I tested it on a server and it worked as expected. this way I intercept all 
wireguard initiator messages on all udp ports and redirect them to the 
listening (real) port of wireguard (51820); and because of DNAT, all follow-up 
packets get through as well. however, I didn't try having any other udp port 
open to test the actual "multiplexing". there is only packet length and first 4 
bytes of udp payload check wich correspond to wireguard's initiator message 
(type 1).

Hope this would be useful to some people :))

P.S: I know that you don't need this stuff for your use case (there is no 
other udp port open on 443), but I thought it might be interesting to you.


_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

             reply	other threads:[~2018-11-05 14:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05 14:22 Saeid Akbari [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-11-04  9:09 match on wg packets and redirect Adrian Sevcenco
2018-11-04  9:55 ` Matthias Urlichs
2018-11-04 11:41 ` Kalin KOZHUHAROV
2018-11-04 13:46   ` Adrian Sevcenco
2018-11-04 13:56     ` Matthias Urlichs
2018-11-04 15:14 ` Jason A. Donenfeld
2018-11-04 15:29   ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7729526.hCRZ1bQ3Gc@scorpbook \
    --to=saeidscorp@yahoo.com \
    --cc=adrian.sev@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).