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

2016/05/18

CentOS 安裝 rpcapd

在CentOS上安裝rpcapd順序

1. 下載winpacp source (官方載點)
2. 解開壓縮檔 並參考 https://www.winpcap.org/pipermail/winpcap-users/2011-November/004540.html
    修正daemon.c檔案的錯誤

3. 依據http://www.winpcap.org/docs/docs_40_2/html/group__remote.html 的說明編譯並啟用 

參考來源:
http://www.winpcap.org/docs/docs_40_2/html/group__remote.html
https://www.winpcap.org/pipermail/winpcap-users/2011-November/004540.html

2015/11/28

Linux Expect 語法

參考來源:https://devcentral.f5.com/articles/example-expect-script
參考來源:http://inguza.com/document/expect-and-tcl-mini-reference-manual

先裝好epxect後 就可以用下列語法透過ssh去控制遠端主機或設備
--------------
#!/usr/bin/expect -f
set HOST "目標IP"
set USER "帳號"
set PASS "密碼"
set SERVER [lindex $argv 0]    // 參數一  字串
set TARGET [lindex $argv 1]  // 參數二 以空格分隔得字串
append SERVER "_WHITE_LIST"  // 在參數一後面加字串

spawn ssh -o StrictHostKeyChecking=no $USER@$HOST    // ssh連線到目標主機
expect  "password:" { send "$PASS\r";}   //  密碼
expect  " #" { send "config firewall addrgrp \r"; }  // 指令
expect  "(addrgrp) #" { send "edit $SERVER \r"; }  // 指令
expect  "($SERVER) #" {
        foreach target [split $TARGET " "] {       // foreach 迴圈    變數來源是用以空格分隔得字串
                send "unselect member [lindex $target 0] \r";   // 指令
                continue;  
        };
}
expect  "($SERVER) #" { send "end \r"; }   // 指令
expect  " #"  {  send "config firewall address \r"; }
expect  "(address) #" {
        foreach target [split $TARGET " "] {
                send "delete [lindex $target 0] \r";
                continue;
        };
}
expect  "(address) #" { send "end \r"; }
expect  " #" { send "exit \r"; }   // 登出主機

----------------

2015/10/26

CentOS 7 Bridge跟Traffic Control

Bridge 設定  http://www.ichiayi.com/wiki/tech/linux_bridge
Traffic Control 設定 http://chunchaichang.blogspot.tw/2010/08/qos.html

這裡有一個重點Bridge預設是不會受iptables的控制,找了一下有下列文章
http://stackoverflow.com/questions/653812/why-doesnt-my-iptables-entries-block-pinging-a-xen-virtual-machine
重點就是要把Bridge的nf功能打開http://ebtables.netfilter.org/documentation/bridge-nf.html
nf功能可以在sysctl.conf裡面設定。

開機要自動做好TC的話,請記得把rc.local改成可執行。

2012/02/06

webmin及openwebmail安裝

以下都是透過yum方式安裝,rpm及tarball方式請自行google。
一、安裝webmin
        參考:http://webmin.com/rpm.html

Using the Webmin YUM repository

