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.
0 意見:
張貼留言