1、安装加密软件包
[root@localhost ~]#rpm -ivh lzo-2.02-3.el5.kb.i386.rpm
2、安装openvpn
[root@localhost ~]#rpm -ivh openvpn-2.1-0.20.rc4.el5.kb.i386.rpm
3、复制生成证书密钥的文件夹
[root@localhost ~]#cp -r /usr/share/openvpn/easy-rsa/2.0/ /etc/openvpn/
4、复制范例的配制文件
[root@localhost ~]#cp /usr/share/doc/openvpn-2.1/sample-config-files/server.conf /etc/openvpn/
5、生成证书key
(1)初始化PKI
[root@localhost ~]# cd /etc/openvpn/2.0/
[root@localhost 2.0]# vi vars
修改正在面几项
export KEY_COUNTRY=”CN”(注:国家)
export KEY_PROVINCE=”SX”(注:省份)
export KEY_CITY=”XA”(注:城市)
export KEY_ORG=”VPN-TEST”(注:公司名称)
export KEY_EMAIL=”[email protected]”(注:电子邮件)
[root@localhost 2.0]#env |grep KEY(先查看一下,看到是没有)
[root@localhost 2.0]# source ./vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/2.0/keys
(注:如果你已经运行了./clean-all,就运行rm -rf /etc/openvpn/2.0/keys 删除)
[root@localhost 2.0]# env |grep KEY
KEY_EXPIRE=3650
[email protected]
KEY_SIZE=1024
KEY_DIR=/etc/openvpn/2.0/keys
KEY_CITY=XA
KEY_PROVINCE=SX
KEY_ORG=VPN-TEST
KEY_CONFIG=/etc/openvpn/2.0/openssl.cnf
KEY_COUNTRY=CN
[root@localhost 2.0]#
[root@localhost 2.0]# ./clean-all (这时会在当前目录生成一个keys的目录)
生成ca文件
[root@localhost 2.0]# ./build-ca
Generating a 1024 bit RSA private key
….++++++
..++++++
writing new private key to ‘ca.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [CN]:
State or Province Name (full name) [SX]:
Locality Name (eg, city) [XA]:
Organization Name (eg, company) [VPN-TEST]:
Organizational Unit Name (eg, section) []:vpn
Common Name (eg, your name or your server’s hostname) [VPN-TEST CA]:server(注意一定要添server)
Email Address [[email protected]]:
[root@localhost 2.0]# ls keys/ (可以看到keys下生成了ca.crt ca.key 两个文件)
(2)生成server key
[root@localhost 2.0]# ./build-key-server server
Generating a 1024 bit RSA private key
………..++++++
…………………………………………………++++++
writing new private key to ‘server.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [CN]:
State or Province Name (full name) [SX]:
Locality Name (eg, city) [XA]:
Organization Name (eg, company) [VPN-TEST]:
Organizational Unit Name (eg, section) []:vpn
Common Name (eg, your name or your server’s hostname) [server]:server
Email Address [[email protected]]:
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:boobooke(注:密码一定要添)
An optional company name []:
Using configuration from /etc/openvpn/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName :PRINTABLE:’CN’
stateOrProvinceName :PRINTABLE:’SX’
localityName :PRINTABLE:’XA’
organizationName :PRINTABLE:’VPN-TEST’
organizationalUnitName:PRINTABLE:’vpn’
commonName :PRINTABLE:’server’
emailAddress :IA5STRING:’[email protected]’
Certificate is to be certified until Dec 31 13:40:06 2019 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
[root@localhost 2.0]#
[root@localhost 2.0]# ls keys/ (可以看到生成了server.crt server.csr server.key)
(3)生成客户端 key
[root@localhost 2.0]# ./build-key client1
Generating a 1024 bit RSA private key
……………………………..++++++
…..++++++
writing new private key to ‘client1.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [CN]:
State or Province Name (full name) [SX]:
Locality Name (eg, city) [XA]:
Organization Name (eg, company) [VPN-TEST]:
Organizational Unit Name (eg, section) []:vpn
Common Name (eg, your name or your server’s hostname) [client1]:
Email Address [[email protected]]:
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:boobooke
An optional company name []:
Using configuration from /etc/openvpn/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName :PRINTABLE:’CN’
stateOrProvinceName :PRINTABLE:’SX’
localityName :PRINTABLE:’XA’
organizationName :PRINTABLE:’VPN-TEST’
organizationalUnitName:PRINTABLE:’vpn’
commonName :PRINTABLE:’client1′
emailAddress :IA5STRING:’[email protected]’
Certificate is to be certified until Dec 31 13:43:36 2019 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
以上选项要和那个server的保持一致。
[root@localhost 2.0]# ls keys/ (可以看到生成了 client1.crt client1.key client1.csr )
生成Diffie Hellman
[root@localhost 2.0]# ./build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
………………………………………………………………………………………………………………………………………………+……………………………………………+……………………………………+………………………………………………………+……..+………………………….+………………………………………….+…………………………………………………..
………………………………………+………………………………………………………………..+……………………………………………………………………………………………….+……………………….+……………+……………………………………………..+…………………..+……….+……….+.+………..+…………………………………..+………+…………………………………+…………………………………………+…………………….+…………………….+……………………………………………………………….+…………………………………+…..+……………………………………….+……………………+………………………………………….++*++*++*
[root@localhost 2.0]#
创建服务端配置文件
将keys下的 ca.crt server.crt server.key dh1024.pem 拷贝到/etc/openvpn下。
配制/etc/openvpn/server.conf
[root@localhost openvpn]# vi server.conf
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
server 10.8.0.0 255.255.255.0
client-to-client
keepalive 10 120
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 4
push “dhcp-option DNS “202.98.5.68″
“server.conf” 16L, 249C written
[root@localhost openvpn]#
启动服务
[root@localhost openvpn]# service openvpn restart
服务启动后用ifconfig查看 可以看到有一个新的接口tun0
[root@localhost openvpn]# ifconfig
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2804 (2.7 KiB) TX bytes:18332 (17.9 KiB)
Windows上的客户端的设置
安装openvpn软件
copy 服务器上的/etc/openvpn/2.0/keys/下的ca.crt ca.key client1.crt client1.csr client1.key 到C:\Program Files\OpenVPN\config下
copy C:\Program Files\OpenVPN\sample-config\client.ovpn 到C:\Program Files\OpenVPN\config下
使用记事本编辑client.ovpn
client
dev tun
proto udp
remote 222.161.0.93 1194
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
ns-cert-type server
comp-lzo
verb 3
redirect-gateway def1
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
这只能看出大至的信息而无法看到详细的信息。
[root@localhost ~]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.4 (Final)
Release: 5.4
Codename: Final
创建并进入acl 3000
acl number 3000
创建rule 0 禁止 目的地址 xxx.xxx.xxx.xxx 0(这个0是反掩码) 目的端口是80
rule 0 deny tcp destination xxx.xxx.xxx.xxx 0 destination-port eq www
进入上行端口
interface GigabitEthernet 1/1
下发规则
packet-filter inbound ip-group 3000 rule 0
Linux中的所有命令(包括函数)都是采用的系统时钟设置。在Linux中,用于时钟查看和设置的命令主要有date、hwclock和 clock。其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。
1、date
查看系统时间
# date
设置系统时间
#date -s “2009-12-28 13:34:00″
2、clock
查看硬件时间
# clock
设置硬件时间
clock –set –date “2009-12-28 13:34:00″
3、硬件时间和系统时间的同步
硬件时钟钟和系统时同步:
# clock –hctosys (注:hc为硬件时钟,sys为系统时钟,我理解为写硬件时间到系统时间。即把系统时钟改为硬件的时钟。)
系统时钟和硬件时钟同步:
与上面的正好相反
# clock –systohc (注:hc为硬件时钟,sys为系统时钟,我理解为写系统时间到硬件时间。即把硬件时钟改为系统时钟。)
一直在用ue,不过都是当记事本来用的。大才小用了。最近总是要用到查找替换,一般都是在网上搜一些来用,今天看了一下ue自己的帮助文件。原来说明的很详细。发来上,记录一下。
UltraEdit 允许在搜索菜单下面列出的大多数搜索和替换功能中使用正则表达式。
正则表达式允许在一次操作中执行多个组合搜索和替换功能。
这里有两个可以使用的语法集。下面的第一个表显示用于早期 UltraEdit 的原始 UltraEdit 语法。第二个表显示可选的“Unix”样式的正则表达式。这可以从配置段启用。
正则表达式 (UltraEdit 语法):
| 符号 | 功能 |
| % | 匹配行首 – 表示搜索字符串必须在行首,但不包括任何选定的结果字符中的行终止字符。 |
| $ | 匹配行尾 – 表示搜索字符串必须在行尾,但不包括任何选定的结果字符中的行终止字符。 |
| ? | 匹配任何除换行符的字符。 |
| * | 匹配任何除换行符外所出现的任意数量的字符。 |
| + | 匹配一个或多个前面的字符/表达式。必须找到至少一个出现的字符。不匹配重复的换行符。 |
| ++ | 0 次或多次匹配前面的字符/表达式。不匹配重复的换行符。 |
| ^b | 匹配一个分页符。 |
| ^p | 匹配一个换行符 (CR/LF) (段落) (DOS 文件) |
| ^r | 匹配一个换行符 (仅 CR) (段落) (MAC 文件) |
| ^n | 匹配一个换行符 (仅 LF) (段落) (UNIX 文件) |
| ^t | 匹配一个制表符 |
| [ ] | 匹配任何括号中的单个字符或范围 |
| ^{A^}^{B^} | 匹配表达式 A 或 B |
| ^ | 忽略其后的正则表达式字符 |
| ^(*^) | 在表达式加上括号或标签在替换命令中使用。正则表达式中可以有 9 个表达式标签,数字根据它们在正则表达式中的次序确定数字。 相应的替换表达式是 ^x,x 的范围是 1-9。例如: 如果 ^(h*o^) ^(f*s^) 匹配“hello folks”,那么^2 ^1 表示将用“folks hello”替换它。 |
注意 – ^ 这里涉及的字符“^”不是控制键 + 值。
例如:
m?n 匹配“man”、“men”、“min”,但不匹配“moon”。
t*t 匹配“test”、“tonight”和“tea time”中的“tea t”部分,但不匹配“tea
time” (“tea ”和“time”之间有换行)。
Te+st 匹配“test”、“teest”、“teeeest”等,但不匹配“tst”。
[aeiou] 匹配每个元音小写字母
[,.?] 匹配文字“,”、“.”或“?”。
[0-9a-z] 匹配任何数字或小写字母
[~0-9] 匹配除数字外的任何字符 (~ 表示不匹配其后的内容)
你可以搜索象下面一样的表达式 A 或 B:
“^{John^}^{Tom^}
这将搜索 John 或 Tom。在两个表达式之间应该没有任何其它内容。
你可以在同一次搜索象下面一样组合 A 或 B 和 C 或 D:
“^{John^}^{Tom^} ^{Smith^}^{Jones^}”
这将搜索后面跟随了 Smith 或 Jones 的 John 或 Tom。
下面的表显示“Unix”样式的正则表达式语法。
正则表达式 (Unix 语法):
| 符号 | 功能 |
| \ | 表示下一个字符有特殊含义。“n”表示匹配字符“n”,“\n”匹配一换行符。看下面的例子 (\d、\f、\n 等)。 |
| ^ | 匹配/停驻行首。 |
| $ | 匹配/停驻行尾。 |
| * | 匹配前面的字符 0 次或多次。 |
| + | 匹配前面的字符一次或多次。不匹配重复的换行符。 |
| . | 匹配任何除换行符之外的单个字符。不匹配重复的换行符。 |
| (表达式) | 在表达式加上括号或标签在替换命令中使用。正则表达式中可以有 9 个表达式标签,数字根据它们在正则表达式中的次序确定数字。 相应的替换表达式是 ^x,x 的范围是 1-9。例如: 如果 ^(h*o^) ^(f*s^) 匹配“hello folks”,那么^2 ^1 表示将用“folks hello”替换它。 |
| [xyz] | 字符集,匹配任何括号间的字符。. |
| [^xyz] | 排除字符集。匹配任何不在括号间的字符。 |
| \d | 匹配一个数字字符。等同于 [0-9]。 |
| \D | 匹配一个非数字字符,等同于 [^0-9]。 |
| \f | 匹配一个换页符。 |
| \n | 匹配一个换行符。 |
| \r | 匹配一个回车符。 |
| \s | 匹配任何包含空格、制表符等不会显示的字符,但不匹配换行符。 |
| \S | 匹配任何非空白区域 (显示字符) 的字符,但不匹配换行符。 |
| \t | 匹配一个制表符。 |
| \v | 匹配一个垂直制表符。 |
| \w | 匹配任何包含下划线的词语。 |
| \W | 匹配任何非词语的字符。 |
| \p | 匹配 CR/LF (等同于 \r\n),用来匹配 DOS 行终止符。 |
注意 – ^ 这里所涉及的字符“^”不是控制键 + 值。
例如:
m.n 匹配“man”、“men”、“min”,但不匹配“moon”。
Te+st 匹配“test”、“teest”、“teeeest”等,但不匹配“tst”。
Te*st 匹配“test”、“teest”、“teeeest”等,还有“tst”。
[aeiou] 匹配每个元音小写字母
[,.?] 匹配文字“,”、“.”或“?”。
[0-9a-z] 匹配任何数字或小写字母
[^0-9] 匹配除数字外的任何字符 (~ 表示不匹配其后的内容)
你可以象下面一样的表达式 A 或 B 进行搜索:
“(John|Tom)”
这将搜索 John 或 Tom。在两个表达式之间应该没有任何其它内容。
你可以在同一次搜索象下面一样组合 A 或 B 和 C 或 D:
“(John|Tom) (Smith|Jones)”
这将搜索 Smith 或 Jones 以及跟随在后面的 John 或 Tom。
如果在查找/替换中没有选择使用正则表达式,在替换对象中下列特殊字符同样有效:
| 符号 | 功能 |
| ^^ | 匹配字符“^” |
| ^s | 表示活动文件窗口中选定 (加亮) 的文字。 |
| ^c | 表示剪贴表的内容。 |
| ^b | 匹配一个分页符。 |
| ^p | 匹配一个换行符 (CR/LF) (段落) (DOS 文件) |
| ^r | 匹配一个换行符 (仅 CR) (段落) (MAC 文件) |
| ^n | 匹配一个换行符 (仅 LF) (段落) (UNIX 文件) |
| ^t | 匹配一个制表符 |
注意 – ^ 这里所涉及的字符“^”不是控制键 + 值。










