Просто оставлю это здесь для гугла. Вдруг кому понадобятся примеры конфигов.
Есть две площадки: "метрополия", она же "центральная". Внутренняя адресация "172.16.1.0/24". Внешний адрес маршрутизатора "213.180.193.1". Оным выступает Juniper SRX.
"Колония", он же "вынос". Внутренняя адресация "172.16.1.0/24". Внешний адрес маршрутизатора "93.158.134.1". Оным выступает Linux / StrongSWAN.
Хочется построить между площадками GRE/IPSec тоннель с наиболее актуальными на сегодняшний день алгоритмами шифрования.
Примечание: со стороны Juniper-а имеется ряд галимых ограничений "то нельзя, сё нельзя". Скажем, в транспортный режим IPSec он не умеет, адресация внутренних концов GRE-тоннеля должна отличаться от внешней.
Решение.
Конфиг на Juniper SRX.
INTERFACES ([edit interfaces])
gr-0/0/0 {
unit 3 {
description "IPSec/GRE Tunnel to SomeWhere";
tunnel {
source 192.168.0.1;
destination 192.168.0.2;
}
family inet {
mtu 1400;
address 192.168.0.5/30;
}
}
}
lo0 {
unit 0 {
family inet {
address 213.180.193.1/32 {
primary;
}
}
}
st0 {
unit 0 {
description "GRE/IPSEC Tunnel to SomeWhere";
family inet {
address 192.168.0.1/32;
}
}
IKE ([edit security ike])
proposal phase1-proposal {
authentication-method pre-shared-keys;
dh-group group20;
encryption-algorithm aes-256-gcm;
lifetime-seconds 86400;
}
policy phase1-policy {
mode main;
description "IPSec-GRE to SomeWhere";
proposals phase1-proposal;
pre-shared-key ascii-text "SuperDooperPooperPassword";
}
gateway to-somewhere-gate {
ike-policy phase1-policy;
address 93.158.134.1;
no-nat-traversal;
external-interface lo0.0;
local-address 213.180.193.1;
version v2-only;
}
IPSEC ([edit security ipsec])
proposal phase2-proposal {
protocol esp;
encryption-algorithm aes-256-gcm;
lifetime-seconds 3600;
}
policy phase2-policy {
description "GRE-IPSec tunnel to SomeWhere";
proposals phase2-proposal;
}
vpn somewhere-vpn {
bind-interface st0.0;
ike {
gateway to-somewhere-gate;
ipsec-policy phase2-policy;
}
traffic-selector gre-endpoints {
local-ip 192.168.0.1/32;
remote-ip 192.168.0.2/32;
}
establish-tunnels immediately;
}
SECURITY ([edit security zones])
security-zone decrypted-gre-endpoints {
description "GRE-encapsulated but already decrypted tunnel endpoints";
host-inbound-traffic {
system-services {
ping;
traceroute;
}
}
interfaces {
st0.0;
}
}
security-zone somewhere-remote {
description "Iface of GRE-decapsulated traffic to/from SomeWhere";
host-inbound-traffic {
system-services {
ping;
traceroute;
}
}
interfaces {
gr-0/0/0.3;
}
}
ROUTES ([edit routing-options static])
route 172.16.2.0/24 {
next-hop 192.168.0.6;
no-readvertise;
}
Конфиг на Linux (сравните размер и читабельность).
/etc/network/interfaces
auto lo
iface lo inet loopback
auto dummy0
iface dummy0 inet static
address 192.168.0.2/32
pre-up /bin/ip link add $IFACE type dummy
post-down /bin/ip link delete $IFACE
auto gre1
iface gre1 inet static
address 192.168.0.6/30
pre-up /bin/ip link add name $IFACE type gre local 192.168.0.2 remote 192.168.0.1
post-down /bin/ip link delete $IFACE
mtu 1400
up /bin/ip route add 172.16.1.0/24 via 192.168.0.5 src 172.16.2.1
auto eth0
iface eth0 inet static
address 172.16.2.1/24
auto eth1
iface eth1 inet static
address 93.158.134.1/24
gateway 93.158.134.254
/etc/ipsec.conf
conn Metropoly
leftsubnet=192.168.0.2/32
rightsubnet=192.168.0.1/32
keyexchange=ikev2
rightauth=psk
leftauth=psk
left=93.158.134.1
right=213.180.193.1
auto=start
type=tunnel
ike=aes256gcm16-prfsha384-ecp384
esp=aes256gcm16
ikelifetime=24h
lifetime=1h
mobike=no
/etc/ipsec.secrets
93.158.134.1 213.180.193.1 : PSK "SuperDooperPooperPassword"
Проверено, работает.
P.S. Смотрите, сейчас придёт какой-то козёл и на радостях зачем-то откомментирует этот псто целых два раза.