AWSNetworkPfsense

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi

AWS Site-to-Site VPN with PfSense – Step-by-Step Setup Guide

AWS to Pfsense Site to site VPN Configuration

Bu yazımda şirketlerin güncelik operasyonlarında olmazsa olmazı diyebileceğim Site to site VPN yapılandırmasının nasıl yapılacağını anlatacağım.

Konuya hakim olmayanlar için kısaca açıklamak gerekirse Site to site aralarında LAN bağlantısı kurulamayan 2 farklı networkü birleştirmek için kullanılan bir teknolojidir.

Detayları için amazonun sayfasını ziyaret edebilirsiniz.

Bu yazıda aşağıda topolojisini gördüğünüz AWS platformu ile on-premis yapınızı site to site VPN ile nasıl konuşturacağınızı Cloud ve local yapınızı hybrid bir mimariye nasıl çevirebileceğinizi anlatacağım.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 2

Topolojiyi basitçe özetlemek gerekirse AWS üzerindeki VPC üzerinde 3 AZ bulunmakta ve Local DC mizde 2 adet LAN networkümüz bulunmakta bu networkleri internernet üzerinden s2s vpn ile birbirine bağlayarak haberleştireceğiz.

AWS s2s Tunnel Mimarisi

AWS üzerinde bir s2s yapılandırdığınızda size 2 adet Tunnel bilgisi verdiğini görürsünüz aslında temel olarak 1 tunel bağlantısı yeterlidir fakat AWS bu yapının kesintisiz hizmet vermesi için 2 adet tunnel oluşturmakta.

Bu yapının temel amacını aşağıdaki başlıklarla özetleyebiliriz;

  • Yüksek Erişilebilirlik (High Availability)
  • Yük Dengeleme (Load Balancing) Desteği
  • Farklı AWS Bölgelerine Uzanım (AWS Global Network Redundancy)

Tünellerin Çalışma Modları

AWS VPN bağlantısında tünelleri iki farklı modda kullanabilirsin:

Aktif/Pasif (Active/Standby) Modu

  • Varsayılan olarak bir tünel aktif, diğeri pasif çalışır.
  • Ana tünel (Primary) çalışırken, yedek tünel (Secondary) yalnızca ana tünel düşerse devreye girer.
  • Statik route kullanıyorsan, AWS genellikle bu modeli önerir.

Aktif/Aktif (Active/Active) Modu

  • BGP ile dinamik yönlendirme kullanıyorsan, her iki tünel aynı anda trafik taşıyabilir.
  • Yük dengeleme (ECMP – Equal Cost Multi-Path Routing) ile trafiği her iki tünele de yayabilirsin.
  • BGP kullanmıyorsan, bu model çalışmaz.

Bu kadar ön bilgiden sonra artık başlayabiliriz.

AWS portal yapılandırma

Step1 – VPC →Customer gateways

bir adet Customer GW oluşturuyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 3

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 4

Step2 – VPC →Virtual Private GW

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 5

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 6

Hangi VPC ye VPN bağlantısı kurulacaksa ilgili VPC yi seçiyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 7

Step3- VPC → “site-to-site VPN connection”

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 8

ayarları aşağıdaki şekilde yapılandırıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 9

Alt bölümde şimdilik bir düzenleme yapmayacağız.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 10

Bu işlemlerden sonra AWS S2S confiğimizi tamamladık şimdi yapılandırdığımız ayarları aşağıdaki ekran göründüğü gibi download butonuna basarak “config” dosyamızı indireceğiz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 11

Burada hangi Firewall ile site-2-site VPN yapılacaksa marka model seçimini yapıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 12

Pfsense i seçerek config dosyasını indiriyoruz. AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 13

indirdiğimiz dosyamızın çıktısı aşağıdaki gibi olacaktır.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 14

Örnek dosya içeriği aşağıdaki gibidir.

! Amazon Web Services
! Virtual Private Cloud

