因爲工作上主要用centos,這幾天把筆記本也重裝了centos系統,想裝xl2tpd包,結果yum search沒有找到,搜了下,要加個fedora的epel源,項目地址https://fedoraproject.org/wiki/EPEL/zh-cn,編輯/etc/yum.repos.d/epel.repo文件,“priority=3”加到[epel]段最後,然後yum makecache,yum install xl2tpd。
--------------------------------------------------------------------------------------------------
系統:Debian6.0,256M
有時需要在家處理單位的事,正好同事在防火牆上做了個l2tp的×××,下面把設置的內容簡單貼出來。
1、安裝xl2tp包
2、修改/etc/xl2tpd/xl2tpd.conf,缺省基礎加上以下:
[lac 123] #123這個名字隨便起
lns = x.x.x.x #(×××接入地址)
redial = yes
redial timeout = 15
require chap = yes
refuse pap = yes
require authentication = yes
name = xxx #(用戶名)
pppoptfile = /etc/ppp/options.123_l2tp #系統缺省文件名是options
ppp debug = yes
3、建立options.123_l2tp文件
:~$ cat /etc/ppp/options.123_l2tp
asyncmap 0
noauth
crtscts
lock
hide-password
modem
netmask 255.255.255.0
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4
ipcp-accept-local
ipcp-accept-remote
4、用戶名、密碼格式:用戶名 * “密碼” *
:~$ cat /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
xxx * "xxxxxx" *
any * any
5、因爲需要輸入幾個命令,自己做了個腳本,見笑!
:~$ cat desktop/xl2tpd_start.sh
#!/bin/bash
# Program:
# xl2tpd ××× start script.
# History:
# 2011/10/17 wyw First release
# 2011/10/18 wyw Second release
# start xl2tpd service
/etc/init.d/xl2tpd start
sleep 10
# 將判斷撥號部分放入循環中,因爲剛撥號沒那麼快連接,ifconfig命令沒有結果輸出,要不採用sleep命令等待一段時間。
# start ppp
echo 'c 123' > /var/run/xl2tpd/l2tp-control
# echo "please wait 20second for ppp0 start"
# sleep 20
#判斷撥號是否成功,ppp0端口啓用狀態
test=$(ifconfig | grep -o Point-to-Point)
echo $test
#循環判斷,直到ppp0端口啓用
until [ "$test" == "Point-to-Point" ] # 中括號做爲判斷句兩邊都要留有空格
do
echo "Device ppp0 No"
sleep 5
test=`ifconfig | grep -o Point-to-Point`
echo $test
done
echo "Device ppp0 Yes"
echo $test
# add route to dev ppp0
route add -net 10.0.0.0 netmask 255.0.0.0 dev ppp0