Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redo route management. #2140

Open
majestrate opened this issue Feb 16, 2023 · 15 comments
Open

redo route management. #2140

majestrate opened this issue Feb 16, 2023 · 15 comments
Labels
enhancement New feature or request linux linux specific issue packaging vpn mode relating to running lokinet in vpn mode
Milestone

Comments

@majestrate
Copy link
Contributor

the route poker as is, currently is a linux only thing and it's kind of hacky. we end up having to periodically probe the routing table to figure out if we need to modify it. this was done because i wanted to make it work and all i had to reference was openvpn. the way it is done now also does not allow us to do selective routing, which is something users have been asking for (i want it too).

ideally i want to remove the route poker and delegate the responsibility of route management to the system layer using nftables. i can see 2 primary modes of operation:

  • (opt out) any user not belonging to a group _lokinet-direct would be forced to route traffic over the lokitun0 interface.
  • (opt in) any user in the _lokinet-tunnel group will always use the lokitun0 interface for traffic.

this means future route management would not be done by lokinet process on linux. this would also make the route management code on every other platform much simpler as they all offload this to the system layer already.

@majestrate majestrate added enhancement New feature or request packaging linux linux specific issue labels Feb 16, 2023
@majestrate majestrate added this to the 0.9.13 milestone Feb 16, 2023
@ple1n
Copy link

ple1n commented Feb 19, 2023

how would per-application routing be done ? I've tried a few and they seem like hacks. Netns, iptables+running as different users, firejail, all have different issues. And there is flatpak, which has no consideration for proxying either.

@majestrate
Copy link
Contributor Author

majestrate commented Feb 19, 2023

how would per-application routing be done ? I've tried a few and they seem like hacks.

in the proposed setup, it'd be nftables rules + run application as a user in a group

e.g. sudo -g _lokinet-tunnel program args args args

Netns, iptables+running as different users, firejail, all have different issues. And there is flatpak, which has no consideration for proxying either.

tooling for netns are painful still.

@ple1n
Copy link

ple1n commented Feb 19, 2023

Is it possible that a process changes its GID so that it leaks the traffic.

nvm, apps are not assumed to be malicious in this threat model

@majestrate
Copy link
Contributor Author

Is it possible that a process changes its GID so that it leaks the traffic

only if a process can setgid / setegid

@majestrate
Copy link
Contributor Author

setgid is as restricted as setuid, if it can call that it very likely can become root which is game over anyways.

@ple1n
Copy link

ple1n commented Mar 26, 2023

How about setting up a netns and running firefox in firejail ? It sounds more secure to me. (nftables seemed to leak traffic for me when interface down or misconfigured)
I fiddled with netns but no success. Idk how to configure this. I shouldn't move lokitun0 into netns apparently.
I'm not sure what a bridge is but lokitun0 can't be added to a bridge

@majestrate
Copy link
Contributor Author

How about setting up a netns and running firefox in firejail ? It sounds more secure to me. (nftables seemed to leak traffic for me when interface down or misconfigured)

that would indeed work very well. there was an attempt years ago to do it that failed.

I fiddled with netns but no success. Idk how to configure this. I shouldn't move lokitun0 into netns apparently.

lokinet needs to somehow straddle the boundary of both netns so that dns and tun are inside it and the rest of lokinet is outside it.

I'm not sure what a bridge is but lokitun0 can't be added to a bridge

yea it's a l3 tun, if it was l2 tap it may work

@ple1n
Copy link

ple1n commented Mar 31, 2023

how do you think of portmaster. it seems to do selective routing

@majestrate
Copy link
Contributor Author

how do you think of portmaster. it seems to do selective routing

i like their ui but i know nothing of their internals

@ple1n
Copy link

ple1n commented Apr 1, 2023

from my two days use of portmaster, its a pain to use without subscribing to their SPN.

  1. You can't route applications individually in the UI even though they can add this feature easily. (de facto SPN vendor-lock-in)
    • so I only use it to prevent leaks, by killing non-localhost connections in the default net namaspace.
  2. You can't disable their DNS server, and their DNS server doesn't work at all (prolly bcs my system has complicated configs but anyway). I have to manually remove their nftables rule to un-redirect DNS to allow my VPN to do the initial lookup, ie bootstrap.

it'd be great if it can route to socks proxies, tor (through tun2socks or something idk) and lokinet, as an all-encompassing solution to desktop proxy-selective-routing on linux. (but it doesnt consider netns)

edit,

I switched to Opensnitch when portmaster started hogging my cpu

@ghost
Copy link

ghost commented Apr 3, 2023

@planetoryd

proxy-selective-routing on linux

You mean like stream isolation?

I think more documentation should be about editing the loki config (the equivilent to Tor's torrc)
Cause by default Loki doesn't have any Exitnodes set. (you have to set them manually if you want them to be automatic at start in the config). Also would be great if you could put in more then one in the config and randomly $RANDOM selecting one from the listed in the config upon startup of the systemd service.

@majestrate
Copy link
Contributor Author

stream isolation would be for .loki and .snode using ipv6 flow labels, it should be in with #2119

@ple1n
Copy link

ple1n commented Apr 5, 2023

You mean like stream isolation?

I mean maintaining multiple isolated online identities through different proxies securely, in general.

The core of proxy-selective-routing is not application/connection/whatever, but identity isolation. The set of rules are means to the end.

Casual proxying usually aims at simple circumvention of censor, or accessing private networks. It's already available. Find the right environment variables, parameters, and try again if the app doesn't pick them up.

Usually there are two identities at least, one for package installers, the other for browsing. more for more complex setup.

@majestrate majestrate added the vpn mode relating to running lokinet in vpn mode label May 8, 2023
@ple1n
Copy link

ple1n commented May 23, 2023

FYI, I wrote a Rust script to handle my needs. It's really handy to me. Ex. enters netns without sudo (sudo messes up a lot of things I decided to ditch it in this scenario) I use it daily.

@majestrate
Copy link
Contributor Author

majestrate commented May 23, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request linux linux specific issue packaging vpn mode relating to running lokinet in vpn mode
Projects
None yet
Development

No branches or pull requests

2 participants