顯示具有 L2TP 標籤的文章。 顯示所有文章
顯示具有 L2TP 標籤的文章。 顯示所有文章

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:

2012年10月6日 星期六

[L2TP] How to connect to Home network by using l2tp


This script will automatic build up the enviroment.
Set routing table.
And connect to Home network.



#!/bin/bash
#sudo aptitude install xl2tpd
Second=3
interface_number=$(ifconfig | grep “Link encap” | cut -d ’ ’ -f 1 | wc -l)

echo ” ”
echo ” ”
echo ” \033[1;31m Please ‘sudo su’ first \033[m” # sudo su –> change to root privilege
echo ” *****************************************************************
echo ” * *
for i in interface_number);
do
eval interface(ifconfig | grep “Link encap” | cut -d ’ ’ -f 1 | sed -n “i p”)
eval echo ’interface$i | xargs -i echo ” * “{}” *
done
echo ” * *
echo ” *****************************************************************
echo “Please input interface : “
read input # read character input
eval echo ‘input

cd /etc/xl2tpd/

if test -e /etc/xl2tpd/xl2tpd.conf; then
sudo cp /etc/xl2tpd/xl2tpd.conf /etc/xl2tpd/xl2tpd.conf.bak
sudo rm /etc/xl2tpd/xl2tpd.conf
fi

cd ~

if ! test -e ~/xl2tpd.conf; then
touch xl2tpd.conf
echo “[global]” >> ~/xl2tpd.conf
echo “access control = no” >> ~/xl2tpd.conf
echo “port = 1701” >> ~/xl2tpd.conf
echo “[lac testvpn]” >> ~/xl2tpd.conf
echo “name = someone” >> ~/xl2tpd.conf
echo “lns = ‘The IP of remote of WAN IP’” >> ~/xl2tpd.conf # change to echo “lns = xxx.xxx.xxx.xxx” >> ~/xl2tpd.conf
echo “pppoptfile = /etc/ppp/peers/testvpn.l2tpd” >> ~/xl2tpd.conf
echo “ppp debug = no” >> ~/xl2tpd.conf
fi

sudo cp ~/xl2tpd.conf /etc/xl2tpd/

if ! test -e ~/testvpn.l2tpd; then
touch testvpn.l2tpd
echo “remotename testvpn” >> ~/testvpn.l2tpd
echo ‘user “The authorize name of remote WAN IP”’ >> ~/testvpn.l2tpd # change to echo ‘user “Hello”’ >> ~/testvpn.l2tpd
echo ‘password “The authorize password of remote WAN IP”’ >> ~/testvpn.l2tpd # change to echo ‘password “World”’ >> ~/testvpn.l2tpd
echo “unit 0” >> ~/testvpn.l2tpd
echo “lock” >> ~/testvpn.l2tpd
echo “nodeflate” >> ~/testvpn.l2tpd
echo “nobsdcomp” >> ~/testvpn.l2tpd
echo “noauth” >> ~/testvpn.l2tpd
echo “persist” >> ~/testvpn.l2tpd
echo “nopcomp” >> ~/testvpn.l2tpd
echo “noaccomp” >> ~/testvpn.l2tpd
echo “maxfail 5” >> ~/testvpn.l2tpd
echo “debug” >> ~/testvpn.l2tpd
fi

sudo cp ~/testvpn.l2tpd /etc/ppp/peers/
xl2tpd -c /etc/xl2tpd/testvpn.options
sudo echo ‘c testvpn’ > /var/run/xl2tpd/l2tp-control
ip_address=input | cut -d ’ ’ -f 3)
echo ip_address # Change to route add -host xxx.xxx.xxx.xxx gw Second” second”
sleep $Second # must wait for few second to wait ppp0 up
route add default ppp0


Reference :

2012年1月14日 星期六

[l2tp] Connect to Company Network Skill

touch /var/run/xl2tpd/l2tp-control

0. Install

sudo aptitude install xl2tpd

Correct one

1. Edit /etc/xl2tpd/xl2tpd.conf

;
; Sample l2tpd configuration file
;
; This example file should give you some idea of how the options for l2tpd
; should work.  The best place to look for a list of all options is in
; the source code itself, until I have the time to write better documetation :)
; Specifically, the file "file.c" contains a list of commands at the end.
;
; You most definitely don't have to spell out everything as it is done here
;
[global]                ; Global parameters:
debug tunnel = yes;

[lac testvpn]
lns = "The IP of remote of WAN IP"
name = "The authorize name of remote WAN IP"
require chap = yes
refuse pap = yes
require authentication = no
ppp debug = no
pppoptfile = /etc/ppp/options.xl2tpd.client
length bit = yes

My /etc/ppp/options.xl2tpd.client of content

ipcp-accept-local
ipcp-accept-remote
ms-dns 168.95.1.1
ms-dns 8.8.8.8
ms-wins 111.2.1.2
ms-wins 111.2.1.4
noccp
auth
crtscts
idle 1800
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
logfile /var/log/xl2tpd.log

