tun
(للأنفاق على مستوى IP) وواجهات tap
(للأنفاق على مستوى Ethernet). عملياً، تستخدم واجهات tun
في معظم الحالات إلا في حال الرغبة بدمج عملاء VPN مع شبكة المخدم المحلية عبر جسر Ethernet.
pki/ca.crt
) will be stored on all machines (both server and clients) as /etc/ssl/certs/Falcot_CA.crt
. The server's certificate is installed only on the server (pki/issued/vpn.falcot.com.crt
goes to /etc/ssl/certs/vpn.falcot.com.crt
, and pki/private/vpn.falcot.com.key
goes to /etc/ssl/private/vpn.falcot.com.key
with restricted permissions so that only the administrator can read it), with the corresponding Diffie-Hellman parameters (pki/dh.pem
) installed to /etc/openvpn/dh.pem
. Client certificates are installed on the corresponding VPN client in a similar fashion.
/etc/openvpn/*.conf
. Setting up a VPN server is therefore a matter of storing a corresponding configuration file in this directory. A good starting point is /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz
, which leads to a rather standard server. Of course, some parameters need to be adapted: ca
, cert
, key
and dh
need to describe the selected locations (respectively, /etc/ssl/certs/Falcot_CA.crt
, /etc/ssl/vpn.falcot.com.crt
, /etc/ssl/private/vpn.falcot.com.key
and /etc/openvpn/dh.pem
). The server 10.8.0.0 255.255.255.0
directive defines the subnet to be used by the VPN; the server uses the first IP address in that range (10.8.0.1
) and the rest of the addresses are allocated to clients.
tun0
name. However, firewalls are often configured at the same time as the real network interfaces, which happens before OpenVPN starts. Good practice therefore recommends creating a persistent virtual network interface, and configuring OpenVPN to use this pre-existing interface. This further allows choosing the name for this interface. To this end, openvpn --mktun --dev vpn --dev-type tun
creates a virtual network interface named vpn
with type tun
; this command can easily be integrated in the firewall configuration script, or in an up
directive of the /etc/network/interfaces
file, or a udev rule can be added to that end. The OpenVPN configuration file must also be updated accordingly, with the dev vpn
and dev-type tun
directives.
10.8.0.1
. للسماح للعملاء بالوصول إلى الشبكة المحلية (192.168.0.0/24)، يجب إضافة تعليمة push route 192.168.0.0 255.255.255.0
إلى إعدادات OpenVPN بحيث يحصل عملاء VPN تلقائياً على مسار توجيه شبكي يبين لهم أن الوصول لهذه الشبكة يتم عبر VPN. بالإضافة لهذا، يجب إعلام الأجهزة في الشبكة المحلية أيضًا أن الوصول إلى شبكة VPN يتم عبر مخدم VPN (هذه هي الحالة الافتراضية إذا كان مخدم VPN منصب على بوابة الشبكة المحلية). أو يمكن ضبط مخدم VPN لإجراء تنكر لعناوين IP بحيث تبدو الاتصالات الواردة من عملاء VPN كما لو كانت ترد من مخدم VPN (انظر قسم 10.1, “البوابات”).
/etc/openvpn/
. يمكن الاستعانة بالملف /usr/share/doc/openvpn/examples/sample-config-files/client.conf
للحصول على إعداد قياسي. تُعرِّف التعلمية التوجيهية remote vpn.falcot.com 1194
عنوان مخدم OpenVPN ورقم المنفذ؛ يجب أيضًا تعديل ca
، cert
، وkey
بحيث تشير إلى مواقع ملفات المفاتيح.
AUTOSTART
directive to none
in the /etc/default/openvpn
file. Starting or stopping a given VPN connection is always possible with the commands systemctl start openvpn@name
and systemctl stop openvpn@name
(where the connection name matches the one defined in /etc/openvpn/name.conf
).
tun*
) على طرفي اتصال SSH، ويمكن إعداد هذه الواجهات الظاهرية تماماً كما لو كانت واجهات فيزيائية. يجب أولاً تفعيل نظام الأنفاق من خلال ضبط قيمة الخيار PermitTunnel
على ”yes“ في ملف إعداد مخدم SSH (/etc/ssh/sshd_config
). عند إنشاء اتصال SSH، يجب طلب إنشاء النفق صراحة باستخدام الخيار -w any:any
(يمكن استبدال any
برقم جهاز tun
المرغوب). هذا يتطلب من المستخدم تقديم صلاحيات مدير النظام على طرفي الاتصال، وذلك حتى يتمكن من إنشاء الجهاز الشبكي (بكلمات أخرى، يجب بدء الاتصال بصلاحيات root).
/etc/ipsec.conf
contains the parameters for IPsec tunnels (or Security Associations, in the IPsec terminology) that the host is concerned with. There are many configuration examples in /usr/share/doc/libreswan/
, but Libreswan's online documentation has more examples with explanations:
systemctl
; for example, systemctl start ipsec
will start the IPsec service.
/etc/ppp/options.pptp
، /etc/ppp/peers/falcot
، /etc/ppp/ip-up.d/falcot
، و /etc/ppp/ip-down.d/falcot
.
مثال 10.2. الملف /etc/ppp/options.pptp
# PPP options used for a PPTP connection lock noauth nobsdcomp nodeflate
مثال 10.3. الملف /etc/ppp/peers/falcot
# vpn.falcot.com is the PPTP server pty "pptp vpn.falcot.com --nolaunchpppd" # the connection will identify as the "vpn" user user vpn remotename pptp # encryption is needed require-mppe-128 file /etc/ppp/options.pptp ipparam falcot
pptpd
هو مخدم PPTP في لينكس. لا يحتاج ملف إعداداته الرئيسي، /etc/pptpd.conf
، إلا لبعض التغييرات القليلة: localip (عنوان IP المحلي)، وremoteip (عنوان IP البعيد). في المثال التالي، يمتلك مخدم PPTP العنوان 192.168.0.199
دوماً، أما عملاء PPTP فيأخذون العناوين من 192.168.0.200
وحتى 192.168.0.250
.
مثال 10.6. الملف /etc/pptpd.conf
# TAG: speed # # Specifies the speed for the PPP daemon to talk at. # speed 115200 # TAG: option # # Specifies the location of the PPP options file. # By default PPP looks in '/etc/ppp/options' # option /etc/ppp/pptpd-options # TAG: debug # # Turns on (more) debugging to syslog # # debug # TAG: localip # TAG: remoteip # # Specifies the local and remote IP address ranges. # # You can specify single IP addresses separated by commas or you can # specify ranges, or both. For example: # # 192.168.0.234,192.168.0.245-249,192.168.0.254 # # IMPORTANT RESTRICTIONS: # # 1. No spaces are permitted between commas or within addresses. # # 2. If you give more IP addresses than MAX_CONNECTIONS, it will # start at the beginning of the list and go until it gets # MAX_CONNECTIONS IPs. Others will be ignored. # # 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238, # you must type 234-238 if you mean this. # # 4. If you give a single localIP, that's ok - all local IPs will # be set to the given one. You MUST still give at least one remote # IP for each simultaneous client. # #localip 192.168.0.234-238,192.168.0.245 #remoteip 192.168.1.234-238,192.168.1.245 #localip 10.0.1.1 #remoteip 10.0.1.2-100 localip 192.168.0.199 remoteip 192.168.0.200-250
/etc/ppp/pptpd-options
. المتغيرات المهمة هي اسم المخدم (pptp
)، واسم النطاق (falcot.com
)، وعناوين IP لمخدمات DNS و WINS.
مثال 10.7. الملف /etc/ppp/pptpd-options
## turn pppd syslog debugging on #debug ## change 'servername' to whatever you specify as your server name in chap-secrets name pptp ## change the domainname to your local domain domain falcot.com ## these are reasonable defaults for WinXXXX clients ## for the security related settings # The Debian pppd package now supports both MSCHAP and MPPE, so enable them # here. Please note that the kernel support for MPPE must also be present! auth require-chap require-mschap require-mschap-v2 require-mppe-128 ## Fill in your addresses ms-dns 192.168.0.1 ms-wins 192.168.0.1 ## Fill in your netmask netmask 255.255.255.0 ## some defaults nodefaultroute proxyarp lock
vpn
(وكلمة سره) في الملف /etc/ppp/chap-secrets
. يجب تعبئة اسم المخدم بشكل صريح هنا، بخلاف الحالات الأخرى حيث يمكن استخدام النجمة (*
) فيها. بالإضافة لذلك، تعرّف عملاء PPTP التي تعمل على ويندوز نفسها بالشكل DOMAIN\\USER
، بدلاً من تقديم اسم المستخدم فقط. هذا يفسر وجود المستخدم FALCOT\\vpn
في الملف. من الممكن أيضاً تحديد عناوين IP الخاصة بالمستخدمين؛ استخدام النجمة في هذا الحقل يدل على أننا نريد استخدام العنونة الديناميكية.