! AWS utilizes unique identifiers to manipulate the configuration of
! a VPN Connection. Each VPN Connection is assigned an identifier and is
! associated with two other identifiers, namely the
! Customer Gateway Identifier and Virtual Private Gateway Identifier.
!
! Your VPN Connection ID 		  : vpn-015c92cf812efc872
! Your Virtual Private Gateway ID  : vgw-0db647e51d824f118
! Your Customer Gateway ID		  : cgw-0c345f7e76741a38f
!
!
! This configuration consists of two tunnels. Both tunnels must be
! configured on your Customer Gateway for redundancy.
!
! --------------------------------------------------------------------------------
! IPSec Tunnel #1
! --------------------------------------------------------------------------------
! #1: Internet Key Exchange (IKE) Configuration
!
! A policy is established for the supported ISAKMP encryption, authentication, Diffie-Hellman, lifetime,
! and key parameters.The IKE peer is configured with the supported IKE encryption,  authentication, Diffie-Hellman, lifetime, and key
! parameters.Please note, these sample configurations are for the minimum requirement of AES128, SHA1, and DH Group 2.
! Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
! You will need to modify these sample configuration files to take advantage of AES256, SHA256,  or other DH
! groups like 2, 14-18, 22, 23, and 24.
! NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.
!
! Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
! The address of the external interface for your customer gateway must be a static address.
! Your customer gateway may reside behind a device performing network address translation (NAT). To
! ensure that NAT traversal (NAT-T) can function, you must adjust your firewall
! rules to unblock UDP port 4500.
! If not behind NAT, and you are not using an Accelerated VPN, we recommend disabling NAT-T. If you are using an Accelerated VPN, make sure that NAT-T is enabled.
!
!
Go to VPN-->IPSec. Add a new Phase1 entry (click + button )

General information
 a. Disabled : uncheck
 b. Key Exchange version :V1
 c. Internet Protocol : IPv4
 d. Interface : WAN
 e. Remote Gateway: 46.137.38.181
 f. Description: Amazon-IKE-vpn-015c92cf812efc872-0

 Phase 1 proposal (Authentication)
 a. Authentication Method: Mutual PSK
 b. Negotiation mode : Main
 c. My identifier : My IP address
 d. Peer identifier : Peer IP address
 e. Pre-Shared Key: EYHI2I7mFQUZHukHcuIQw8C.gC5L16wd

 Phase 1 proposal (Algorithms)
 a. Encryption algorithm : aes128
 b. Hash algorithm :  sha1
 c. DH key group :  2
 d. Lifetime : 28800 seconds

 Advanced Options
 a. Disable Rekey : uncheck
 b. Responder Only : uncheck
 c. NAT Traversal : Auto
 d. Dead Peer Detection : Enable DPD
    Delay between requesting peer acknowledgement : 10 seconds
    Number of consecutive failures allowed before disconnect : 3 retries



! #2: IPSec Configuration
!
! The IPSec transform set defines the encryption, authentication, and IPSec
! mode parameters.
! Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
! Please note, you may use these additionally supported IPSec parameters for encryption like AES256 and other DH groups like 2, 5, 14-18, 22, 23, and 24.
! Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".

Expand the VPN configuration clicking in "+" and then create a new Phase2 entry as follows:

 a. Disabled :uncheck
 b. Mode : Tunnel
 c. Local Network : Type: LAN subnet
    Address :  ! Enter your local network CIDR in the Address tab
 d. Remote Network : Type : Network
    Address :  ! Enter your remote network CIDR in the Address tab
 e. Description : Amazon-IPSec-vpn-015c92cf812efc872-0

 Phase 2 proposal (SA/Key Exchange)
 a. Protocol : ESP
 b. Encryption algorithms : aes128
  c. Hash algorithms : hmac-sha1-96
  d. PFS key group :   2
e. Lifetime : 3600 seconds

Advanced Options

Automatically ping host : ! Provide the IP address of an EC2 instance in VPC that will respond to ICMP.


! --------------------------------------------------------------------------------


! --------------------------------------------------------------------------------
! IPSec Tunnel #2
! --------------------------------------------------------------------------------
! #1: Internet Key Exchange (IKE) Configuration
!
! A policy is established for the supported ISAKMP encryption, authentication, Diffie-Hellman, lifetime,
! and key parameters.The IKE peer is configured with the supported IKE encryption,  authentication, Diffie-Hellman, lifetime, and key
! parameters.Please note, these sample configurations are for the minimum requirement of AES128, SHA1, and DH Group 2.
! Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
! You will need to modify these sample configuration files to take advantage of AES256, SHA256,  or other DH
! groups like 2, 14-18, 22, 23, and 24.
! NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.
!
! Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".
! The address of the external interface for your customer gateway must be a static address.
! Your customer gateway may reside behind a device performing network address translation (NAT). To
! ensure that NAT traversal (NAT-T) can function, you must adjust your firewall
! rules to unblock UDP port 4500.
! If not behind NAT, and you are not using an Accelerated VPN, we recommend disabling NAT-T. If you are using an Accelerated VPN, make sure that NAT-T is enabled.
!
!
Go to VPN-->IPSec. Add a new Phase1 entry (click + button )

