How to Build Ipsec Site to Site Vpn With Vyos and Pfsense

How to build ipse site-to-site VPN with vyos and pfsense

Vyos VS pfsense

For build all kinds of network functions like nat,firewall, site-to-site vpn , dial in vpn with pfsense.It works well. But it has some Crons:

  1. Hard to upgrade version, it manybe crashed
  2. Didn’t support API.
  3. Heavy loading and low performance.

After try to replace pfsense to build all functions with vyos. It has a lot of pros:

  1. Easy upgrade and rollback
  2. Support http and python api
  3. Support ansible deploy
  4. Command line operation,just like juniper and cisco.

Today I will show you how to build ipsec site-to-site vpn with vyos and pfsense

Prerequest

SITE ASITE B
WAN ADDRESS1.1.1.12.2.2.2
WAN Interfaceeth0eth0
LAN ADDRESS192.168.1.1/24192.168.2.1/24
LAN NETWORK192.168.1.0/24192.168.2.0/24
LAN Interfaceeth1eth1
OSVyospfsense
Pre-Shared Key*#JCenaoewaoi0298J299*8&^(%9))_&&*#JCenaoewaoi0298J299*8&^(%9))_&&

Configure vyos

Configure Site A

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
configure
set vpn ipsec ipsec-interfaces interface eth0
set vpn ipsec ike-group IKE-Default dead-peer-detection action 'hold'
set vpn ipsec ike-group IKE-Default dead-peer-detection interval '30'
set vpn ipsec ike-group IKE-Default dead-peer-detection timeout '120'
set vpn ipsec ike-group IKE-Default ikev2-reauth 'no'
set vpn ipsec ike-group IKE-Default key-exchange 'ikev2'
set vpn ipsec ike-group IKE-Default lifetime '10800'
set vpn ipsec ike-group IKE-Default mobike 'disable'
set vpn ipsec ike-group IKE-Default proposal 1 dh-group '14'
set vpn ipsec ike-group IKE-Default proposal 1 encryption 'aes256gcm128'
set vpn ipsec ike-group IKE-Default proposal 1 hash 'sha256'

set vpn ipsec esp-group ESP-Default compression 'disable'
set vpn ipsec esp-group ESP-Default lifetime '3600'
set vpn ipsec esp-group ESP-Default mode 'tunnel'
set vpn ipsec esp-group ESP-Default pfs 'dh-group14'
set vpn ipsec esp-group ESP-Default proposal 1 encryption 'aes256gcm128'
set vpn ipsec esp-group ESP-Default proposal 1 hash 'sha256'

set vpn ipsec site-to-site peer 2.2.2.2 authentication id '1.1.1.1'
set vpn ipsec site-to-site peer 2.2.2.2 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 2.2.2.2 authentication pre-shared-secret '*#JCenaoewaoi0298J299*8&^(%9))_&&'
set vpn ipsec site-to-site peer 2.2.2.2 authentication remote-id '2.2.2.2'
set vpn ipsec site-to-site peer 2.2.2.2 connection-type 'initiate'
set vpn ipsec site-to-site peer 2.2.2.2 ike-group 'IKE-Default'
set vpn ipsec site-to-site peer 2.2.2.2 ikev2-reauth 'inherit'
set vpn ipsec site-to-site peer 2.2.2.2 local-address '1.1.1.1'
set vpn ipsec site-to-site peer 2.2.2.2 tunnel 0 esp-group 'ESP-Default'
set vpn ipsec site-to-site peer 2.2.2.2 tunnel 0 local prefix '192.168.1.0/24'
set vpn ipsec site-to-site peer 2.2.2.2 tunnel 0 remote prefix '192.168.2.0/24'

Configure pfsense

Configure Site B

  1. After login pfsense click VPN | IPsec;
  2. Then click ‘Add P1` button.
  3. configuraton as show below

Add P1

General Information

KeyValue
Disableduncheck
Key Exchange versionIKEv2
Internet ProtocolIPv4
InterfaeWAN
Remote Gateway1.1.1.1
DescriptionSITE-A-VPN

Phase 1 Proposal (Authentication)

KeyValue
Authentication MethodMutual PSK
My identifierMy IP address
Peer identifierPeer IP address
Pre-Shared Key*#JCenaoewaoi0298J299*8&^(%9))_&&

Phase 1 Proposal(Encryption Algorithm)

KeyAlgorithmKey lengthHashDH Group
Encryption AlgorithmAES256-GCM128 bitsSHA25614(2048bit)
KeyValue
Lifetime(Seconds)28800

Advanced Options

KEYVALUE
Disable rekeyuncheck
Margintime(Secondsblack
Disable Reauthuncheck
Responder OnlyUncheck
MOBIKEDisable
Split connectionsuncheck
Dead Peer Dection‘Check on’ Enable DPD
Delay120
Max failures30

Add P2

General Information

KeyValue
Disableunchecked
ModeTunnel IPv4
Local networkNetwork 192.168.2.0/24
NAT/BINAT translationNone
Remote NetworkNetwork 192.168.1.0/24
DescriptionSite A

Phase 2 Proposal(SA/Key Exchange)

KeyValue
ProtocolESP
Encryption AlgorithmsAES256-GCM 128 bit
Hash AlgorithmsSHA256
PFS key group14(2048 bit)
Lifttime3600

Advanced Configuration

KeyValue
Automatically ping host192.168.1.1

Change firewall to allow ipsec vpn connection

ProtocolSourcePortDestinationPort
Ipv4 UDP1.1.1.1*WAN address500(ISAKMP)
IPv4 UDP1.1.1.1*WAN address4500(IPsec NAT-T)
Ipv4 ESP1.1.1.1*WAN address*

—The End—

Built with Hugo
Theme Stack designed by Jimmy