特殊:Badtitle/NS100:L2TPServer:修订间差异
小 以内容'{{From|https://help.ubuntu.com/community/L2TPServer}} {{Languages|UbuntuHelp:L2TPServer}} #title IPSec L2TP VPN Server Setup Guide This Guide will walk you through the pro…'创建新页面 |
小 →Debug |
||
第275行: | 第275行: | ||
---- | ---- | ||
[[ | [[UbuntuHelp:CategoryVPN]] |
2014年10月3日 (五) 23:49的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/L2TPServer }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/af | • {{#if: UbuntuHelp:L2TPServer|Afrikaans| [[::L2TPServer/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ar | • {{#if: UbuntuHelp:L2TPServer|العربية| [[::L2TPServer/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/az | • {{#if: UbuntuHelp:L2TPServer|azərbaycanca| [[::L2TPServer/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/bcc | • {{#if: UbuntuHelp:L2TPServer|جهلسری بلوچی| [[::L2TPServer/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/bg | • {{#if: UbuntuHelp:L2TPServer|български| [[::L2TPServer/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/br | • {{#if: UbuntuHelp:L2TPServer|brezhoneg| [[::L2TPServer/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ca | • {{#if: UbuntuHelp:L2TPServer|català| [[::L2TPServer/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/cs | • {{#if: UbuntuHelp:L2TPServer|čeština| [[::L2TPServer/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/de | • {{#if: UbuntuHelp:L2TPServer|Deutsch| [[::L2TPServer/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/el | • {{#if: UbuntuHelp:L2TPServer|Ελληνικά| [[::L2TPServer/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/es | • {{#if: UbuntuHelp:L2TPServer|español| [[::L2TPServer/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/fa | • {{#if: UbuntuHelp:L2TPServer|فارسی| [[::L2TPServer/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/fi | • {{#if: UbuntuHelp:L2TPServer|suomi| [[::L2TPServer/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/fr | • {{#if: UbuntuHelp:L2TPServer|français| [[::L2TPServer/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/gu | • {{#if: UbuntuHelp:L2TPServer|ગુજરાતી| [[::L2TPServer/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/he | • {{#if: UbuntuHelp:L2TPServer|עברית| [[::L2TPServer/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/hu | • {{#if: UbuntuHelp:L2TPServer|magyar| [[::L2TPServer/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/id | • {{#if: UbuntuHelp:L2TPServer|Bahasa Indonesia| [[::L2TPServer/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/it | • {{#if: UbuntuHelp:L2TPServer|italiano| [[::L2TPServer/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ja | • {{#if: UbuntuHelp:L2TPServer|日本語| [[::L2TPServer/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ko | • {{#if: UbuntuHelp:L2TPServer|한국어| [[::L2TPServer/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ksh | • {{#if: UbuntuHelp:L2TPServer|Ripoarisch| [[::L2TPServer/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/mr | • {{#if: UbuntuHelp:L2TPServer|मराठी| [[::L2TPServer/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ms | • {{#if: UbuntuHelp:L2TPServer|Bahasa Melayu| [[::L2TPServer/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/nl | • {{#if: UbuntuHelp:L2TPServer|Nederlands| [[::L2TPServer/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/no | • {{#if: UbuntuHelp:L2TPServer|norsk| [[::L2TPServer/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/oc | • {{#if: UbuntuHelp:L2TPServer|occitan| [[::L2TPServer/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/pl | • {{#if: UbuntuHelp:L2TPServer|polski| [[::L2TPServer/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/pt | • {{#if: UbuntuHelp:L2TPServer|português| [[::L2TPServer/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ro | • {{#if: UbuntuHelp:L2TPServer|română| [[::L2TPServer/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/ru | • {{#if: UbuntuHelp:L2TPServer|русский| [[::L2TPServer/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/si | • {{#if: UbuntuHelp:L2TPServer|සිංහල| [[::L2TPServer/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/sq | • {{#if: UbuntuHelp:L2TPServer|shqip| [[::L2TPServer/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/sr | • {{#if: UbuntuHelp:L2TPServer|српски / srpski| [[::L2TPServer/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/sv | • {{#if: UbuntuHelp:L2TPServer|svenska| [[::L2TPServer/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/th | • {{#if: UbuntuHelp:L2TPServer|ไทย| [[::L2TPServer/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/tr | • {{#if: UbuntuHelp:L2TPServer|Türkçe| [[::L2TPServer/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/vi | • {{#if: UbuntuHelp:L2TPServer|Tiếng Việt| [[::L2TPServer/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/yue | • {{#if: UbuntuHelp:L2TPServer|粵語| [[::L2TPServer/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/zh | • {{#if: UbuntuHelp:L2TPServer|中文| [[::L2TPServer/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/zh-hans | • {{#if: UbuntuHelp:L2TPServer|中文(简体)| [[::L2TPServer/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:L2TPServer | UbuntuHelp:L2TPServer | {{#if: | :}}L2TPServer}}/zh-hant | • {{#if: UbuntuHelp:L2TPServer|中文(繁體)| [[::L2TPServer/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:L2TPServer|:L2TPServer|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :L2TPServer/zh | | {{#ifexist: L2TPServer/zh | | {{#ifeq: {{#titleparts:L2TPServer|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:L2TPServer|1|-1|}} | zh | | }}
- title IPSec L2TP VPN Server Setup Guide
This Guide will walk you through the process of installing a L2TP VPN Server on Ubuntu Server 12.4
This configuration has been successfully tested with Android, Windows, and iOS devices.
Instructions
sudo apt-get install xl2tpd openswan ppp
IPSec / Openswan
In the /etc/ipsec.conf file copy:
config setup nat_traversal=yes virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:!10.152.2.0/24 #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. oe=off protostack=netkey conn L2TP-PSK-NAT rightsubnet=vhost:%priv also=L2TP-PSK-noNAT conn L2TP-PSK-noNAT authby=secret pfs=no auto=add keyingtries=3 rekey=no # Apple iOS doesn't send delete notify so we need dead peer detection # to detect vanishing clients dpddelay=30 dpdtimeout=120 dpdaction=clear # Set ikelifetime and keylife to same defaults windows has ikelifetime=8h keylife=1h type=transport # Replace IP address with your local IP (private, behind NAT IP is okay as well) left=x.x.x.x # For updated Windows 2000/XP clients, # to support old clients as well, use leftprotoport=17/%any leftprotoport=17/1701 right=%any rightprotoport=17/%any #force all to be nat'ed. because of iOS forceencaps=yes
Make sure you follow the setup in the ipsec.conf file, the part "config setup" and "conn l2tp-psk" should be to the very left while the other text 8 spaces to the right.
In the "/etc/ipsec.secrets" file copy:
x.x.x.x %any: PSK "somegoodpassword"
Replace x.x.x.x with your Server's IP
Start the IPSEC service with
/etc/init.d/ipsec start
Please verify the IPSEC service with :
sudo ipsec verify
you must get no errors.
Checking your system to see if IPsec got installed and started correctly: Version check and ipsec on-path [OK] Linux Openswan U2.6.28/K2.6.32-32-generic-pae (netkey) Checking for IPsec support in kernel [OK] NETKEY detected, testing for disabled ICMP send_redirects [OK] NETKEY detected, testing for disabled ICMP accept_redirects [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 for 'iptables' command [OK] Opportunistic Encryption Support [DISABLED]
Create a file called "ipsec.vpn" in "/etc/init.d/"
case "$1" in start) echo "Starting my Ipsec VPN" iptables -t nat -A POSTROUTING -o eth0 -s 10.152.2.0/24 -j MASQUERADE echo 1 > /proc/sys/net/ipv4/ip_forward for each in /proc/sys/net/ipv4/conf/* do echo 0 > $each/accept_redirects echo 0 > $each/send_redirects done /etc/init.d/ipsec start /etc/init.d/xl2tpd start ;; stop) echo "Stopping my Ipsec VPN" iptables --table nat --flush echo 0 > /proc/sys/net/ipv4/ip_forward /etc/init.d/ipsec stop /etc/init.d/xl2tpd stop ;; restart) echo "Restarting my Ipsec VPN" iptables -t nat -A POSTROUTING -o eth0 -s 10.152.2.0/24 -j MASQUERADE echo 1 > /proc/sys/net/ipv4/ip_forward for each in /proc/sys/net/ipv4/conf/* do echo 0 > $each/accept_redirects echo 0 > $each/send_redirects done /etc/init.d/ipsec restart /etc/init.d/xl2tpd restart ;; *) echo "Usage: /etc/init.d/ipsec.vpn {start|stop|restart}" exit 1 ;; esac
This will configure the firewall forwarding. If you use a local IP pool other than 10.152.2, be sure to update it.
Then set the permission to execute:
sudo chmod 755 ipsec.vpn
Disable the ipsec default init script with
#update-rc.d -f ipsec remove
And enable the custom one.
#update-rc.d ipsec.vpn defaults
L2TP
In the file /etc/xl2tpd/xl2tpd.conf
[global] ipsec saref = no [lns default] ip range = 10.152.2.2-10.152.2.254 local ip = 10.152.2.1 require chap = yes refuse pap = yes require authentication = yes ppp debug = yes pppoptfile = /etc/ppp/options.xl2tpd length bit = yes
* ip range = range of IP’s to give to the connecting clients * local ip = IP of VPN server. Value must be outside of "ip range". * refuse pap = refure pap authentication * ppp debug = yes when testing, no when in production
Choose a good challenge-response authentication string. The secret should, ideally, be 16 characters long, and should probably be longer to ensure sufficient security. There is no minimum length requirement. In the file /etc/xl2tpd/l2tp-secrets:
* * exampleforchallengestring
In the file /etc/ppp/options.xl2tpd copy:
refuse-mschap-v2 refuse-mschap ms-dns 8.8.8.8 ms-dns 8.8.4.4 asyncmap 0 auth crtscts idle 1800 mtu 1200 mru 1200 lock hide-password local #debug name l2tpd proxyarp lcp-echo-interval 30 lcp-echo-failure 4
ms-dns option
Here you set the dns server for your lan, this dns server are pushed to the road warrior when he connects. If you wan to add several servers just add several lines.
If you need to push wins settings to the clients there is an separate option for that.
mtu / mru
On openswan.org they informs that it's important to reduce the mru/mtu size. Because l2tp/ipsec are encapsulated several times it causes overhead, reducing this makes it possible to transmit all packages over lines with reduced mtu size.
proxyarp
Adds an entry to this system’s ARP [Address Resolution Protocol] table with the IP address of the peer and the Ethernet address of this system. This will have the effect of making the peer appear to other systems to be on the local ethernet.
name l2tpd
Is used in the ppp authentication file.
Adding Users
In the file /etc/ppp/chap-secrets copy:
user1 l2tpd chooseagoodpassword * user2 * chooseagoodpassword *
* client = username for the user * server = the name we define in the ppp.options file for xl2tpd * secret = password for the user * IP Address = leave to * for any address or define addresses from were a user can login.
Note: you can add as many user you like.
Forward
in /etc/sysctl.conf
net.ipv4.ip_forward=1
Load the new settings made in /etc/sysctl.conf
sysctl -p
Starting the VPN
sudo /etc/init.d/ipsec.vpn restart sudo /etc/init.d/xl2tpd restart
Connecting the VPN to iOS device
1. Go to Settings > General > Network > VPN > Add VPN Configuration > L2TP 2. VPN Description > the name you like 3. Set VPN server > external ip address of the VPN server (x.x.x.x) 4. Account > PPP username 5. Set password > somegoodpassword 6. Set L2TP Secret > was exampleforchallengestring 7. Connect using the PPP username/password (user1 chooseagoodpassword)
Connecting the VPN to an Android device
1. Go to Settings > Wireless & networks > VPN settings > Add VPN > Add L2TP/IPSec PSK VPN > 2. VPN Name / Description > the name you like 3. Set VPN server > external ip address of the VPN server (x.x.x.x) 4. Set IPSec pre-shared key / password > somegoodpassword 5. Enable L2TP secret > enable 6. Set L2TP Secret > was exampleforchallengestring 7. Press back, then connect using the PPP username/password (user1 chooseagoodpassword)
Debug
In case of problems this are a few commands that can help out the debugging.
sudo tcpdump -i ppp0 sudo tail -f /var/log/auth.log sudo tail -f /var/log/syslog
You can also monitor the results on the Server with
sudo tcpdump -i eth0 host aaa.bbb.ccc.ddd and not port ssh
aaa.bbb.ccc.ddd are the public IP address of your Clients