إنشاء L2TP/IPSEC VPN

من Arabic Ikoula Wiki
مراجعة ١٢:٣٦، ٩ فبراير ٢٠١٧ بواسطة Ikbot (نقاش | مساهمات) (أنشأ الصفحة ب'<br />هام: تمت ترجمة هذه المقال باستخدام برامج للترجمة الآلية, لقرائة النسخة الأصلية :fr:Mettre en pla...')
(فرق) → مراجعة أقدم | المراجعة الحالية (فرق) | مراجعة أحدث ← (فرق)
Jump to navigation Jump to search


هام: تمت ترجمة هذه المقال باستخدام برامج للترجمة الآلية, لقرائة النسخة الأصلية أنقر على الرابط

مقدمة

VPN (شبكة اتصال خاصة ظاهرية) est un système permettant de créer un lien direct entre des ordinateurs distants. On utilise notamment ce terme dans le milieu de la dématérialisation fiscale et dans le travail à distance, ainsi que pour l'accès à des structures de type سحابة الحوسبة. L'avantage du L2TP (طبقة 2 بروتوكول تونيلينج) réside dans l'utilisation d'une clé pré partagée en plus des identifiants de connexion habituels. A cela s'ajoute IPSEC, une technologie d'encapsulation cryptée dans la trame IP.

المتطلبات الأساسية

يجب عليك اتباع هذا البرنامج التعليمي :

  • آلة تحت توزيع لينكس (دبيان 8فيدورا، CentOS، أوبونتو، Pi التوت...) لا تعمل تحت ديبيان 8 بسبب مستودع OpenSwan التي لم تعد موجودة
  • يعرف عنوان ip العام الخاص بك، إذا كنت لا تعرف هنا!

البرنامج التعليمي

أولاً، تسجيل في جذر (أو عن طريق مستخدم الذي لديه حقوق مستخدم متميز). يمكنك استخدام المعجون للاتصال جهاز عن بعد عن طريق SSH أو ببساطة فتح المعبر إذا كان لديك حق الوصول إلى واجهة رسومية للجهاز الخاص بك.

حزم التحديث والتثبيت

أولاً، تحديث الجهاز الخاص بك وتثبيت المستودع اللازمة :

apt-get update && apt-get upgrade -y
apt-get install openswan xl2tpd ppp lsof

OpenSwan سوف يسألك بعض الأسئلة، الإجابة y مع القيم الافتراضية.'.

إضافة قواعد جدار الحماية

ثم سنقوم بإضافة قاعدة إلى [ايبتبلس] للسماح بحركة مرور VPN (استبدال %سيرفيريب% بالملكية الفكرية من الخاص بك خادم) :

iptables -t nat -A POSTROUTING -j SNAT --to-source %سيرفيريب% -o eth0


قم بتشغيل الأوامر التالية لتمكين توجيه حزم IP:

echo "net.ipv4.ip_forward = 1" |  tee -a /etc/sysctl.conf
echo "net.ipv4.conf.all.accept_redirects = 0" |  tee -a /etc/sysctl.conf
echo "net.ipv4.conf.all.send_redirects = 0" |  tee -a /etc/sysctl.conf
echo "net.ipv4.conf.default.rp_filter = 0" |  tee -a /etc/sysctl.conf
echo "net.ipv4.conf.default.accept_source_route = 0" |  tee -a /etc/sysctl.conf
echo "net.ipv4.conf.default.send_redirects = 0" |  tee -a /etc/sysctl.conf
echo "net.ipv4.icmp_ignore_bogus_error_responses = 1" |  tee -a /etc/sysctl.conf
for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done
sysctl -p

جعل المستمرة لإعادة تشغيل الجهاز :

nano /etc/rc.local

ثم، تضاف إلى نهاية قبل قم بإنهاء 0 :

