Π¦Π΅Π»Ρ
ΠΠ΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΎΡΠ³Π°Π½ΠΈΠ·ΠΎΠ²Π°ΡΡ VPN Tunnel ΠΌΠ΅ΠΆΠ΄Ρ Π΄Π²ΡΠΌΡ ΡΡΡΡΠΎΠΉΡΡΠ²Π°ΠΌΠΈ, ΡΠ°ΠΊΠΈΡ ΠΊΠ°ΠΊ Mikrotik ΠΈ Juniper Π»ΠΈΠ½Π΅ΠΉΠΊΠΈ SRX.
Π§ΡΠΎ ΠΈΠΌΠ΅Π΅ΠΌ
ΠΠ· ΠΌΠΈΠΊΡΠΎΡΠΈΠΊΠΎΠ² Π²ΡΠ±ΡΠ°Π»ΠΈ Π½Π° ΡΠ°ΠΉΡΠ΅ ΠΌΠΈΠΊΡΠΎΡΠΈΠΊΠ° Π²ΠΈΠΊΠΈ, ΠΌΠΎΠ΄Π΅Π»Ρ ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠΌΠΎΠΆΠ΅Ρ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡ Π°ΠΏΠΏΠ°ΡΠ°ΡΠ½ΠΎΠ΅ ΡΠΈΡΡΠΎΠ²Π°Π½ΠΈΠ΅ IPSec, Π½Π° Π½Π°Ρ Π²Π·Π³Π»ΡΠ΄ ΠΎΠ½Π° ΠΎΠΊΠ°Π·Π°Π»Π°ΡΡ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΠΊΠΎΠΌΠΏΠ°ΠΊΡΠ½Π°Ρ ΠΈ Π½Π΅Π΄ΠΎΡΠΎΠ³Π°Ρ, Π° ΠΈΠΌΠ΅Π½Π½ΠΎ Mikrotik hEXS.
USB Modem Π±ΡΠ» ΠΊΡΠΏΠ»Π΅Π½ Π² Π±Π»ΠΈΠΆΠ°ΠΉΡΠ΅ΠΌ ΡΠΎΡΠΎΠ²ΠΎΠΌ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ΅, ΠΌΠΎΠ΄Π΅Π»Ρ Π±ΡΠ»Π° Huawei E3370. ΠΠΈΠΊΠ°ΠΊΠΈΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ ΠΏΠΎ ΠΎΡΠ²ΡΠ·ΠΊΠΈ ΠΎΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ° ΠΌΡ Π½Π΅ ΠΏΡΠΎΠ²ΠΎΠ΄ΠΈΠ»ΠΈ. ΠΡΠ΅ ΡΡΠ°ΡΠ½ΠΎΠ΅ ΠΈ ΠΏΡΠΎΡΠΈΡΠΎ ΡΠ°ΠΌΠΈΠΌ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠΎΠΌ.
Π ΡΠ΄ΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ ΡΠ΅Π½ΡΡΠ°Π»ΡΠ½ΡΠΉ ΠΌΠ°ΡΡΡΡΡΠΈΠ·Π°ΡΠΎΡ Juniper SRX240H.
Π§ΡΠΎ ΡΠ΄Π°Π»ΠΎΡΡ
Π£Π΄Π°Π»ΠΎΡΡ ΡΠ΅Π°Π»ΠΈΠ·ΠΎΠ²Π°ΡΡ ΡΡ Π΅ΠΌΡ ΡΠ°Π±ΠΎΡΡ, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠ΅ΡΠ΅Π· ΡΠΎΡΠΎΠ²ΠΎΠ³ΠΎ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ°, Π½Π΅ ΠΈΠΌΠ΅Ρ ΡΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ³ΠΎ Π°Π΄ΡΠ΅ΡΠ°, ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²ΠΎΠΌ ΠΌΠΎΠ΄Π΅ΠΌΠ° ΡΠΎΠ·Π΄Π°ΡΡ IPsec ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΠ΅ Π² ΠΊΠΎΡΠΎΡΡΠΉ Π·Π°Π²ΠΎΡΠ°ΡΠΈΠ²Π°Π΅ΡΡΡ GRE Tunnel.
ΠΠ°Π½Π½Π°Ρ ΡΡ Π΅ΠΌΠ° ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΈ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ Π½Π° USB ΠΌΠΎΠ΄Π΅ΠΌΠ°Ρ ΠΠΈΠ»Π°ΠΉΠ½ ΠΈ ΠΠ΅Π³Π°ΡΠΎΠ½.
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ ΡΠ»Π΅Π΄ΡΡΡΠ°Ρ:
Π ΡΠ΄ΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ Juniper SRX240H
Local Address: 192.168.1.1/24
External Address: 1.1.1.1/30
GW: 1.1.1.2
Π£Π΄Π°Π»Π΅Π½Π½Π°Ρ ΡΠΎΡΠΊΠ°
Mikrotik hEX S
Local Address: 192.168.152.1/24
External Address: Dynamic
ΠΠ΅Π±ΠΎΠ»ΡΡΠ°Ρ Π΄ΠΈΠ°Π³ΡΠ°ΠΌΠΌΠ° Π΄Π»Ρ ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΡ ΡΠ°Π±ΠΎΡΡ:
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Juniper SRX240:
ΠΠ΅ΡΡΠΈΡ ΠΠ JUNOS Software Release [12.1X46-D82]
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Juniper
interfaces {
ge-0/0/0 {
description Internet-1;
unit 0 {
family inet {
address 1.1.1.1/30;
}
}
}
gr-0/0/0 {
unit 1 {
description GRE-Tunnel;
tunnel {
source 172.31.152.2;
destination 172.31.152.1;
}
family inet;
vlan {
unit 0 {
family inet {
address 192.168.1.1/24;
}
}
st0 {
unit 5 {
description "Area - 192.168.152.0/24";
family inet {
mtu 1400;
}
}
routing-options {
static {
route 0.0.0.0/0 next-hop 1.1.1.2;
route 192.168.152.0/24 next-hop gr-0/0/0.1;
route 172.31.152.0/30 next-hop st0.5;
}
router-id 192.168.1.1;
}
security {
ike {
traceoptions {
file vpn.log size 256k files 5;
flag all;
}
policy ike-gretunnel {
mode aggressive;
description area-192.168.152.0;
proposal-set standard;
pre-shared-key ascii-text "mysecret"; ## SECRET-DATA
}
gateway gw-gretunnel {
ike-policy ike-gretunnel;
dynamic inet 172.31.152.1;
external-interface ge-0/0/0.0;
version v2-only;
}
ipsec {
}
policy vpn-policy0 {
perfect-forward-secrecy {
keys group2;
}
proposal-set standard;
}
vpn vpn-gretunnel {
bind-interface st0.5;
df-bit copy;
vpn-monitor {
optimized;
source-interface st0.5;
destination-ip 172.31.152.1;
}
ike {
gateway gw-gretunnel;
no-anti-replay;
ipsec-policy vpn-policy0;
install-interval 10;
}
establish-tunnels immediately;
}
}
policies {
from-zone vpn to-zone vpn {
policy st-vpn-vpn {
match {
source-address any;
destination-address any;
application any;
}
then {
permit;
log {
session-init;
session-close;
}
count;
}
}
}
from-zone trust to-zone vpn {
policy st-trust-to-vpn {
match {
source-address any;
destination-address any;
application any;
}
then {
permit;
log {
session-init;
session-close;
}
count;
}
}
}
from-zone vpn to-zone trust {
policy st-vpn-to-trust {
match {
source-address any;
destination-address any;
application any;
}
then {
permit;
log {
session-init;
session-close;
}
count;
}
}
}
zones {
security-zone trust {
vlan.0 {
host-inbound-traffic {
system-services {
all;
}
protocols {
all;
}
}
}
security-zone vpn {
interfaces {
st0.5 {
host-inbound-traffic {
protocols {
ospf;
}
}
}
gr-0/0/0.1 {
host-inbound-traffic {
system-services {
all;
}
protocols {
all;
}
}
}
security-zone untrust {
interfaces {
ge-0/0/0.0 {
host-inbound-traffic {
system-services {
ping;
ssh;
ike;
}
}
}
}
}
vlans {
vlan-local {
vlan-id 5;
l3-interface vlan.1;
}
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Mikrotik hEX S:
ΠΠ΅ΡΡΠΈΡ ΠΠ RouterOS [6.44.3]
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Mikrotik
/ip address
add address=172.31.152.1/24 comment=GRE-Tunnel interface=gre-srx network=172.31.152.0
add address=192.168.152.1/24 comment=Local-Area interface=bridge network=192.168.152.0
/interface gre
add comment=GRE-Tunnel-SRX-HQ !keepalive local-address=172.31.152.1 name=gre-srx remote-address=172.31.152.2
/ip ipsec policy group
add name=srx-gre
/ip ipsec profile
add dh-group=modp1024 dpd-interval=10s name=profile1
/ip ipsec peer
add address=1.1.1.1/32 comment=GRE-SRX exchange-mode=aggressive local-address=172.31.152.1 name=peer2 profile=profile1
/ip ipsec proposal
set [ find default=yes ] enc-algorithms=aes-256-cbc,aes-128-cbc,3des
add enc-algorithms=aes-128-cbc,3des name=proposal1
/ip route
add distance=10 dst-address=192.168.0.0/16 gateway=gre-srx
/ip ipsec identity
add comment=IPSec-GRE my-id=address:172.31.152.1 peer=peer2 policy-template-group=srx-gre secret=mysecret
/ip ipsec policy
set 0 disabled=yes
add dst-address=0.0.0.0/0 proposal=proposal1 sa-dst-address=1.1.1.1 sa-src-address=172.31.152.1 src-address=172.31.152.0/30 tunnel=yes
/ip address
add address=172.31.152.1/24 comment=GRE-Tunnel interface=gre-srx network=172.31.152.0
add address=192.168.152.1/24 comment=Local-Area interface=bridge network=192.168.152.0
Π Π΅Π·ΡΠ»ΡΡΠ°Ρ:
Π‘ΠΎ ΡΡΠΎΡΠΎΠ½Ρ Juniper SRX
netscreen@srx240> ping 192.168.152.1
PING 192.168.152.1 (192.168.152.1): 56 data bytes
64 bytes from 192.168.152.1: icmp_seq=0 ttl=64 time=29.290 ms
64 bytes from 192.168.152.1: icmp_seq=1 ttl=64 time=28.126 ms
64 bytes from 192.168.152.1: icmp_seq=2 ttl=64 time=26.775 ms
64 bytes from 192.168.152.1: icmp_seq=3 ttl=64 time=25.401 ms
^C
--- 192.168.152.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 25.401/27.398/29.290/1.457 ms
Π‘ΠΎ ΡΡΠΎΡΠΎΠ½Ρ Mikrotik
net[admin@GW-LTE-] > ping 192.168.1.1
SEQ HOST SIZE TTL TIME STATUS
0 192.168.1.1 56 64 34ms
1 192.168.1.1 56 64 40ms
2 192.168.1.1 56 64 37ms
3 192.168.1.1 56 64 40ms
4 192.168.1.1 56 64 51ms
sent=5 received=5 packet-loss=0% min-rtt=34ms avg-rtt=40ms max-rtt=51ms
ΠΡΠ²ΠΎΠ΄Ρ
ΠΠΎΡΠ»Π΅ ΠΏΡΠΎΠ΄Π΅Π»Π°Π½Π½ΠΎΠΉ ΡΠ°Π±ΠΎΡΡ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠ»ΠΈ ΡΡΠ°Π±ΠΈΠ»ΡΠ½ΡΠΉ VPN Tunnel, ΠΈΠ· ΡΠ΄Π°Π»Π΅Π½Π½ΠΎΠΉ ΡΠ΅ΡΠΈ Π½Π°ΠΌ Π΄ΠΎΡΡΡΠΏΠ½Π° Π²ΡΠ΅ ΡΠ΅ΡΡ ΠΊΠΎΡΠΎΡΠ°Ρ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡΡ Π·Π° juniper, ΠΈ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²Π΅Π½Π½ΠΎ ΠΎΠ±ΡΠ°ΡΠ½ΠΎ.
ΠΠ΅ ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π² Π΄Π°Π½Π½ΠΎΠΉ ΡΡ
Π΅ΠΌΠ΅ IKE2, Π²ΠΎΠ·Π½ΠΈΠΊΠ°Π»Π° ΡΠΈΡΡΠ°ΡΠΈΡ ΡΡΠΎ ΠΏΠΎΡΠ»Π΅ ΠΏΠ΅ΡΠ΅Π·Π°Π³ΡΡΠ·ΠΊΠΈ ΡΠΎΠ³ΠΎ ΠΈΠ»ΠΈ ΠΈΠ½ΠΎΠ³ΠΎ ΡΡΡΡΠΎΠΉΡΡΠ²Π° Π½Π΅ ΠΏΠΎΠ΄Π½ΠΈΠΌΠ°Π΅ΡΡΡ IPSec.
ΠΡΡΠΎΡΠ½ΠΈΠΊ: habr.com