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
nixos/openvpn: add network namespace support #109643
Open
ju1m
wants to merge
2
commits into
NixOS:master
Choose a base branch
from
ju1m:openvpn
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ju1m
force-pushed
the
openvpn
branch
3 times, most recently
from
January 17, 2021 22:27
7f8baab
to
4ca96c5
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
|
@cladmi, seeing that you've written https://github.com/cladmi/openvpn-netns, you may be interested by this PR :) |
|
stale
bot
added
the
2.status: stale
https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
label
Jun 12, 2022
ju1m
force-pushed
the
openvpn
branch
2 times, most recently
from
August 21, 2022 08:17
ac97b66
to
df65a81
Compare
|
ju1m
force-pushed
the
openvpn
branch
2 times, most recently
from
October 10, 2022 00:28
4ff2305
to
7cd3789
Compare
stale
bot
removed
the
2.status: stale
https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
label
Oct 10, 2022
|
|
pborzenkov
reviewed
Oct 31, 2022
Rebased onto |
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is working enough for me so far but may benefit from reviews and tests before being merged.
I am not sure how to handle the
DNS
option fromDHCP
, currently/etc/netns/${netns}/resolv.conf
is always set (ip netns
bind mounting it onto/etc/resolv.conf
) but maybe it should be guarded by a NixOS option. I've also not tested the interaction withupdateResolvConf
.Motivation for this change
Add network namespace support to OpenVPN.
This enables to move the OpenVPN interface and selected systemd services in a dedicated network namespace without the physical network interfaces.
Things done
services.netns
module to create network namespaces and have systemd services depend upon it.services.netns.${netns}.sysctl
to configuresysctl
s within network namespaces, and inherit defaults fromboot.kernel.sysctl
.services.netns.${netns}.nftables
to configure the firewall usingnftables
within network namespaces, iif.networking.nftables.enable
istrue
.services.openvpn.settings
option usingfreeformType
.services.openvpn.server.${server}.netns
. Note that this requiresscript-security = 2
because afterip link
has movedopenvpn
's device the network configuration has to be done from scratch within the network namespace.services.openvpn.server.${server}.{up,down}
toservices.openvpn.server.${server}.settings.{up,down}
, usingmkAliasAndWrapDefsWithPriority
.services.openvpn.server.${server}.enable
.Example
This creates the
riseup
network namespace, start anopenvpn
in the initial network namespace, and then moveopenvpn
's interface to thatriseup
network namespace.This excerpt puts
transmission
in thatriseup
network namespace.sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)