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

wireguard: Fix IPv6-only VPN #1353

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
30 changes: 22 additions & 8 deletions emhttp/plugins/dynamix/include/update.wireguard.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ function addDocker($vtun) {
}
if (!$error && !isNet($network)) {
[$device,$thisnet,$gateway] = thisNet();
exec("ip -4 rule add from $network table $index");
exec("ip -4 route add unreachable default table $index");
exec("ip -4 route add $thisnet via $gateway dev $device table $index");
// TODO: Add IPv6 support
if ($gateway != "" && $thisnet != "") {
exec("ip -4 rule add from $network table $index");
exec("ip -4 route add unreachable default table $index");
exec("ip -4 route add $thisnet via $gateway dev $device table $index");
}
}
return $error;
}
Expand Down Expand Up @@ -233,15 +236,26 @@ function parseInput($vtun,&$input,&$x) {
[$id,$i] = array_pad(explode(':',$key),2,0);
if ($i != $section) {
if ($section==0) {
// add WG routing for docker containers. Only IPv4 supported
// add WG routing for docker containers.
// TODO: Add IPv6 support!
[$index,$network] = newNet($vtun);
[$device,$thisnet,$gateway] = thisNet();

$conf[] = "PostUp=ip -4 route flush table $index";
$conf[] = "PostUp=ip -4 route add default via $tunip dev $vtun table $index";
$conf[] = "PostUp=ip -4 route add $thisnet via $gateway dev $device table $index";
$conf[] = "PostDown=ip -4 route flush table $index";
$conf[] = "PostDown=ip -4 route add unreachable default table $index";
$conf[] = "PostDown=ip -4 route add $thisnet via $gateway dev $device table $index";

if ($tunip != "") {
// Tunnel supports IPv4
$conf[] = "PostUp=ip -4 route add default via $tunip dev $vtun table $index";
$conf[] = "PostDown=ip -4 route add unreachable default table $index";
}

if ($gateway != "" && $thisnet != "") {
// local network supports IPv4
$conf[] = "PostUp=ip -4 route add $thisnet via $gateway dev $device table $index";
$conf[] = "PostDown=ip -4 route add $thisnet via $gateway dev $device table $index";
}

}
$conf[] = "\n[Peer]";
// add peers, this is only used for peer sections
Expand Down