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

Only add ipv6 route if available and set MTU directly #8

Merged
merged 1 commit into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ expected values are set by default, most with dummy default values.
WireGuard interface. For a namespaced VPN, where the goal is to force all
traffic through the VPN, the catch-all value `0.0.0.0/0,::0/0` is probably
correct.
- `WIREGUARD_INITIAL_MTU`:
MTU of the wireguard interface. Choosing too large a value risks packet loss.
- `WIREGUARD_IP_ADDRESSES`:
Comma-separated list of static IP addresses to assign to the WireGuard
interface. As far as I know, WireGuard does not currently support DHCP or any
Expand Down
7 changes: 5 additions & 2 deletions bin/namespaced-wireguard-vpn-interface
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ die() {

case "$1" in
up)
ip link add "$WIREGUARD_NAME" type wireguard || die
ip link add "$WIREGUARD_NAME" mtu $WIREGUARD_INITIAL_MTU type wireguard || die

wg set "$WIREGUARD_NAME" \
private-key <(echo "$WIREGUARD_PRIVATE_KEY") \
Expand All @@ -26,7 +26,10 @@ case "$1" in

# Add default routes for IPv4 and IPv6
ip -n "$NETNS_NAME" -4 route add default dev "$WIREGUARD_NAME" || die
ip -n "$NETNS_NAME" -6 route add default dev "$WIREGUARD_NAME" || die
if ip -o -6 -a | grep -q "$WIREGUARD_NAME"
then
ip -n "$NETNS_NAME" -6 route add default dev "$WIREGUARD_NAME" || die
fi
;;

down)
Expand Down
6 changes: 6 additions & 0 deletions conf/namespaced-wireguard-vpn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ WIREGUARD_ALLOWED_IPS=0.0.0.0/0,::0/0
# interface
WIREGUARD_IP_ADDRESSES=10.0.0.1/32,fd12:3456:789a:1::1/128

# Assuming a sane VPN provider:
# IPv4: 1440
# IPv6: 1420
# If using PPPoE(typically DSL) -=8
WIREGUARD_INITIAL_MTU=1420

# Name of the init-facing tunnel interface
TUNNEL_INIT_NAME=veth-vpn0

Expand Down