2. Edit /etc/ppp/chap-secrets 

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
"Account of remote WANIP"  *    "Password of remote WANIP"        *
abc  *    abc1234       *

3. Start daemon

xl2tpd -c /etc/xl2tpd/xl2tpd.conf -D

Create VPN tunnel
echo 'c testvpn' >/var/run/xl2tpd/l2tp-control

Wait for 2 second.
And type ifconfig will see ppp0


Destroy VPN tunnel
echo "d testvpn" >/var/run/xl2tpd/l2tp-control

4. Add "Remote WAN IP address" as LAN IP address
Go through gateway is depend on you internet

For example :
My internet setting is

wlan0     Link encap:Ethernet  HWaddr 48:5D:60:35:2A:B0
          inet addr:192.168.2.101  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::4a5d:60ff:fe35:2ab0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9854 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1055 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1321131 (1.2 MiB)  TX bytes:183435 (179.1 KiB)

So the Gateway is 192.168.2.1

route add -host "Remote WAN IP address" gw 192.168.2.1
ex: route add -host 1.2.3.4 gw 192.168.2.1

route add default ppp0

5. ping any machine of your company
ping x.x.x.x

If you get response.
Congratulation you are successfully.

PS1:

After step 5  using traceroute.

And traceroute 8.8.8.8.

Will see route packet to defferent way out


root@YA-laptop:~# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  10.10.101.1 (10.10.101.1)  63.703 ms  63.633 ms  67.763 ms
 2  222-222-222-254.HINET-IP.hinet.net (222.222.222.254)  103.519 ms  103.478 ms  103.439 ms
 3  h122.s208.ts.hinet.net (168.95.208.122)  103.399 ms  111.391 ms  111.351 ms
 4  SCZS-3101.hinet.net (220.128.7.82)  114.293 ms SCZS-3102.hinet.net (220.128.7.102)  111.269 ms  114.212 ms
 5  TPDT-3012.hinet.net (220.128.2.34)  118.192 ms TPDT-3011.hinet.net (220.128.1.90)  118.155 ms  122.301 ms
 6  TYFO-3011.hinet.net (220.128.3.105)  127.286 ms  175.703 ms TYFO-3012.hinet.net (220.128.4.105)  175.635 ms
 7  TYFO-3302.hinet.net (220.128.9.197)  139.454 ms 220-128-8-189.HINET-IP.hinet.net (220.128.8.189)  139.386 ms  139.349 ms

ifcnofig is :



ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.10.101.20  P-t-P:10.10.101.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1410  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:42 (42.0 B)  TX bytes:48 (48.0 B)

route is :

root@YA-laptop:~# route -n
Kernel IP routing table
Destination            Gateway            Genmask             Flags        Metric    Ref    Use   Iface
10.10.101.1              0.0.0.0        255.255.255.255        UH            0        0      0    ppp0
222.222.222.222        192.168.1.1      255.255.255.255        UGH           0        0      0    wlan0
192.168.1.0              0.0.0.0          255.255.255.0        U             2        0      0    wlan0
0.0.0.0                  0.0.0.0          0.0.0.0              U             0        0      0    ppp0
0.0.0.0                192.168.1.1         0.0.0.0             UG            0        0      0    wlan0

PS2 .

If you have use linux OS

You can type " route -n " to find out  what is the gateway you got.

HAPPY@HAPPY-laptop:~$ route -n
Kernel IP routing table
Destination        Gateway      Genmask        Flags  Metric   Ref   Use Iface
172.16.146.0      0.0.0.0     255.255.255.0      U     0        0     0 vmnet8
192.168.178.0   0.0.0.0       255.255.255.0      U     0        0     0 vmnet1
192.168.1.0        0.0.0.0    255.255.255.0      U     1        0     0 eth0
192.168.1.0      0.0.0.0      255.255.255.0      U     2        0     0 wlan0
169.254.0.0      0.0.0.0      255.255.0.0        U     1000     0     0 eth0
0.0.0.0         192.168.1.1     0.0.0.0          UG    0        0     0 eth0

The blue word is gateway.


vmnet8 & vmnet1 is IP address of VMware.

**********************************************************
Reference:


Comment :

I find so many document at 2:03 PM. I write it down at 20120106 at 2:51 AM. When 2:51 AM. My father saw my light was still light.He so angry come to upstair and yell me. So I must go to sleep.



2011年9月9日 星期五

[L2TP] How To Configure Windows LP2T/IPsec Client for Cisco VPN

How To Configure Windows LP2T/IPsec Client for Cisco VPN

Step 1: Add the ProhibitIpSec Registry Value

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rasman\Parameters 
  1. Click Start, click Run, type regedt32, and then click OK.
  2. Locate, and then click the following registry subkey:
  3. On the Edit menu, click Add Value.
  4. In the Value Name box, type ProhibitIpSec.
  5. In the Data Type list, click REG_DWORD, and then click OK.
  6. In the Data box, type 1, and then click OK.
  7. Quit Registry Editor, and then restart your computer.
Reference :