From: Bruno Wolff III <bruno@wolff.to>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: [WireGuard] Using wireguard link as a proxy?
Date: Fri, 22 Jul 2016 13:05:27 -0500 [thread overview]
Message-ID: <20160722180527.GA14911@wolff.to> (raw)
In-Reply-To: <CAHmME9oDAbN=OW8oLERFJQUnhKua_dSvSBVKz9139ORhEWOU8g@mail.gmail.com>
On Fri, Jul 22, 2016 at 17:30:37 +0200,
"Jason A. Donenfeld" <Jason@zx2c4.com> wrote:
>
>$ ip rule add to 1.2.3.4 lookup main pref 30
>$ ip rule add to all lookup 80 pref 40
>$ ip route add default dev wg0 table 80
>
>
>This thread might interest you:
>http://marc.info/?l=linux-netdev&m=145452157719655&w=2
While this doesn't cover the general case, what I found usable was
after checking for packets to the proxy, suppressing the default route when
searching the main table and letting stuff that matches a narrower route go
through directly. And then left over stuff goes to the tunnel via a
default route in the extra routing table.
So for a real example that appears to be working, my systemd service file
is below. 98.103.208.27 and 192.168.1.2 are bith the same machine. I need
to include both because replies from 98.103.208.27 on my local network
sometimes have a source address of 192.168.1.2. Most people won't have
that issue.
There is extra cleanup commands so the service can be restarted without
accumalating extra rules or routing table entries.
It seems to work now, but I had been fooled previously by cached router
information.
The main thing of interest at this point in the thread is:
ip rule add suppress_prefixlength 0 lookup main priority 102
[Unit]
Description=WireGuard Server
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=-/usr/sbin/ip link del dev wg0
ExecStart=/usr/sbin/ip rule flush
ExecStart=/usr/sbin/ip rule add from all lookup default priority 32767
ExecStart=/usr/sbin/ip rule add from all lookup main priority 32766
ExecStart=/usr/sbin/ip route flush table 200
ExecStart=/usr/sbin/ip link add dev wg0 type wireguard
ExecStart=/usr/sbin/ip address add dev wg0 192.168.7.3 peer 192.168.7.1/32
ExecStart=/usr/bin/wg setconf wg0 /etc/wireguard/config
ExecStart=/usr/sbin/ip link set up dev wg0
ExecStart=/usr/sbin/ip route add default dev wg0 table 200
ExecStart=/usr/sbin/ip rule add to 98.103.208.27/32 lookup main priority 100
ExecStart=/usr/sbin/ip rule add to 192.168.1.2/32 lookup main priority 101
ExecStart=/usr/sbin/ip rule add suppress_prefixlength 0 lookup main priority 102
ExecStart=/usr/sbin/ip rule add from all lookup 200 priority 103
ExecStopPost=/usr/sbin/ip link del dev wg0
ExecStopPost=/usr/sbin/ip rule flush
ExecStopPost=/usr/sbin/ip rule add from all lookup default priority 32767
ExecStopPost=/usr/sbin/ip rule add from all lookup main priority 32766
ExecStopPost=/usr/sbin/ip route flush table 200
[Install]
WantedBy=multi-user.target
next prev parent reply other threads:[~2016-07-22 18:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 20:57 [WireGuard] Using wireguard link as a proxy? Bruno Wolff III
2016-07-22 8:18 ` Baptiste Jonglez
2016-07-22 9:09 ` Bruno Wolff III
2016-07-22 9:32 ` Baptiste Jonglez
2016-07-22 11:32 ` Bruno Wolff III
2016-07-22 12:42 ` Jason A. Donenfeld
2016-07-22 15:14 ` Bruno Wolff III
2016-07-22 15:30 ` Jason A. Donenfeld
2016-07-22 16:13 ` Bruno Wolff III
2016-07-22 18:05 ` Bruno Wolff III [this message]
2016-07-23 16:36 ` Bruno Wolff III
2016-07-23 17:25 ` Bruno Wolff III
2016-07-25 12:57 ` Jason A. Donenfeld
2016-07-25 15:40 ` Bruno Wolff III
2016-07-22 15:35 ` Quan Zhou
2016-07-22 16:02 ` Bruno Wolff III
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=20160722180527.GA14911@wolff.to \
--to=bruno@wolff.to \
--cc=Jason@zx2c4.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.