General information
 a. Disabled : uncheck
 b. Key Exchange version :V1
 c. Internet Protocol : IPv4
 d. Interface : WAN
 e. Remote Gateway: 52.51.70.188
 f. Description: Amazon-IKE-vpn-015c92cf812efc872-1

 Phase 1 proposal (Authentication)
 a. Authentication Method: Mutual PSK
 b. Negotiation mode : Main
 c. My identifier : My IP address
 d. Peer identifier : Peer IP address
 e. Pre-Shared Key: lBZzK_vKEja0j4Czzp27_kp2RmVrPcMb

 Phase 1 proposal (Algorithms)
 a. Encryption algorithm : aes128
 b. Hash algorithm :  sha1
 c. DH key group :  2
 d. Lifetime : 28800 seconds

 Advanced Options
 a. Disable Rekey : uncheck
 b. Responder Only : uncheck
 c. NAT Traversal : Auto
 d. Dead Peer Detection : Enable DPD
    Delay between requesting peer acknowledgement : 10 seconds
    Number of consecutive failures allowed before disconnect : 3 retries



! #2: IPSec Configuration
!
! The IPSec transform set defines the encryption, authentication, and IPSec
! mode parameters.
! Category "VPN" connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
! Please note, you may use these additionally supported IPSec parameters for encryption like AES256 and other DH groups like 2, 5, 14-18, 22, 23, and 24.
! Higher parameters are only available for VPNs of category "VPN," and not for "VPN-Classic".

Expand the VPN configuration clicking in "+" and then create a new Phase2 entry as follows:

 a. Disabled :uncheck
 b. Mode : Tunnel
 c. Local Network : Type: LAN subnet
    Address :  ! Enter your local network CIDR in the Address tab
 d. Remote Network : Type : Network
    Address :  ! Enter your remote network CIDR in the Address tab
 e. Description : Amazon-IPSec-vpn-015c92cf812efc872-1

 Phase 2 proposal (SA/Key Exchange)
 a. Protocol : ESP
 b. Encryption algorithms : aes128
  c. Hash algorithms : hmac-sha1-96
  d. PFS key group :   2
e. Lifetime : 3600 seconds

Advanced Options

Automatically ping host : ! Provide the IP address of an EC2 instance in VPC that will respond to ICMP.


! --------------------------------------------------------------------------------



! Additional Notes and Questions
!  - Amazon Virtual Private Cloud Getting Started Guide:
!       http://docs.amazonwebservices.com/AmazonVPC/latest/GettingStartedGuide
!  - Amazon Virtual Private Cloud Network Administrator Guide:
!       http://docs.amazonwebservices.com/AmazonVPC/latest/NetworkAdminGuide

Pfsense VPN Configuration

Tunnel 1 Configuration

Pfsense FW cihazımızda “VPN → IPSec” Menüsüne gidiyoruz ve “Add P1” diyerek bir VPN tunel oluşturma adımını başlatıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 15

Tunnel1 bölümünde yer alan bilgileri aşağıdaki şekilde giriyorum

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 16

Phase1 bölümünde yer alan bilgileri aşağıdaki şekilde dolduruyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 17

Son bölümü de aşağıdaki şekilde güncelleyerek kayıt ediyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 18

T1-P1

Save dediğimizde Tunnel1 i tamamlayarak aşağıdaki ekran görüntüsüne ulaşacağız.

Bizim yapımızda 2 adet subnetimiz var bu subnetlerin her biri için bir phase oluşturmamız gerekiyor şimdi Phaze1 için 192.168.1.0/ 24 subneti için oluşturuyorum.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 19

“Show Phase 2 Entires” diyerek 2. Phaz ı yapılandırmaya başlıyoruz “Add P2” diyerek devam ediyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 20

Bu bölümü de indirdiğimiz dosyadaki “#2: IPSec Configuration” başlığı altıda yer alan bilgilerle dolduracağız.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 21

Network Bölümünde Local den AWS e ulaşacak subnet bilgimi giriyorum Remote bölümüne de AWS üzerinde hangi subnete ulaşılacaksa bu bilgiyi giriyorum

Bu makalede 192.168.1.0/24 networkünden AWS üzerindeki 172.31.0.0/16 Networküne erişim sağlayacağız.

Phaze 2 adımında SHA1 ve PFS Key Group bilgilerini düzenliyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 22

Keep Alive bölümünde site to site yapacağımız karşı taraftan bir ip adresi girerek sistemin buraya ping gibi paketler görmesini sağlayarak Tüneli sürekli up tutabilirsiniz. Fakat bu bölüm isteğe bağlıdır ben karşı taraftaki bir sunucumun ip adresini giriyorum.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 23

Save diyerek yaptığımız değişiklikleri kayıt ediyoruz.

Tünel 1 için yapılandırma adımlarımızı tamamladık son durum aşağıdaki gibi görünüyor olacak.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 24

T1-P2