If you like to install and update Webmin via RPM, create the/etc/yum.repos.d/webmin.repo file containing :[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
You should also fetch and install my GPG key with which the packages are signed, with the commands :wget http://www.webmin.com/jcameron-key.asc
rpm --import jcameron-key.asc
You will now be able to install with the command :yum install webminAll dependencies should be resolved automatically.


二、安裝openwebmail


How to install openwebmail from yum repository
==============================================
Thomas Chung <tchung@openwebmail.org>
2008.05.29
UPDATE 2010.05.24
Install perl-Text-Iconv from rpmforge for your arch if you're running RHEL or CentOS:
http://dag.wieers.com/rpm/packages/perl-Text-Iconv/
$ su -
# cd /etc/yum.repos.d
# lftpget http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo
# yum install openwebmail
fedora 100% |=========================| 2.1 kB 00:00
openwebmail 100% |=========================| 951 B 00:00
updates 100% |=========================| 2.3 kB 00:00
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package openwebmail.i386 0:2.53-1 set to be updated
--> Processing Dependency: openwebmail-data = 2.53-1 for package: openwebmail
--> Processing Dependency: perl-suidperl for package: openwebmail
--> Processing Dependency: perl-Text-Iconv for package: openwebmail
--> Running transaction check
---> Package openwebmail-data.i386 0:2.53-1 set to be updated
---> Package perl-suidperl.i386 4:5.8.8-32.fc8 set to be updated
---> Package perl-Text-Iconv.i386 0:1.5-1.fc8 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing for dependencies:
openwebmail i386 2.53-1 openwebmail 2.3 M
openwebmail-data i386 2.53-1 openwebmail 7.0 M
perl-Text-Iconv i386 1.5-1.fc8 fedora 20 k
perl-suidperl i386 4:5.8.8-32.fc8 updates 60 k
Transaction Summary
=============================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-Text-Iconv-1. 100% |=========================| 20 kB 00:00
(2/4): openwebmail-2.53-1 100% |=========================| 2.3 MB 00:03
(3/4): perl-suidperl-5.8. 100% |=========================| 60 kB 00:00
(4/4): openwebmail-data-2 100% |=========================| 7.0 MB 00:10
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cfb164d8
Importing GPG key 0xCFB164D8 "Thomas Chung <tchung@openwebmail.org>" from http://openwebmail.org/.../RPM-GPG-KEY-openwebmail
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-Text-Iconv ######################### [1/4]
Installing: perl-suidperl ######################### [2/4]
Installing: openwebmail ######################### [3/4]
Permission and Ownership for openwebmail files have been fixed!
Please execute following tool first as a root:
/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init
After restarting httpd service, login with non-root account from
http://localhost.localdomain/cgi-bin/openwebmail/openwebmail.pl
or http://localhost.localdomain/webmail
If SELinux enabled, you may need to set it 'permissive' in
/etc/sysconfig/selinux or system-config-selinux
Installing: openwebmail-data ######################### [4/4]
Dependency Installed: openwebmail.i386 0:2.53-1 openwebmail-data.i386 0:2.53-1 perl-Text-Iconv.i386 0:1.5-1.fc8 perl-suidperl.i386 4:5.8.8-32.fc8
Complete!
三、 openwebmail安裝好後的設定
        修改/var/log/openwebmail.log的 selinux設定
參考:http://j796160836.pixnet.net/blog/post/21882397-%5B%E7%AD%86%E8%A8%98%5D%5B%E6%A5%B5%E9%87%8D%E8%A6%81%5Dopenwebmail%E7%9A%84%E9%97%9C%E9%8D%B5%E8%A8%AD%E5%AE%9A%EF%BC%8C%E8%A8%AD%E5%AE%9Aselinu



2011/10/06

Fedora 讓gnome可以用root登入

參考來源:http://fedoraproject.org/wiki/Enabling_Root_User_For_GNOME_Display_Manager

要先有root權限或是用sudo方式處理。

1. 修改 /etc/pam.d/gdm
   將
   auth required pam_succeed_if.so user != root quiet
   這行改成
   #auth required pam_succeed_if.so user != root quiet
2. 修改 /etc/pam.d/gdm-password
  同1的方式修改

  不過一般不建議這樣作,畢竟安全至上。除非你自己有相當的管理經驗。

2011/08/04

Install snort 2.9.0.5 on CentOS 5.5

今天裝Snort 2.9.0.5到CentOS 5.5上,遭遇很多問題。
所以寫這篇紀錄如何安裝。這篇完全用tarball方式安裝,RPM部份請參考(http://forum.icst.org.tw/phpbb/viewtopic.php?f=11&t=20365)。
這邊是安裝好CentOS 5.5並且將全部套件更新到最新版後的安裝方式。

1.事前準備
  1.1 從snort官網下載snort-2.9.0.5.tar.gz, dag-0.5.tar.gz
  1.2 下載snort的rule,免費的即可,前提是你要先註冊一個帳號。將來有想要升級的話也可以升級上去。
        snortrules-snapshot-2904.tar.gz, snortrules-snapshot-2905.tar.gz
  1.3 到http://www.tcpdump.org 下載libpcap-1.1.1.tar.gz
  1.4 到http://libdnet.sourceforge.net 下載libdnet-1.11.tar.gz
  1.5 將snort,dag,libdnet及libpcap解開(請自行到鳥哥那瞭解如何解壓縮),到各自目錄夾。
        通常解開的目錄就是檔案去掉tar.gz的部份。
        例:snort-2.9.0.5.tar.gz解開後目錄名稱為snort-2.9.0.5。
2.開始安裝
  2.1 用瀏覽器打開 Install_Snort_2.8.6_on_CentOS_5.5.pdf
       請依照裡面的 Snort Installation and Setup章節安裝。裡面會要你用yum安裝很多套件。
       安裝完後會到 Making directories and building/installing Snort: 章節。
       接下來的請依順序安裝,不然會有錯誤訊息。
  2.2 安裝libdnet
cd libdnet-1.11
./configure --prefix=/usr
make
make install

  2.3 安裝libpcap
cd libpcap-1.1.1
./configure --prefix=/usr
make
make install

  2.4 安裝dag
cd dag-0.5
./configure --prefix=/usr
make
make install

  2.5 安裝snort
cd snort-2.9.0.5
./configure --with-mysql --enable-dynamicplugin --enable-ipv6 --enable-gre --enable-mpls --enable-targetbased --enable-decoder-preprocessor-rules --enable-ppm --enable-perfprofiling --enable-zlib --enable-active-response --enable-normalizer --enable-reload --enable-react --enable-flexresp3
make
make install

  2.6 接著就接續Making directories and building/installing Snort:後面章節的部份繼續安裝下去。

3. PHP Pear部份
   3.1 安裝php pear

yum -y install php-pear
pear upgrade --force http://download.pear.php.net/package/PEAR-1.9.1.tgz
pear install Numbers_Roman
pear install channel://pear.php.net/Numbers_Words-0.16.2
pear install Image_Color
pear install channel://pear.php.net/Image_Canvas-0.3.2
pear install channel://pear.php.net/Image_Graph-0.7.2


4. adodb
wget http://sourceforge.net/projects/adodb/files/adodb-php5-only/adodb-511-for-php5/adodb511.tgz/download


5. secureideas
wget http://sourceforge.net/projects/secureideas/files/BASE/base-1.4.5/base-1.4.5.tar.gz/download


6. Barnyard2
安裝裡面的網站已經不存在了,現在換到這個https://nodeload.github.com/firnsy/barnyard2/tarball/master。
  6.1 請參閱doc裡面的INSTALL文件
        如果發生 AM_PATH_LIBPRELUDE 錯誤的話,依下面方式處理。

cp snort-2.9.0.5/m4/libprelude.m4 /usr/share/aclocal

snort-2.9.0.5可以改成你實際解開的目錄。
  6.2 之後就./configure --with-mysql --prefix=/usr沒問題的話就可以安裝了

7. 修改snort.conf
     把ipvar部份全部改成var。

全部做完後就可以開始使用Snort了。

2011/02/22

Nagios Plugin Check_SNMP

OS: CentOS 5.5
Nagios: nagios-3.2.3-3.el5.rf.i386
這篇是關於Nagios Plugin Check_SNMP中關於--rate指令的使用方式。
如果你是用YUM或是apt等方式安裝的Nagios,可能在使用check_snmp的--rate選項的時候會發生錯誤。
原因是因為check_snmp在儲存rate的狀態的時候,會除存在/var/check_snmp裡面,而extinfo.cgi確無法在開啟檔案,原因是目錄建立的時候,使用者及群組不是nagios(或你自訂的群組),權限也只有700。
所以將使用者及群組改成nagios(或你自訂的群組),權限也修改成755(或你覺得安全權限)。
裡面如果原本就有檔案的話,也請將使用者及群組改成nagios(或你自訂的群組),權限640即可。想省事一點可以把檔案全砍了,反正重新建立也不會有啥影響。之後重新啟動nagios就會正常。

2011/02/16

CentOS Yum Repo

CentOS預設安裝的Yum有蠻多東西都沒有的。
所以下面是幾個目前常用的repo及安裝方式。

1.remi

wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

2.rpmforge

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

3.IUS

wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm
rpm -Uvh ius-release*.rpm


PS:請注意上面是i386版本,若是64bit版的,必須把i386的字串改為x86_64。
PS2:RHEL已經有6版了,但不建議在系統不是6版的狀況下裝6版的repo。
2012/07/02 redhar的域名修正

2011/02/15

Wireshark的cli版 tshark

TShark 1.0.15
Dump and analyze network traffic.
See http://www.wireshark.org for more information.

Copyright 1998-2010 Gerald Combs and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Usage: tshark [options] ...

Capture interface:
-i name or idx of interface (def: first non-loopback)
-f packet filter in libpcap filter syntax
-s packet snapshot length (def: 65535)
-p don't capture in promiscuous mode
-y link layer type (def: first appropriate)
-D print list of interfaces and exit
-L print list of link-layer types of iface and exit

Capture stop conditions:
-c stop after n packets (def: infinite)
-a ... duration:NUM - stop after NUM seconds
在幾秒後停止
filesize:NUM - stop this file after NUM KB
在檔案大小為幾KB後停止
files:NUM - stop after NUM files
在幾個檔案後停止
Capture output:
-b ... duration:NUM - switch to next file after NUM secs
在幾秒後換新檔案
filesize:NUM - switch to next file after NUM KB
在檔案大小為幾KB後換新檔案
files:NUM - ringbuffer: replace after NUM files
在幾次後後換覆蓋檔案(類似logrotate的功能)
Input file:
-r set the filename to read from (no pipes or stdin!)

Processing:
-R packet filter in Wireshark display filter syntax
-n disable all name resolutions (def: all enabled)
-N enable specific name resolution(s): "mntC"
-d ==, ...
"Decode As", see the man page for details
Example: tcp.port==8888,http
Output:
-w set the output filename (or '-' for stdout)
將抓到的資料存放到 (或輸入 '-' 來輸出到stdout也就是顯示在螢幕上)
-C start with specified configuration profile
-F set the output file type, default is libpcap
an empty "-F" option will list the file types
-V add output of packet tree (Packet Details)
-S display packets even when writing to a file
-x add output of hex and ASCII dump (Packet Bytes)
-T pdml|ps|psml|text|fields
format of text output (def: text)
-e field to print if -Tfields selected (e.g. tcp.port);
this option can be repeated to print multiple fields
-E= set options for output when -Tfields selected:
header=y|n switch headers on and off
separator=/t|/s| select tab, space, printable character as separator
quote=d|s|n select double, single, no quotes for values
-t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)
-l flush standard output after each packet
-q be more quiet on stdout (e.g. when using statistics)
-X : eXtension options, see the man page for details
-z various statistics, see the man page for details

Miscellaneous:
-h display this help and exit
-v display version info and exit
-o : ... override preference setting

2010/11/12

用Bind9架设自己的智能DNS

用Bind9架设自己的智能DNS

by ProdigYu on Oct.20, 2010, under CDN

中国的南北网络问题,是许多做网站的人的心病
除了使用双通或者多通机房以外,还可以通过多台镜像服务器的方法来提高用户的访问速度
但是,如果使用的双通机房并不是单IP的,或者使用多台镜像的做法,就会面临多个不同的服务器IP的问题
最早的时候,很多镜像服务器都是使用不同的域名的,比如说www1和www2,或者www和cnc
这样的做法,对用户相当不友好,而且不方便推广,比如说,你要告诉朋友一个网站,还要问他是什么线路才能给网址吗,或者可能你还不知道这个网站有一个专为网通的线路所设置的镜像
用统一的域名,然后根据用户的线路自动判断引导到不同的镜像服务器,正是智能DNS的功用(智能DNS其实是CDN的其中一部分,是最前端的部分)

现在还是有一些地方使用多域名,比如说下载网站的下载镜像服务器,因为智能DNS有一定的缺陷(并不一定选择到正确的线路,下面说),也提供给用户自由选择线路的权利

目前也有一些公司提供智能DNS解释服务,把你的域名NS指到他们服务器,然后输入网通和电信服务器的IP就ok了
也有一些公司提供比较完整的CDN服务,比如比较出名的就是chinacache,不少中型网站是使用他们的服务

最初的bind是不支持通过来源选择不同的ip的,因此只能通过iptables的辅助来实现智能DNS,方法也很简单,在DNS服务器上面启动两份bind,都不要用默认的端口,两份分别解析不同的线路,然后再用iptables将默认端口的DNS请求根据来源IP发送到不同的bind实例
这种方法缺点很明显,需要多个bind实例,如果需要更多的线路解释那就还要再开bind实例,另外iptables对来源的解释也会导致iptables太多规则

现在的bind支持了根据来源选择的功能,我不确定是不是bind9的新特性,不过bind9是重写过的,相比漏洞百出的bind8来说,稳定和安全很多,以下的配置以bind9为基础

我使用的是CentOS,由于bind服务没有其他服务(比如apache,squid)要求那么高,所以也没有必要自己编译一份,我是用过yum安装的,版本不是最新的稳定版

装好之后,可以用过/etc/init.d/named start成功启动服务
有一个文件named.conf出现在/etc下,就是bind的主config文件,我们只要改动他
(我只说明智能DNS实现部分,其他的bind设置自行修改,呵呵)
另外一个小技巧,可以通过/usr/sbin/named -g -u named来启动bind,可以立刻看到输出信息,方便调试

我们是通过bind9的view功能来分离判断的
首先,我们需要一份网通的IP列表,这是一份在网上流传的列表,呵呵

acl “CNC” {
58.16.0.0/16;
58.17.0.0/17;
58.17.128.0/17;
58.18.0.0/16;
58.19.0.0/16;
58.20.0.0/16;
58.21.0.0/16;
58.22.0.0/15;
58.240.0.0/15;
58.242.0.0/15;
58.244.0.0/15;
58.246.0.0/15;
58.248.0.0/13;
60.0.0.0/13;
60.8.0.0/15;
60.10.0.0/16;
60.11.0.0/16;
60.12.0.0/16;
60.13.0.0/18;
60.13.128.0/17;
60.14.0.0/15;
60.16.0.0/13;
60.24.0.0/14;
60.30.0.0/16;
60.31.0.0/16;
60.208.0.0/13;
60.216.0.0/15;
60.218.0.0/15;
60.220.0.0/14;
61.48.0.0/13;
61.133.0.0/17;
61.134.96.0/19;
61.134.128.0/17;
61.135.0.0/16;
61.137.128.0/17;
61.138.0.0/17;
61.138.128.0/18;
61.139.128.0/18;
61.148.0.0/15;
61.156.0.0/16;
61.159.0.0/18;
61.161.0.0/18;
61.161.128.0/17;
61.162.0.0/16;
61.163.0.0/16;
61.167.0.0/16;
61.168.0.0/16;
61.176.0.0/16;
61.179.0.0/16;
61.181.0.0/16;
61.182.0.0/16;
61.189.0.0/17;
125.32.0.0/16;
125.40.0.0/13;
202.96.0.0/18;
202.96.64.0/21;
202.96.72.0/21;
202.97.128.0/18;
202.97.224.0/21;
202.97.240.0/20;
202.98.0.0/21;
202.98.8.0/21;
202.99.64.0/19;
202.99.96.0/21;
202.99.128.0/19;
202.99.160.0/21;
202.99.168.0/21;
202.99.176.0/20;
202.99.208.0/20;
202.99.224.0/21;
202.99.232.0/21;
202.99.240.0/20;
202.102.128.0/21;
202.102.224.0/21;
202.102.232.0/21;
202.106.0.0/16;
202.107.0.0/17;
202.108.0.0/16;
202.110.0.0/17;
202.111.128.0/18;
203.93.8.0/24;
203.93.192.0/18;
210.13.128.0/17;
210.14.160.0/19;
210.14.192.0/19;
210.15.32.0/19;
210.15.96.0/19;
210.15.128.0/18;
210.21.0.0/16;
210.52.128.0/17;
210.53.0.0/17;
210.53.128.0/17;
210.74.96.0/19;
210.74.128.0/19;
210.82.0.0/15;
218.8.0.0/14;
218.12.0.0/16;
218.21.128.0/17;
218.24.0.0/14;
218.56.0.0/14;
218.60.0.0/15;
218.67.128.0/17;
218.68.0.0/15;
218.104.0.0/14;
219.154.0.0/15;
219.156.0.0/15;
219.158.0.0/17;
219.158.128.0/17;
219.159.0.0/18;
220.252.0.0/16;
221.0.0.0/15;
221.2.0.0/16;
221.3.0.0/17;
221.3.128.0/17;
221.4.0.0/16;
221.5.0.0/17;
221.5.128.0/17;
221.6.0.0/16;
221.7.0.0/19;
221.7.32.0/19;
221.7.64.0/19;
221.7.96.0/19;
221.8.0.0/15;
221.10.0.0/16;
221.11.0.0/17;
221.11.128.0/18;
221.11.192.0/19;
221.12.0.0/17;
221.12.128.0/18;
221.13.0.0/18;
221.13.64.0/19;
221.13.96.0/19;
221.13.128.0/17;
221.14.0.0/15;
221.192.0.0/15;
221.194.0.0/16;
221.195.0.0/16;
221.196.0.0/15;
221.198.0.0/16;
221.199.0.0/19;
221.199.32.0/20;
221.199.128.0/18;
221.199.192.0/20;
221.200.0.0/14;
221.204.0.0/15;
221.206.0.0/16;
221.207.0.0/18;
221.207.64.0/18;
221.207.128.0/17;
221.208.0.0/14;
221.212.0.0/16;
221.213.0.0/16;
221.216.0.0/13;
222.128.0.0/14;
222.132.0.0/14;
222.136.0.0/13;
222.160.0.0/15;
222.162.0.0/16;
222.163.0.0/19;
222.163.32.0/19;
222.163.64.0/18;
222.163.128.0/17;
};

如果觉得有哪些部分不是很准确的话,可以自行修改

由于这个部分太长了,所以写在一个专门的文件然后include进named.conf比较容易维护
例如,我们把上面这段配置保存为cnc_acl.conf
然后在named.conf写入

include “/data/named/cnc_acl.conf”;

即可

接下来就是view的配置,假设域名是xyz.com,呵呵

view “view_cnc” {
match-clients { CNC; };
zone “xyz.com” {
type master;
file “/data/named/cnc_xyz”;
};
};

view “view_any” {
match-clients { any; };
zone “xyz.com” {
type master;
file “/data/named/any_xyz”;
};
};

就这样就足够了

然后我们需要cnc\_xyz和any_xyz两个具体的zone file
两个文件基本是一模一样的,就是指向不同的ip

$TTL 2h
xyz.com. IN SOA ns.xyz.com. root.xyz.com. (
20071022
2h
40m
1w
2h
)

this6.com. IN NS ns.xyz.com.
this6.com. IN MX 1 mail.xyz.com.
ns IN A 1.1.1.1
mail IN A 1.1.1.1

www IN A 1.1.1.1

根据不同的线路把www指向不同的IP即可
这样,我们就实现了自己的智能DNS

后话,目前许多大型网站都是用这个来实现不同的线路来源访问不同的镜像,甚至还做到地区级别,例如,在佛山机房部署了一台镜像服务器,就将广东省的访问都指向这台服务器
另外,刚刚提到智能DNS也有缺陷,这里详细描述一下,bind9通过用户的来源IP来返回不同的解释IP,而实际上,并不是实际用户直接访问我们的 DNS,而是用户所使用的DNS(比如说广州ADSL用户的默认DNS)负责访问我们的DNS,网通的DNS就保存有我们网通的IP,如果用户自行修改了 DNS,比如说电信的用户硬要用网通的DNS,或者网通的用户使用国外的DNS(比如opendns之类的),就会导致判断失误

2010/11/03

修改vim的編碼

vim ~/.vimrc 後 i 寫入 enc=utf-8 \n fenc=utf-8 :wq

2010/11/02

[Linux] 在 windows底下讀寫linux

« [Linux] cwRsync [rsync for windows] SSH 加密異地備份
Ubuntu Edgy Release KDE 桌面環境 »
[Linux] 在 windows底下讀寫linux

Dec 15th, 2006 by appleboy 參觀者:9,215Views 機器人:1,295Views
推到 Twitter!
推到 Plurk!
推到 Facebook!

剛剛在ptt看到的,一連串討論

□ XP 認得 ext2/ext3 磁區嗎 ?

裡面有很多文章 寫的不錯,可以提供出來

問題:

想問一下,我有一個移動式硬碟 60G
所以只能format 成 NTFS or ext2/ext3

而在 Linux 下, 目前支援 NTFS 讀寫可能要另外掛 package…

所以想問,那 Windows XP 是否支援 ext2 / ext3
ext3好像不行, 因為剛剛在 Linux 下 format成 ext3了
並備份了一些東東,到進到了Windows XP底下好像認不得了,

想問,ext2 在 Windows XP 底下,OK嗎…
xp認得嗎?

解法如下

作者 wyocbu@kkcity.com.tw (wyocbu),

以前下載過一個商業軟體 Paragon Mount Everything
http://www.mount-everything.com/

印象中好像可以讀寫 ext3

作者 ogre0403 (肚子餓)

只要讀的話 試試這個 應該是free的
http://www.chrysocome.net/explore2fs
寫的話應該不行

作者 alpe (薛丁格的貓)

http://www.fs-driver.org/

IFS Drivewrs 讀寫可… 不過中文編碼就…

作者 adolf.bbs@cd.twbbs.org (蘇怡華 有人要死了),

> http://ext2fsd.sf.net/
> ext2 可讀可寫
> ext3 唯讀

其實這類的driver都可以正常寫ext3
只是把journal關掉而已…

http://pank.org/blog/archives/000621.html


作者 jlovet (阿我真是猜不透XD)

ext2 跟 ext3是相容的檔案系統
在只支援ext2的OS上面mount ext3可以正常讀寫
只是會略過journal

關於ntfs-3g的測試…網站上面就有了…
http://www.ntfs-3g.org/performance.html

Ubuntu 掛載 Windows 分割區

Ubuntu 6.10 (Edgy):
deb http://givre.cabspace.com/ubuntu/ edgy main
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main
deb http://flomertens.keo.in/ubuntu/ edgy main

Ubuntu 6.06 (Dapper Drake):
deb http://givre.cabspace.com/ubuntu/ dapper main main-all
deb http://ntfs-3g.sitesweetsite.info/ubuntu/ dapper main main-all
deb http://flomertens.keo.in/ubuntu/ dapper main main-all

然後執行以下指令更新 repositories 及安裝 ntfs-3g:

wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add -
wget http://givre.cabspace.com/ubuntu/givre_key.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install ntfs-3g

http://www.real-blog.com/linux-bsd-notes/290


文章來源

Ubuntu 9.10 增加 / 設定 語系(Locale)

Ubuntu 9.10 增加 / 設定 語系(Locale)

語系增加在 Debian / Ubuntu Linux 上, 都是編輯 /etc/locale.gen 此檔案, 再執行 locale-gen 即可.

在 Ubuntu Linux 9.10 後, /etc/locale.gen 這個檔案不見了, 設上去也沒有用, 於是來找找新的設定法.
Locales 設定

* 由 "man locale-gen" 可以找到新的設定位置: /var/lib/locales/supported.d/*
* cat /var/lib/locales/supported.d/local # 可以看到目前設定語系

zh_TW.UTF-8 UTF-8

Locales 增加

要增加語系可以有下述兩種做法: (註: 語系列表可見: /usr/share/i18n/SUPPORTED)

1. 手動加入語系
* vim /var/lib/locales/supported.d/zh # 隨意新增一個檔案(zh 這個檔名可隨意命名)

zh_CN.UTF-8 UTF-8
zh_SG.UTF-8 UTF-8
zh_HK.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8

2. 使用 locale-gen 加入語系

1. sudo locale-gen zh_TW
2. sudo locale-gen zh_TW.UTF-8
3. cat /var/lib/locales/supported.d/local # 加入完成後, 可於此檔案看到資訊

重新建立 Locales

上述設定完成後, 執行重新建立的動作.

1. sudo locale-gen # 執行即可
2. 完成可見: ls /usr/lib/locale # 語系檔資料庫.

原始來源

2010/08/23

Rsyslog Template for Fortigate Traffic


CREATE TABLE IF NOT EXISTS `Fortigate` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`log_time` datetime NOT NULL,
`log_id` int(10) unsigned NOT NULL,
`type` varchar(20) NOT NULL,
`subtype` varchar(20) NOT NULL,
`pri` varchar(20) NOT NULL,
`fwver` varchar(20) NOT NULL,
`vd` varchar(20) NOT NULL,
`msg` varchar(100) NOT NULL,
`action` varchar(20) NOT NULL,
`rem_ip` varchar(15) NOT NULL,
`loc_ip` varchar(15) NOT NULL,
`rem_port` int(10) unsigned NOT NULL,
`loc_port` int(10) unsigned NOT NULL,
`out_intf` varchar(20) NOT NULL,
`cookies` varchar(40) NOT NULL,
`user` varchar(20) NOT NULL,
`group` varchar(20) NOT NULL,
`xauth_user` varchar(20) NOT NULL,
`xauth_group` varchar(20) NOT NULL,
`vpn_tunnel` varchar(20) NOT NULL,
`status` varchar(20) NOT NULL,
`init` varchar(20) NOT NULL,
`mode` varchar(20) NOT NULL,
`dir` varchar(20) NOT NULL,
`stage` int(10) unsigned NOT NULL,
`role` varchar(20) NOT NULL,
`result` varchar(20) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

$template fortigate, "insert into Fortigate (log_time,log_id,type,subtype,pri,fwver,vd,msg,action,rem_ip,loc_ip,rem_port,loc_port,out_intf,cookies,user,group,xauth_user,xauth_group,vpn_tunnel,status,init,mode,dir,stage,role,result) values ('%timegenerated:::date-mysql%','%msg:R,ERE,1,BLANK:log_id=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:type=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:subtype=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:pri=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:fwver=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:vd=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:msg=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:action=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:rem_ip=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%,'%msg:R,ERE,1,BLANK:loc_ip=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%',%msg:R,ERE,1,ZERO:rem_port=([0-9]+)--end%,%msg:R,ERE,1,ZERO:loc_port=([0-9]+)--end%,
'%msg:R,ERE,1,BLANK:out_intf=([a-zA-Z0-9_]+)--end%',%msg:R,ERE,1,BLANK:cookies=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:user=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:group=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:xauth_user=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:xauth_group=([a-zA-Z0-9]+)--end%,
%msg:R,ERE,1,BLANK:vpn_tunnel=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:status=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:init=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:mode=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:dir=([a-zA-Z0-9]+)--end%,'%msg:R,ERE,1,BLANK:stage=([a-zA-Z0-9]+)--end%',%msg:R,ERE,1,BLANK:role=([a-zA-Z0-9]+)--end%,%msg:R,ERE,1,BLANK:result=([a-zA-Z0-9]+)--end%)", SQL



CREATE TABLE IF NOT EXISTS `Fortigate2` (
`ID` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`log_time` DATETIME NOT NULL ,
`log_id` INT( 10 ) UNSIGNED NOT NULL ,
`type` VARCHAR( 20 ) NOT NULL ,
`subtype` VARCHAR( 20 ) NOT NULL ,
`pri` VARCHAR( 20 ) NOT NULL ,
`vd` VARCHAR( 20 ) NOT NULL ,
`msg` VARCHAR( 100 ) NOT NULL ,
`action` VARCHAR( 20 ) NOT NULL ,
`user` VARCHAR( 20 ) NOT NULL ,
`status` VARCHAR( 20 ) NOT NULL ,
`reason` VARCHAR( 20 ) NOT NULL ,
`ui` VARCHAR( 20 ) NOT NULL ,
PRIMARY KEY ( `ID` ))
ENGINE = MYISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;

$template fortigate2, "insert into Fortigate2 (log_time,log_id,type,subtype,pri,vd,msg,action,user,status,reason) values ('%timegenerated:::date-mysql%','%msg:R,ERE,1,BLANK:log_id=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:type=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:subtype=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:pri=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:vd=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:msg=([a-zA-Z0-9() .]+)--end%','%msg:R,ERE,1,BLANK:action=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:user="([a-zA-Z0-9]"+)--end%','%msg:R,ERE,1,BLANK:status=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:reason=([a-zA-Z0-9"_]+)--end%')", SQL

2010/08/17

Dialogic 卡片安裝步驟

http://www.dialogic.com/support/helpweb/divasvr/InbuiltDrivers.aspx

2010/08/04

Atheros AR8131 ethernet driver install in CentOS 5.4 x86_64

Atheros AR8131 ethernet driver install in CentOS 5.4 x86_64
分類:Linux
2010/01/24 21:41

1. Download kmod-atl1e-1.0.1.0-3.el5.elrepo.x86_64.rpm

2. If link error, link here http://elrepo.org/linux/elrepo/el5/x86_64/RPMS/

3. rpm -ivh kmod-atl1e-1.0.1 .0-3.el5.elrepo.x86_64.rpm

4. Reboot the CentOS system



Note:

1. If download the AR8131 for Linux driver from Atheros Web-Site, it just can install in

CentOS 5.3 i686/x86_64; Install in CentOS 5.4, it will have error message and can not

load this driver.

2010/04/27

Rsyslog Template for NetScreen Traffic


$template Netscreen, "insert into Netscreen (ReceivedAt,DeviceReportedTime,Facility,Severity,Priority,FromHost,InfoUnitID,SyslogTag,Device_ID,Start_Time,Duration ,Policy_ID ,Service,Proto,Src_Zone,Dst_Zone,Action,Sent ,Rcvd,Src_IP ,Src_Port,Dst_IP ,Dst_Port,Src_Xlated_IP ,Port,Session_ID) values ('%timegenerated:::date-mysql%','%timereported:::date-mysql%',%syslogfacility%,%syslogseverity%,%syslogpriority%,'%fromhost-ip%',%iut%,'%syslogtag%','%msg:R,ERE,1,BLANK:device_id=([a-zA-Z0-9]+)--end%','%msg:R,ERE,1,BLANK:start_time="(.+)"--end%',%msg:R,ERE,1,ZERO:duration=([0-9]+)--end%,%msg:R,ERE,1,ZERO:policy_id=([0-9]+)--end%,'%msg:R,ERE,1,BLANK:service=([a-zA-Z0-9_]+)--end%',%msg:R,ERE,1,ZERO:proto=([0-9]+)--end%,'%msg:R,ERE,1,BLANK:src zone=([a-zA-Z0-9_]+)--end%','%msg:R,ERE,1,BLANK:dst zone=([a-zA-Z0-9_]+)--end%','%msg:R,ERE,1,BLANK:action=([a-zA-Z0-9_]+)--end%',%msg:R,ERE,1,ZERO:sent=([0-9]+)--end%,%msg:R,ERE,1,ZERO:rcvd=([0-9]+)--end%,'%msg:R,ERE,1,BLANK:src=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%',%msg:R,ERE,1,ZERO:src_port=([0-9]+)--end%,'%msg:R,ERE,1,BLANK:dst=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%',%msg:R,ERE,1,ZERO:dst_port=([0-9]+)--end%,'%msg:R,ERE,1,BLANK:src-xlated ip=([0-9]+.[0-9]+.[0-9]+.[0-9]+)--end%',%msg:R,ERE,1,ZERO:[^_]port=([0-9]+)--end%,%msg:R,ERE,1,ZERO:session_id=([0-9]+)--end%)", SQL

Schema for NetScreen Traffic


CREATE TABLE `Netscreen` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ReceivedAt` datetime DEFAULT NULL,
`DeviceReportedTime` datetime DEFAULT NULL,
`Facility` tinyint(3) unsigned DEFAULT NULL,
`Severity` int(10) unsigned DEFAULT NULL,
`Priority` tinyint(3) unsigned DEFAULT NULL,
`FromHost` varchar(60) DEFAULT NULL,
`InfoUnitID` int(10) unsigned DEFAULT NULL,
`SysLogTag` varchar(60) DEFAULT NULL,
`Device_ID` varchar(60) DEFAULT NULL,
`Start_Time` datetime DEFAULT NULL,
`Duration` int(10) unsigned DEFAULT NULL,
`Policy_ID` tinyint(3) unsigned DEFAULT NULL,
`Service` varchar(60) DEFAULT NULL,
`Proto` tinyint(3) unsigned DEFAULT NULL,
`Src_Zone` varchar(60) DEFAULT NULL,
`Dst_Zone` varchar(60) DEFAULT NULL,
`Action` varchar(30) DEFAULT NULL,
`Sent` int(10) unsigned DEFAULT NULL,
`Rcvd` int(10) unsigned DEFAULT NULL,
`Src_IP` varchar(15) DEFAULT NULL,
`Dst_IP` varchar(15) DEFAULT NULL,
`Src_Port` smallint(5) unsigned DEFAULT NULL,
`Dst_Port` smallint(5) unsigned DEFAULT NULL,
`Src_Xlated_IP` varchar(15) DEFAULT NULL,
`Port` smallint(5) unsigned DEFAULT NULL,
`Session_ID` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

2010/03/28

MonitorWare Schema


CREATE TABLE SystemEvents
(
ID int unsigned not null auto_increment primary key,
CustomerID bigint,
ReceivedAt datetime NULL,
DeviceReportedTime datetime NULL,
Facility smallint NULL,
Priority smallint NULL,
FromHost varchar(60) NULL,
Message text,
NTSeverity int NULL,
Importance int NULL,
EventSource varchar(60),
EventUser varchar(60) NULL,
EventCategory int NULL,
EventID int NULL,
EventBinaryData text NULL,
MaxAvailable int NULL,
CurrUsage int NULL,
MinUsage int NULL,
MaxUsage int NULL,
InfoUnitID int NULL ,
SysLogTag varchar(60),
EventLogType varchar(60),
GenericFileName VarChar(60),
SystemID int NULL
);

CREATE TABLE SystemEventsProperties
(
ID int unsigned not null auto_increment primary key,
SystemEventID int NULL ,
ParamName varchar(255) NULL ,
ParamValue text NULL
);


參考文章:
rsyslogの設定@CentOS5.3

2009/05/17

IPSec/L2TP

找了好久才找到的技術資料

資料來源:http://bbs.chinaunix.net/archiver/tid-556457-page-2.html

25 Linux作为一个L2TP/IPsec客户端

25 Linux作为一个L2TP/IPsec客户端
可能有这种情况,你希望使用Linux作为一个客户端连接到一个L2TP/IPsec VPN服务器(比如Windows 2000/2003)。首先请确认你确实需要使用L2TP/IPsec,你是否可以使用单纯的IPsec替代它?在Linux下使用单纯的IPsec更加简单,Linux从内部支持它。Linux客户端使用L2TP只会使事情更加复杂。不过,这样的情况你也许无法绕过它,比如:出于某种策略上的原因,L2TP/IPsec VPN服务器管理员会简单地拒绝支持单纯的IPsec。
假如你使用Linux作为L2TP/IPsec VPN客户端需要截然不同的两个阶段,首先连接到IPsec服务器,然后再通过IPsec隧道连接到L2TP服务器。在Linux下把Openswan配置成客户端与前边提到的配置成服务端稍微有些不同。
# Configuration for connecting to an L2TP/IPsec server,
# for example Windows 2003 Server.
#
# Authenticates through certificates. The Linux client can be
# behind NAT or not.

conn L2TP-CERT-CLIENT
#
# Configuration for clients that are not behind NAT.
# ----------------------------------------------------------
# Use certificates. Disable Perfect Forward Secrecy.
# Respond to rekeying requests but do not initiate rekeying.
# Connection type _must_ be Transport Mode.
#
authby=rsasig
pfs=no
rekey=no
keyingtries=3
type=transport
#
# ----------------------------------------------------------
# The local Linux machine that connects as a client.
#
# The external network interface is used to connect to the server.
# If you want to use a different interface or if there is no
# defaultroute, you can use: left=your.ip.addr.ess
left=%defaultroute
#
# The certificate of this client.
#
leftcert=/etc/ipsec.d/certs/YourClientCertHere.pem
leftrsasigkey=%cert
leftprotoport=17/1701
#
# ----------------------------------------------------------
# The remote server.
#
# Connect to the server with this IP address.
right=123.123.123.123
#
# The server should the present the following certificate.
rightcert=/etc/ipsec.d/certs/YourServerCertHere.pem
rightrsasigkey=%cert
rightca=%same
rightprotoport=17/1701
# ----------------------------------------------------------
#
# Change 'ignore' to 'add' to enable this configuration.
#
auto=ignore
在上边的例子中,想让服务器通过证书来进行验证,需要与包含在证书(YourServerCertHere.pem)中的ID完全相同的ID。还有另一种方法来验证服务器的证书,比如使用rightid=“CN=vpnserver.example.com”或 rightid=“@vpnserver.example.com”来代替rightcert=这一行。另外,一旦你启用了这个配置文件,就可以使用下列命令启动IPsec连接:
ipsec auto --up L2TP-CERT-CLIENT
如果一切正常,你将可以从日志中看到类似下面的一些行:
"L2TP-CERT-CLIENT" #1: initiating Main Mode
"L2TP-CERT-CLIENT" #1: ignoring Vendor ID payload [MS NT5 ISAKMPOAKLEY 00000004]
"L2TP-CERT-CLIENT" #1: ignoring Vendor ID payload [FRAGMENTATION]
"L2TP-CERT-CLIENT" #1: received Vendor ID payload [draft-ietf-ipsec-nat-t-ike-02_n] method set to=106
"L2TP-CERT-CLIENT" #1: enabling possible NAT-traversal with method RFC 3947 (NAT-Traversal)
"L2TP-CERT-CLIENT" #1: transition from state STATE_MAIN_I1 to state STATE_MAIN_I2
"L2TP-CERT-CLIENT" #1: STATE_MAIN_I2: sent MI2, expecting MR2
"L2TP-CERT-CLIENT" #1: NAT-Traversal: Result using draft-ietf-ipsec-nat-t-ike-02/03: i am NATed
"L2TP-CERT-CLIENT" #1: I am sending my cert
"L2TP-CERT-CLIENT" #1: I am sending a certificate request
"L2TP-CERT-CLIENT" #1: transition from state STATE_MAIN_I2 to state STATE_MAIN_I3
"L2TP-CERT-CLIENT" #1: STATE_MAIN_I3: sent MI3, expecting MR3
"L2TP-CERT-CLIENT" #1: Main mode peer ID is ID_DER_ASN1_DN: 'C=NL, ST=ST, L=L,O=TESTORG, CN=duron'
"L2TP-CERT-CLIENT" #1: transition from state STATE_MAIN_I3 to state STATE_MAIN_I4
"L2TP-CERT-CLIENT" #1: STATE_MAIN_I4: ISAKMP SA established {auth=OAKLEY_RSA_SIG cipher=oakley_3des_cbc_192 prf=oakley_sha group=modp1024}
"L2TP-CERT-CLIENT" #2: initiating Quick Mode RSASIG+ENCRYPT+DONTREKEY+UP {using isakmp#1}
"L2TP-CERT-CLIENT" #2: IKE message has the Commit Flag set but Pluto doesn't implement this feature; ignoring flag
"L2TP-CERT-CLIENT" #2: ignoring informational payload, type IPSEC_RESPONDER_LIFETIME
"L2TP-CERT-CLIENT" #2: transition from state STATE_QUICK_I1 to state STATE_QUICK_I2
"L2TP-CERT-CLIENT" #2: STATE_QUICK_I2: sent QI2, IPsec SA established {ESP=>0x6f7e432c <0x43ccbfd7 xfrm=3DES_0-HMAC_SHA1 NATD=none DPD=none}
"L2TP-CERT-CLIENT" #2: IKE message has the Commit Flag set but Pluto doesn't implement this feature; ignoring flag
"L2TP-CERT-CLIENT" #2: message ignored because it contains an unexpected payload type (ISAKMP_NEXT_HASH)
"L2TP-CERT-CLIENT" #2: sending encrypted notification INVALID_PAYLOAD_TYPE to 192.168.0.200:4500
这里有一些错误,即使你已经拥有了一个可以工作的IPsec连接。下一步是使L2TP连接工作起来。首先,你需要在l2tpd.conf中增加“client”节。
; Connect as a client to a server at 123.123.123.123

[lac L2TPserver]
lns = 123.123.123.123
require chap = yes
refuse pap = yes
require authentication = yes
; Name should be the same as the username in the PPP authentication
name = jacco
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd.client
length bit = yes
看来,“name”是必须的,并且要与PPP认证中的用户名相同,即使这里没有L2TP认证。注:我分别为服务器配置和客户端配置创建了不同的pppd选项文件。如下是/etc/ppp/options.l2tpd.client的大致内容:
ipcp-accept-local
ipcp-accept-remote
refuse-eap
noccp
noauth
crtscts
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
“refuse-eap”和“noauth”这几行只能用到客户端配置文件“options.l2tpd”中,不能用到Linux服务器配置文件 “options.l2tpd”中。默认情况下,Windows 2000/2003 Server会首先尝试使用EAP进行PPP认证,如果你不能(或不想)使用EAP(例如:你想使用CHAP或MS-CHAP代替它),你只有拒绝 EAP,否则将开始EAP认证并且将会失败。“noauth”是必须的,因为Windows Server拒绝对它自己进行PPP认证。只有客肩必须认证。你可以随意增加参数“usepeerdns”,因此可以从远程PPP服务器得到两个DNS服务器的IP地址。
你运行下面的命令可以启动L2TP/PPP连接。
echo “c L2TPserver” > /var/run/l2tp-control
现在l2tpd作为一个客户端连接到远程L2TP服务器,L2TP数据包将通过IPsec隧道。通过网络嗅探器(比如:tcpdump,Ethereal等)验证客户端和服务器端之间的L2TP数据包被真正地加密。
当你想中断连接,使用下面的命令:
echo “d L2TPserver” > /var/run/l2tp-control
ipsec auto --down L2TP-CERT-CLIENT
参考l2tpd自带的README来了解更多更详细的L2TP连接。默认情况下,l2tpd监听所有接口。如果你想使用Linux作为 L2TP/IPsec客户端,那么同时把l2tpd作为服务端来运行看起来是多余的。你可以通过使用“listen-addr”参数只绑定到内部接口或者干脆绑定到本地(127.0.0.1)来减少L2TP服务在外界的曝露。
一些L2TP执行者比如l2tpns不能作为客户端使用。