IPSEC چیست ؟
IPsec (Internet Protocol Security) یک پروتکل امنیتی برای ایجاد ارتباطات امن در شبکههای اینترنتی است. این پروتکل برای محافظت از ارتباطات شبکه، اعمال مکانیزمهای رمزنگاری و احراز هویت بین دو یا چندین دستگاه در شبکه استفاده میشود.
IPsec اجازه میدهد تا دادههایی که از یک دستگاه به دیگری ارسال میشوند، به صورت رمزنگاری شده ارسال شوند تا از تهدیدهایی مانند تقلب، تغییر داده شدن در حین ارسال و مشاهده دادهها توسط افراد غیرمجاز جلوگیری شود. همچنین، IPsec میتواند برای احراز هویت دستگاهها و اجازه دسترسی به منابع شبکه نیز استفاده شود.
IPsec معمولاً برای ایجاد تونلهای امن بین شبکههای مختلف، اتصالات از راه دور به شبکه، ارتباطات VoIP امن و سایر حوزههایی که نیازمند امنیت بالا هستند، استفاده میشود.
مزایای ipsec
IPsec (Internet Protocol Security) دارای مزایای متعددی است که آن را به یک پروتکل امنیتی محبوب برای اتصالات شبکه تبدیل کرده است. برخی از مزایای اصلی IPsec عبارتند از:
رمزنگاری قوی: IPsec از الگوریتمهای رمزنگاری قوی مانند AES و 3DES برای محافظت از دادهها استفاده میکند که امنیت بالایی را فراهم میکند.
احراز هویت: IPsec از مکانیزمهای احراز هویت مختلفی مانند پسوردها، کلیدهای اشتراکی (Pre-shared Keys) و گواهینامههای دیجیتال برای اطمینان از اینکه فقط دستگاههای معتبر میتوانند به شبکه دسترسی پیدا کنند.
مقاومت در برابر حملات افزودن و سرنگونی (Replay and Man-in-the-Middle Attacks): IPsec از مکانیزمهایی برای جلوگیری از حملات افزودن (Replay Attacks) و حملات سرنگونی (Man-in-the-Middle Attacks) استفاده میکند که اطمینان میدهد دادهها در طول ارتباطات امن باقی بمانند.
پشتیبانی از تونلهای VPN: IPsec به عنوان یکی از پروتکلهای اصلی برای ایجاد تونلهای امن VPN بین شبکههای مختلف یا دستگاههای از راه دور استفاده میشود.
اتصالات امن از راه دور: IPsec به ارائه امکانات امنیتی برای اتصالات از راه دور برای کارمندانی که از دور کار میکنند، کمک میکند. این امکان اتصال از راه دور را به شبکه داخلی با امنیت بالا ارائه میدهد.
قابلیت اعتماد: IPsec یک استاندارد بینالمللی است که توسط انجمن IETF تعریف شده است و به عنوان یکی از راهحلهای امنیتی اصلی در اینترنت مورد اعتماد استفاده میشود.
به طور کلی، IPsec امنیت، اعتماد و حفاظت در ارتباطات شبکه را فراهم میکند و به شرکتها و سازمانها کمک میکند تا اطلاعات خود را در شبکههای اینترنتی به شکلی امن انتقال دهند.
راه اندازی site to site VPN با روتر میکروتیک
در اینجا یک آموزش سریع در مورد نحوه ایجاد تونل IPSec Site To Site VPN با Mikrotik RouterOS در هر دو سمت آورده شده است
پیکربندی در محیط لابراتور
شعبه 1:
روتر1:
WAN IP: 192.168.155.131/24
Default Gateway: 192.168.155.2/24
Local network: 10.50.50.0/24
PC1 : 10.50.50.2/24
شعبه 2:
روتر25:
WAN IP: 192.168.155.130/24
Default Gateway: 192.168.155.2/24
Local network: 192.168.11.0/24
PC2 : 192.168.11.2/24
بنابراین، من سعی می کنم زیر شبکه های محلی را از شعبه 1 (192.168.11.0/24) با زیر شبکه محلی در شعبه 2 (10.50.50.0/24) از طریق IPSec Site to Site tunnel متصل کنم.
من قصد دارم تنظیمات شعبه 1 را نشان دهم و شما باید این مراحل را در هر دو سمت تکرار کنید. همچنین اشاره خواهم کرد که تنظیمات شعبه 2 برای هر مرحله انجام شده در طول آموزش چگونه باید باشد.
من نحوه پیکربندی روتر شعبه1 را نشان خواهم داد، همان مراحل باید در روتر شعبه 2 انجام شود
Office 1:
Router 1:
WAN IP: 192.168.155.131/24
Default Gateway: 192.168.155.2/24
Local network: 10.50.50.0/24
PC1 : 10.50.50.2/24
ابتدا peer خود را تعریف می کنیم. Peer روتر از شعبه 2 و آدرس IP عمومی آن (192.168.155.130) خواهد بود.
IP | IPSec | tab Peers | click on Plus (+) sign
یک نام برای ipsec انتخاب کرده و در فیلد آدرس, IP WAN Adress 2 روتر شعبه 2 (192.168.155.130) وارد میکنم. من همچنین Exchange Mode: را به IKE2 تغییر خواهم داد.
بقیه تنظیمات به همین شکل باقی خواهند ماند. OK را اعمال کنید.
شعبه2 – برای شعبه2 این پیکربندی خواهد بود – Router1، 192.168.155.131، IKE2)
I
ایستگاه بعدی تب Identities است
IP | IPSec | tab Identities| click on Plus (+) sign
Peer is going to be Router2, Authentication Method – pre shared key, and in Secret field you will enter password. Remember this password, as it is needed on both sides of the tunnel.
Also, if you are using pre shared key in your production IPSec environment, make sure that it is more than 20 signs (letters, numbers, special characters) long.
Leave the rest as default.
(Office2 – for Office2 this configuration will be – Router1, same Secret as entered in Office 1 on Router 1)
Proposals
Now I’m going to configure Proposals.
IP | IPSec | tab Proposals| click on *default configuration to edit it
I’m just going to modify default rule for this tutorial. This tab is completely up to you, on how you want to configure it. As Auth. Algorithms I’m going to select sha256, for Encr.Alghorithms aes-256 cbc, lifetime will be 30 minutes and PFS Group modp2048.
Generally, the more secure alghoritms, the better. I would not recommend md5 or sha1 anymore, but will have to decide for yourself. Security should be priority in network communication these days.
Make sure you have the same Proposal configuration on both sides.
(Office2 – for Office2 this configuration has to be the same as the one in Office 1 on Router 1)
Profiles
Again, for this tutorial I will just edit default Profile created.
IP | IPSec | tab Profiles| click on *default configuration to edit it
Again, the same rule as for Priorities tab. Select what you see best fit, avoid weak algorithms.
Hash Algorithms: sha256, Encryption Algorithm: aes-256, DH Group: modp2048, Proposal check: obey, lifetime – 1day, NAT Traversal – checked, DPD Maximum Failure 5. Apply – OK.
Make sure you have same settings on both sides.
(Office2 – for Office2 this configuration has to be the same as the one in Office 1 on Router 1)
Policies
IP | IPSec | tab Policies| click on Plus (+) sign
On General Tab of the New IPSec Policy, under Peer I will selected created Peer – Router2. I will also check Tunnel, In Src.Address I will enter LAN subnet of local Office1 – 10.50.50.0/24. Under Dst.Address I will enter remote LAN subnet of the remote Office2 – 192.168.11.0/24 and I will leave everything else default.
(Office2 – for Office2 this configuration with addresses in different order – Router1, Tunnel checked, Src Address: 192.168.11.0/24, Dst Address 10.50.50.0/24 )
Next in Action tab I will leave everything default.
(Office2 – for Office2 this configuration is the same)
Status Tab – there is nothing to change, it is just status of the connection with public IPs from Peer.
(Office2 – for Office2 this configuration is the same)
Now, when you finish this same configuration on Office2 (of course with differences in IP settings, as mentioned during tutorial), when you are done with creating policy, you should see this on Policy screen.
Under PH2 State, there should be established state.
Under Active Peers situation should look like this
And Installed SAs should also be created.
This is what established channel looks like.
Now if you are unable to establish IPSec tunnel, there are a lot of issues that can be reason for this – first, double check all your IPSec settings (Peer, Proposals, Secret, Profile, Policy…)
Check your routing, gateway, NAT and firewall settings (in some case port 500, 4500, 50 and few more needs to go through).
I got a lot of issues with IPSec in the past, and reasons for problems were different, and sometimes very hard to pinpoint.
Now, on local PCs both in Office1 and Office2 I started ping command, but no luck
I started pinging Office1 PC1 10.50.50.2 from Office 2 PC2 192.168.11.1