şimdi aynı işlemleri Phaze2 için tekrarlayıp sadece 192.168.2.0/24 subneti gireceğim “Add P” diyerek eklemeye devam ediyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 25

Yukarıda göründüğü gibi 192.168.2.0/24 networkünü giriyorum ve son görünüm aşağıdaki gibi olacak.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 26

Tunnel 2 Configuration

Bu bölümde de yukarıdaki adımları dökümana bakarak tekrarlayacağız “Add P1” diyerek devam ediyoruz.

Yukarıdaki adımları 2. Tunnel için de uyguluyorum phase 2 nin ekran görüntüleri aynı olduğu için bu bölümleri Tunnel 2 için eklemedim bunları aynı yolla eklemeniz gerekiyor.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 27

Bilgileri aşağıdaki şekilde giriyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 28

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 29

Save diyerek değişiklikleri kayıt ediyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 30

T2-P2

Tunel 2 nin “Phaze 2” adımı için “Add P2” ye tıklıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 31

Dökümanda bize verilen bilgiler giriyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 32

ve yukarıdaki işlemde yaptığımız gibi local ve aws netwokrlerini tanımlıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 33

Save e tıklayarak işlemi tamamlıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 34

Yaptığımız değişiklikleri “Apply Changes” diyerek kayıt ediyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 35

Yukarıdaki Menüden “Status → IPsec” yolunu takip ediyoruz.

Eğer yapınızda sadece tek bir subneti eklediyseniz aşağıdaki gibi görünecek.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 36

Yukarıdaki connect butonlarına basarsanız yada bir süre beklerseniz ve yapılandırmaları doğru yaptıysanız aşağıdaki şekilde her iki tünelinde bağlandığını göreceksiniz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 37

Ben 2. subneti daha sonradan ekledim ve 2 subnet için göreceğiniz görüntü aşağıdaki gibi olacak.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 38

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 39

Pfsense tarafındaki işlemlerimiz bu kadar şimdi AWS portaldan kontrolleri sağlayalım.

AWS Config S2s Check

Tekrar AWS Portalımıza dönüyoruz.

VPC→Site-to-site Menüsüne gelirsek ”Tunnel details” bölümünde her iki tünelimizinde up durumda olduğunu görüyorsanız bağlantımız başarıyla kurulmuş demektir.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 40

 

“Static route” tabına geçiyoruz burada on-prem networklerimizden hangi subnetler buraya girecekse bu adresler görünüyor olmalı biz tanımlarımızı “192.168.1.0/24, 192.168.2.0/24” e göre yapılandırdık.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 41

Yukarıda gördüğünüz ip adresinin VPC mize bağlı route tablosunda da yer alması gerekiyor “Route table” Menüsüne gidiyoruz gördüğünüz gibi onpremis ip adreslerim bu tabloda yok dilersek tabloya manual de ekleyebiliriz fakat bu şekilde olursa her yeni network eklendiğinde takip etmemiz gerekir biz bunu otomatik alacak şekilde yapılandıracağız.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 42

“Route propagation” tabına gidiyoruz edit seçeneğini seçiyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 43

Aşağıdaki şekilde Enable yapıyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 44

Sonraki adımda aşağıda gördüğünüz gibi 192.168.x.x networklerimin otomatik olarak route tablosuna eklenmiş olarak gelecek.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 45

Security Group Check

Tüm yapılandırmanızı tamamladık son adım olarak AWS üzerindeki Sanal makinemizin dahil olduğu “Security group” a giderek ping isteklerinin açık olup olmadığını kontrol ediyoruz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 46

Yukarıdaki ekran görüntüsünde de görüldüğü ICMP paketleri tüm adreslerden kontrole açık durumda.

Artık testimizi yapabiliriz ekran görüntüsüde gördüğünüz gibi 192.168.1.11 adresinden 172.31.32.159 adresine yapi AWS Cloud ortamına sağlıklı bir şekilde erişim sağlayabildilk.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 47

Aynı şekilde 192.168.2.10 adresinden 172.31.32.159 adresine de erişim yapabilmekteyiz.

AWS to PfSense Site-to-Site VPN | Detaylı Kurulum Rehberi 48

Bu makalemizde AWS ile pfsense FW arasında site to site bağlantı yapılandırmasını detaylarıyla aktardım.

Bir başka makalede görüşmek üzere.

Serdar BAYRAM

Serdar Bayram

Bu yazı blog üzerinde Serdar Bayram tarafından hazırlanıp paylaşılmıştır. 2009 yılında açılan blogum kısa zaman içerisinde paylasımları ile dikkat cekip büyük bir izleyici kitlesine sahip olmuştur.

İlgili Makaleler

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Başa dön tuşu