diff options
author | Daniil Baturin <daniil@vyos.io> | 2020-07-31 00:07:05 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-31 00:07:05 +0700 |
commit | ce56258f8dd52c5a14482a1055e4f23b89e462f6 (patch) | |
tree | 842a337724998fa7e99f8ab37fdfd85cd0b66d7e | |
parent | 66a3c73455d80adc920d4120fb31a9b0070b4158 (diff) | |
parent | cec720d0fd241f656100b10674bf2c7c4f02b4ea (diff) | |
download | vyatta-cfg-vpn-ce56258f8dd52c5a14482a1055e4f23b89e462f6.tar.gz vyatta-cfg-vpn-ce56258f8dd52c5a14482a1055e4f23b89e462f6.zip |
Merge pull request #35 from zdc/T2728-equuleus
IPSec tunnels: T2728: Fixed protocol selector for tunnels
-rwxr-xr-x | scripts/vpn-config.pl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/vpn-config.pl b/scripts/vpn-config.pl index 582e3a7..d1ae5a8 100755 --- a/scripts/vpn-config.pl +++ b/scripts/vpn-config.pl @@ -928,6 +928,29 @@ if ($vcVPN->exists('ipsec')) { if ($isVti == 1) { vpn_die(["vpn","ipsec","site-to-site","peer",$peer,"$tunKeyword"],"$vpn_cfg_err Can not use transport mode for \"$peer\" with vti\n"); } + # Processing protocol selector for a tunnel + my $protocol = $vcVPN->returnValue("ipsec site-to-site peer $peer $tunKeyword protocol"); + if (defined($protocol)) { + # Replace 'all' with the proper variant for strongSwan + if ($protocol eq 'all') { + $protocol = '%any'; + } + # Transport mode with protocol selector can be used only together with left|rightsubnet + # Thus, we need to be sure that it is possible to generate their values from left/right + my $left_ip = new NetAddr::IP $vcVPN->returnValue("ipsec site-to-site peer $peer local-address"); + if ($left_ip->addr eq '0.0.0.0') { + vpn_die(["vpn","ipsec","site-to-site","peer",$peer,"$tunKeyword"],"$vpn_cfg_err It is not possible to use transport mode ESP ". + "group and protocol selector without predefined static \"local-address\"\n"); + } + my $right_ip = new NetAddr::IP $peer; + if ($right_ip->addr eq '0.0.0.0') { + vpn_die(["vpn","ipsec","site-to-site","peer",$peer,"$tunKeyword"],"$vpn_cfg_err It is not possible to use transport mode ESP ". + "group and protocol selector together with a peer without predefined IP address\n"); + } + # Generate a config for using with the protocol selector + $genout .= "\tleftsubnet=$left_ip\[$protocol\]\n"; + $genout .= "\trightsubnet=$right_ip\[$protocol\]\n"; + } } $genout .= "\ttype=$espmode\n"; |