for vpn in /proc/sys/net/ipv4/conf/*; do echo 0 > $vpn/accept_redirects; echo 0 > $vpn/send_redirects; done
iptables -t nat -A POSTROUTING -j SNAT --to-source %سيرفيريب% -o eth+


تنفيذIPSEC


قم بإنشاء ملف تكوين جديد ipsec :

mv /etc/ipsec.conf /etc/ipsec.conf.bak && nano /etc/ipsec.conf

عصا ثم هذا : ولا ننسى أن يحل محل %SERVERIP% حسب عنوان IP خادم

version 2 # conforms to second version of ipsec.conf specification

config setup
    dumpdir=/var/run/pluto/
    #in what directory should things started by setup (notably the Pluto daemon) be allowed to dump core?

    nat_traversal=yes
    #whether to accept/offer to support NAT (NAPT, also known as "IP Masqurade") workaround for IPsec

    virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v6:fd00::/8,%v6:fe80::/10
    #contains the networks that are allowed as subnet= for the remote client. In other words, the address ranges that may live behind a NAT router through which a client connects.

    protostack=netkey
    #decide which protocol stack is going to be used.

    force_keepalive=yes
    keep_alive=60
    # Send a keep-alive packet every 60 seconds.

conn L2TP-PSK-noNAT
    authby=secret
    #shared secret. Use rsasig for certificates.

    pfs=no
    #Disable pfs

    auto=add
    #the ipsec tunnel should be started and routes created when the ipsec daemon itself starts.

    keyingtries=3
    #Only negotiate a conn. 3 times.

    ikelifetime=8h
    keylife=1h

    ike=aes256-sha1,aes128-sha1,3des-sha1
    phase2alg=aes256-sha1,aes128-sha1,3des-sha1
    # https://lists.openswan.org/pipermail/users/2014-April/022947.html
    # specifies the phase 1 encryption scheme, the hashing algorithm, and the diffie-hellman group. The modp1024 is for Diffie-Hellman 2. Why 'modp' instead of dh? DH2 is a 1028 bit encryption algorithm that modulo's a prime number, e.g. modp1028. See RFC 5114 for details or the wiki page on diffie hellmann, if interested.

    type=transport
    #because we use l2tp as tunnel protocol

    left=%SERVERIP%
    #fill in server IP above

    leftprotoport=17/1701
    right=%any
    rightprotoport=17/%any

    dpddelay=10
    # Dead Peer Dectection (RFC 3706) keepalives delay
    dpdtimeout=20
    #  length of time (in seconds) we will idle without hearing either an R_U_THERE poll from our peer, or an R_U_THERE_ACK reply.
    dpdaction=clear
    # When a DPD enabled peer is declared dead, what action should be taken. clear means the eroute and SA with both be cleared.

On crée ensuite le preshared secret (المفتاح المشترك قبل) :

nano /etc/ipsec.secrets

ثم أدخل هذا السطر :

%SERVERIP%  %any:   PSK "VotreClePlusOuMoinsSecurisee"

النظر في استبدال %SERVERIP% par l'IP de votre خادم. Si vous séchez pour la création de votre clé vous pouvez utilisez la commande suivante :

openssl rand -hex 30


علينا التحقق من أن كل شيء على ما يرام، حيث يمكنك استخدام هذا الأمر :

ipsec verify

ويجب أن تحصل :

Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path                                 [OK]
Linux Openswan U2.6.38/K3.13.0-24-generic (netkey)
Checking for IPsec support in kernel                            [OK]
 SAref kernel support                                           [N/A]
 NETKEY:  Testing XFRM related proc values                      [OK]
    [OK]
    [OK]
Checking that pluto is running                                  [OK]
 Pluto listening for IKE on udp 500                             [OK]
 Pluto listening for NAT-T on udp 4500                          [OK]
Checking for 'ip' command                                       [OK]
Checking /bin/sh is not /bin/dash                               [WARNING]
Checking for 'iptables' command                                 [OK]
Opportunistic Encryption Support                                [DISABLED]

Configuration de xl2tpd

دعونا نبدأ بتحرير ملف تكوين جديد :

mv /etc/xl2tpd/xl2tpd.conf /etc/xl2tpd/xl2tpd.conf.bak && nano /etc/xl2tpd/xl2tpd.conf

عصا ثم هذا :

[global]
ipsec saref = yes
saref refinfo = 30

;debug avp = yes
;debug network = yes
;debug state = yes
;debug tunnel = yes

[lns default]
ip range = 172.16.1.30-172.16.1.100
local ip = 172.16.1.1
refuse pap = yes
require authentication = yes
;ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

تكوين PPP

لهذا الجزء، مرة أخرى سيتم إنشاء ملف تكوين جديد (الجديد أيضا في جملة واحدة :3) :

mv /etc/ppp/options.xl2tpd /etc/ppp/options.xl2tpd.bak && nano /etc/ppp/options.xl2tpd

ثم قم بإدراج هذا :

require-mschap-v2
ms-dns 8.8.8.8
ms-dns 8.8.4.4
auth
mtu 1200
mru 1000
crtscts
hide-password
modem
name l2tpd
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4

هنا، أنا استخدم نظام أسماء النطاقات العامة إلى جوجل، مجاناً لتتمكن من تعديل واستخدام تلك اختيارك ! ;)

إضافة مستخدمين

وأخيراً ! هذه الخطوة الحاسمة سوف يسمح لك لتعيين تسجيل الدخول وكلمات المرور للمستخدمين vpn الخاص بك، وتحرير هذا الملف فقط :

nano /etc/ppp/chap-secrets

أسفل خط نموذجية:

jean          l2tpd   0F92E5FC2414101EA            *


الاهتمام : هذا الملف قضية حساسة، إذا قمت بوضع حرف، تحتاج إلى الاحتفاظ بها عند كتابة تسجيل الدخول أو كلمة المرور الخاصة بك.

وأخيراً قم بإعادة تشغيل :

/etc/init.d/ipsec restart && /etc/init.d/xl2tpd restart



تبدو هذه المادة مفيدة لك ?

0



ليس مسموح لك بأن تنشر تعليقا.