Development discussion of WireGuard
 help / color / mirror / Atom feed
* Enable Wireguard only for specific user
@ 2021-09-30 10:40 Florent B.
  2021-09-30 10:53 ` Nils Andreas Svee
  0 siblings, 1 reply; 3+ messages in thread
From: Florent B. @ 2021-09-30 10:40 UTC (permalink / raw)
  To: wireguard

Hi list,

On a Linux system (Ubuntu), I would like to enable Wireguard VPN only 
for a single user on my system.

Currently by default, every packet of every user is getting though 
Wireguard.

How can I do to route packets only for 1 user ?

I think I have to play with packets marking (wg show wg0 fwmark / 
iptables owner/mark module), I tried some commands but was unable to 
success.

Can someone help please ?

Thank you.

Florent


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Enable Wireguard only for specific user
  2021-09-30 10:40 Enable Wireguard only for specific user Florent B.
@ 2021-09-30 10:53 ` Nils Andreas Svee
  2021-09-30 11:01   ` Florent B.
  0 siblings, 1 reply; 3+ messages in thread
From: Nils Andreas Svee @ 2021-09-30 10:53 UTC (permalink / raw)
  To: Florent B., WireGuard mailing list

Hi,

What I've had success with is using policy-based routing, selecting the routing table to use based on UID's.
You create a new routing table for the WireGuard VPN and add a rule directing that users traffic to that table.

Using commands you can do this to route traffic from the user with UID 1000 to table 500.
> ip rule add pref 20 uidrange 1000-1000 lookup 500

You can also do this in systemd-networkd if you're using that. Not sure about other network managers.

Best Regards
Nils

On Thu, Sep 30, 2021, at 12:40, Florent B. wrote:
> Hi list,
>
> On a Linux system (Ubuntu), I would like to enable Wireguard VPN only 
> for a single user on my system.
>
> Currently by default, every packet of every user is getting though 
> Wireguard.
>
> How can I do to route packets only for 1 user ?
>
> I think I have to play with packets marking (wg show wg0 fwmark / 
> iptables owner/mark module), I tried some commands but was unable to 
> success.
>
> Can someone help please ?
>
> Thank you.
>
> Florent

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Enable Wireguard only for specific user
  2021-09-30 10:53 ` Nils Andreas Svee
@ 2021-09-30 11:01   ` Florent B.
  0 siblings, 0 replies; 3+ messages in thread
From: Florent B. @ 2021-09-30 11:01 UTC (permalink / raw)
  To: Nils Andreas Svee, WireGuard mailing list

Hi,

Thank you it works very well matching my excluded user and using "lookup 
main" ;)

 > ip rule add pref 20 uidrange 1001-1001 lookup main

I though it was more difficult and didn't know that "uid matching" in 
"ip rule".

Thanks

Le 30/09/2021 à 12:53, Nils Andreas Svee a écrit :
> Hi,
>
> What I've had success with is using policy-based routing, selecting the routing table to use based on UID's.
> You create a new routing table for the WireGuard VPN and add a rule directing that users traffic to that table.
>
> Using commands you can do this to route traffic from the user with UID 1000 to table 500.
>> ip rule add pref 20 uidrange 1000-1000 lookup 500
> You can also do this in systemd-networkd if you're using that. Not sure about other network managers.
>
> Best Regards
> Nils
>
> On Thu, Sep 30, 2021, at 12:40, Florent B. wrote:
>> Hi list,
>>
>> On a Linux system (Ubuntu), I would like to enable Wireguard VPN only
>> for a single user on my system.
>>
>> Currently by default, every packet of every user is getting though
>> Wireguard.
>>
>> How can I do to route packets only for 1 user ?
>>
>> I think I have to play with packets marking (wg show wg0 fwmark /
>> iptables owner/mark module), I tried some commands but was unable to
>> success.
>>
>> Can someone help please ?
>>
>> Thank you.
>>
>> Florent

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-30 11:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 10:40 Enable Wireguard only for specific user Florent B.
2021-09-30 10:53 ` Nils Andreas Svee
2021-09-30 11:01   ` Florent B.

Development discussion of WireGuard

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/wireguard/0 wireguard/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 wireguard wireguard/ https://inbox.vuxu.org/wireguard \
		wireguard@lists.zx2c4.com
	public-inbox-index wireguard

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.wireguard


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git