2017年8月30日 星期三

[L2TP][ubuntu] How to build up L2TP server

* SERVER *
Install xl2tpd package
sudo apt install xl2tpd

gedit /etc/xl2tpd/xl2tpd.conf

[global]
port = 1701
;auth file = /etc/xl2tpd/l2tp-secrets

[lns default]
exclusive = no
ip range = 192.168.168.2-192.168.168.254 ; Replace with your IP range
local ip = 192.168.0.108 ; One of your interface must be using this IP
require authentication = no
pppoptfile = /etc/ppp/Test01.options.xl2tpd
length bit = yes


root@rails:/etc/xl2tpd# cat l2tp-secrets
# Secrets for authenticating l2tp tunnels
# us them secret
# * marko blah2
# zeus marko blah
# * * interop
* Happy Good

Method 1 : no need password

Because no auth


Create Test01.options.xl2tpd

gedit /etc/ppp/Test01.options.xl2tpd

root@rails:/etc/xl2tpd# cat /etc/ppp/Test01.options.xl2tpd
dump

# Output debugging information to /var/log/debug
debug

# Do not support BSD compression.
nobsdcomp
passive
lock

# Allow all usernames to connect.
name *
proxyarp
ipcp-accept-local
ipcp-accept-remote
lcp-echo-failure 3
lcp-echo-interval 5
nodeflate

# Do not authenticate incoming connections. This is handled by IPsec.
# Client don’t need to input account and password
noauth
refuse-chap
refuse-mschap
refuse-mschap-v2

# Set the DNS servers the PPP clients will use.
ms-dns 208.67.222.222
ms-dns 208.67.220.220

mtu 1400
mru 1400


Method 2 : need password

Because auth


root@rails:/etc/ppp# cat Test01.options.xl2tpd
dump

# Output debugging information to /var/log/debug
debug

# Do not support BSD compression.
nobsdcomp
passive
lock

# Allow all usernames to connect.
name *
proxyarp
ipcp-accept-local
ipcp-accept-remote
lcp-echo-failure 3
lcp-echo-interval 5
nodeflate

# Do not authenticate incoming connections. This is handled by IPsec.
# Need account and password to authentication.
auth
#refuse-chap
refuse-mschap
refuse-mschap-v2

# Set the DNS servers the PPP clients will use.
ms-dns 208.67.222.222
ms-dns 208.67.220.220

mtu 1400
mru 1400


Set L2TP password for client input account & password.

/etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
happy * good *


Start xl2tpd sever

xl2tpd -D &

After success start l2tpd server

root@rails:/etc/xl2tpd# xl2tpd[2318]: setsockopt recvref[30]: Protocol not available
xl2tpd[2318]: This binary does not support kernel L2TP.
xl2tpd[2318]: xl2tpd version xl2tpd-1.3.6 started on rails PID:2318
xl2tpd[2318]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.
xl2tpd[2318]: Forked by Scott Balmos and David Stipp, (C) 2001
xl2tpd[2318]: Inherited by Jeff McAdams, (C) 2002
xl2tpd[2318]: Forked again by Xelerance (www.xelerance.com) (C) 2006
xl2tpd[2318]: Listening on IP address 0.0.0.0, port 1701

After client connect to server
root@rails:/etc/xl2tpd#
root@rails:/etc/xl2tpd# xl2tpd[2318]: handle_avps: no handler for atribute 5 (Tie Breaker).
xl2tpd[2318]: Connection established to 192.168.0.100, 1701. Local: 22457, Remote: 55781 (ref=0/0). LNS session is ‘default’
xl2tpd[2318]: start_pppd: I’m running:
xl2tpd[2318]: “/usr/sbin/pppd”
xl2tpd[2318]: “passive”
xl2tpd[2318]: “nodetach”
xl2tpd[2318]: “192.168.0.108:192.168.168.2”
xl2tpd[2318]: “file”
xl2tpd[2318]: “/etc/ppp/Test01.options.xl2tpd”
xl2tpd[2318]: “/dev/pts/5”
xl2tpd[2318]: Call established with 192.168.0.100, Local: 22274, Remote: 33710, Serial: 0
xl2tpd[2318]: control_finish: Connection closed to 192.168.0.100, port 1701 (Shutting down), Local: 22457, Remote: 55781
xl2tpd[2318]: Terminating pppd: sending TERM signal to pid 2320
xl2tpd[2318]: Can not find tunnel 22457 (refhim=0)
xl2tpd[2318]: network_thread: unable to find call or tunnel to handle packet. call = 22274, tunnel = 22457 Dumping.
xl2tpd[2318]: Can not find tunnel 22457 (refhim=0)
xl2tpd[2318]: network_thread: unable to find call or tunnel to handle packet. call = 22274, tunnel = 22457 Dumping.
xl2tpd[2318]: handle_avps: no handler for atribute 5 (Tie Breaker).
xl2tpd[2318]: Connection established to 192.168.0.100, 1701. Local: 54164, Remote: 3812 (ref=0/0). LNS session is ‘default’
xl2tpd[2318]: start_pppd: I’m running:
xl2tpd[2318]: “/usr/sbin/pppd”
xl2tpd[2318]: “passive”
xl2tpd[2318]: “nodetach”
xl2tpd[2318]: “192.168.0.108:192.168.168.2”
xl2tpd[2318]: “file”
xl2tpd[2318]: “/etc/ppp/Test01.options.xl2tpd”
xl2tpd[2318]: “/dev/pts/5”
xl2tpd[2318]: Call established with 192.168.0.100, Local: 26365, Remote: 38583, Serial: 0

Q:
rails@rails:/etc/ppp xl2tpd[4969]: setsockopt recvref[30]: Protocol not available
xl2tpd[4969]: This binary does not support kernel L2TP.
xl2tpd[4969]: open_controlfd: Unable to open /var/run/xl2tpd/l2tp-control for reading.

A:
chmod 777 /var/run/xl2tpd/l2tp-control

Reference:

0 意見:

張貼留言