Skip to content

Commit 684ee8c

Browse files
committed
Only add ipv6 route if available and set MTU directly
1 parent e7f30a9 commit 684ee8c

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ expected values are set by default, most with dummy default values.
7878
WireGuard interface. For a namespaced VPN, where the goal is to force all
7979
traffic through the VPN, the catch-all value `0.0.0.0/0,::0/0` is probably
8080
correct.
81+
- `WIREGUARD_INITIAL_MTU`:
82+
MTU of the wireguard interface. Choosing too large a value risks packet loss.
8183
- `WIREGUARD_IP_ADDRESSES`:
8284
Comma-separated list of static IP addresses to assign to the WireGuard
8385
interface. As far as I know, WireGuard does not currently support DHCP or any

bin/namespaced-wireguard-vpn-interface

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ die() {
77

88
case "$1" in
99
up)
10-
ip link add "$WIREGUARD_NAME" type wireguard || die
10+
ip link add "$WIREGUARD_NAME" mtu $WIREGUARD_INITIAL_MTU type wireguard || die
1111

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

2727
# Add default routes for IPv4 and IPv6
2828
ip -n "$NETNS_NAME" -4 route add default dev "$WIREGUARD_NAME" || die
29-
ip -n "$NETNS_NAME" -6 route add default dev "$WIREGUARD_NAME" || die
29+
if ip -o -6 -a | grep "${wg_names[$i]}"
30+
then
31+
ip -n "$NETNS_NAME" -6 route add default dev "$WIREGUARD_NAME" || die
32+
fi
3033
;;
3134

3235
down)

conf/namespaced-wireguard-vpn.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ WIREGUARD_ALLOWED_IPS=0.0.0.0/0,::0/0
2020
# interface
2121
WIREGUARD_IP_ADDRESSES=10.0.0.1/32,fd12:3456:789a:1::1/128
2222

23+
# Assuming a sane VPN provider:
24+
# IPv4: 1440
25+
# IPv6: 1420
26+
# If using PPPoE(typically DSL) -=8
27+
WIREGUARD_INITIAL_MTU=1420
28+
2329
# Name of the init-facing tunnel interface
2430
TUNNEL_INIT_NAME=veth-vpn0
2531

0 commit comments

Comments
 (0)