6 月 252013
 

在CentOS 6.3最小化环境下安装依赖软件包

[root@localhost openvpn-2.2.2]# yum install gcc make lzo-devel openssl-devel

编译安装OpenVPN 2.2.2

[root@localhost ~]# tar xzf openvpn-2.2.2.tar.gz
[root@localhost ~]# cd openvpn-2.2.2
[root@localhost openvpn-2.2.2]# ./configure --prefix=/usr/local/openvpn
[root@localhost openvpn-2.2.2]# make
[root@localhost openvpn-2.2.2]# make install

openvpn-install-01

生成证书

openvpn-install-02

编辑控制证书生成工具easy-rsa参数的配置文件

[root@localhost 2.0]# vi vars
# easy-rsa parameter settings

# NOTE: If you installed from an RPM,
# don’t edit this file in place in
# /usr/share/openvpn/easy-rsa —
# instead, you should copy the whole
# easy-rsa directory to another location
# (such as /etc/openvpn) so that your
# edits will not be wiped out by a future
# OpenVPN package upgrade.

# This variable should point to
# the top level of the easy-rsa
# tree.
export EASY_RSA=”`pwd`”

#
# This variable should point to
# the requested executables
#
export OPENSSL=”openssl”
export PKCS11TOOL=”pkcs11-tool”
export GREP=”grep”

# This variable should point to
# the openssl.cnf file included
# with easy-rsa.
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`

# Edit this variable to point to
# your soon-to-be-created key
# directory.
#
# WARNING: clean-all will do
# a rm -rf on this directory
# so make sure you define
# it correctly!
export KEY_DIR=”$EASY_RSA/keys”

# Issue rm -rf warning
echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR

# PKCS11 fixes
export PKCS11_MODULE_PATH=”dummy”
export PKCS11_PIN=”dummy”

# Increase this to 2048 if you
# are paranoid.  This will slow
# down TLS negotiation performance
# as well as the one-time DH parms
# generation process.
export KEY_SIZE=1024

# In how many days should the root CA key expire?
export CA_EXPIRE=3650

# In how many days should certificates expire?
export KEY_EXPIRE=3650

# These are the default values for fields
# which will be placed in the certificate.
# Don’t leave any of these fields blank.
export KEY_COUNTRY=”US”
export KEY_PROVINCE=”CA”
export KEY_CITY=”SanFrancisco”
export KEY_ORG=”Fort-Funston”
export KEY_EMAIL=”me@myhost.mydomain”
export KEY_EMAIL=mail@host.domain
export KEY_CN=changeme
export KEY_NAME=changeme
export KEY_OU=changeme
export PKCS11_MODULE_PATH=changeme
export PKCS11_PIN=1234

执行证书环境配置清理工作

[root@localhost 2.0]# source ./vars
**************************************************************
No /root/openvpn-2.2.2/easy-rsa/2.0/openssl.cnf file could be found
Further invocations will fail
**************************************************************
NOTE: If you run ./clean-all, I will be doing a rm -rf on /root/openvpn-2.2.2/easy-rsa/2.0/keys

[root@localhost 2.0]#
[root@localhost 2.0]# ./clean-all

根据当前系统中安装openssl的版本确定引用openssl配置文件

[root@localhost 2.0]# cp openssl-1.0.0.cnf openssl.cnf

生成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) [US]:CN
 State or Province Name (full name) [CA]:GD
 Locality Name (eg, city) [SanFrancisco]:SHENZHEN
 Organization Name (eg, company) [Fort-Funston]:LINUXCACHE
 Organizational Unit Name (eg, section) [changeme]:LINUXCACHE LABS
 Common Name (eg, your name or your server's hostname) [changeme]:LINUXCACHE CA
 Name [changeme]:
 Email Address [mail@host.domain]:
 [root@localhost 2.0]#

查看已生成的文件

[root@localhost 2.0]# ls keys/
ca.crt  ca.key  index.txt  serial
[root@localhost 2.0]#

生成服务证书

[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) [US]:CN
 State or Province Name (full name) [CA]:GD
 Locality Name (eg, city) [SanFrancisco]:SHENZHEN
 Organization Name (eg, company) [Fort-Funston]:LINUXCACHE
 Organizational Unit Name (eg, section) [changeme]:LINUXCACHE LABS
 Common Name (eg, your name or your server's hostname) [server]:LINUXCACHE SERVER
 Name [changeme]:linuxcache
 Email Address [mail@host.domain]:hostmaster@linuxcache.com
Please enter the following 'extra' attributes
 to be sent with your certificate request
 A challenge password []:
 An optional company name []:
 Using configuration from /root/openvpn-2.2.2/easy-rsa/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:'GD'
 localityName          :PRINTABLE:'SHENZHEN'
 organizationName      :PRINTABLE:'LINUXCACHE'
 organizationalUnitName:PRINTABLE:'LINUXCACHE LABS'
 commonName            :PRINTABLE:'LINUXCACHE SERVER'
 name                  :PRINTABLE:'linuxcache'
 emailAddress          :IA5STRING:'hostmaster@linuxcache.com'
 Certificate is to be certified until Nov 10 06:48:22 2023 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/
 01.pem  ca.key     index.txt.attr  serial      server.crt  server.key
 ca.crt  index.txt  index.txt.old   serial.old  server.csr
 [root@localhost 2.0]#

生成服务器DH文件

[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]#

生成客户端证书

修改客户端证书的有效期
Certificate is to be certified until Dec 12 07:01:44 2013 GMT (30 days)

[root@localhost 2.0]# ./build-key client
Generating a 1024 bit RSA private key
…..++++++
….++++++
writing new private key to ‘client.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) [US]:CN
State or Province Name (full name) [CA]:GD
Locality Name (eg, city) [SanFrancisco]:SHENZHEN
Organization Name (eg, company) [Fort-Funston]:LINUXCACHE
Organizational Unit Name (eg, section) [changeme]:LINUXCACHE LABS
Common Name (eg, your name or your server’s hostname) [client]:CLIENT
Name [changeme]:linuxcache-client
Email Address [mail@host.domain]:client@linuxcache.com

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /root/openvpn-2.2.2/easy-rsa/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:’GD’
localityName          :PRINTABLE:’SHENZHEN’
organizationName      :PRINTABLE:’LINUXCACHE’
organizationalUnitName:PRINTABLE:’LINUXCACHE LABS’
commonName            :PRINTABLE:’CLIENT’
name                  :PRINTABLE:’linuxcache-client’
emailAddress          :IA5STRING:’client@linuxcache.com’
Certificate is to be certified until Nov 10 06:54:04 2023 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/
01.pem  ca.key      client.key  index.txt.attr      serial      server.csr
02.pem  client.crt  dh1024.pem  index.txt.attr.old  serial.old  server.key
ca.crt  client.csr  index.txt   index.txt.old       server.crt
[root@localhost 2.0]#

openvpn-install-03

 

6 月 242013
 

查看当前系统发行版本

[root@localhost ~]# cat /etc/redhat-release
 CentOS release 6.4 (Final)
[root@localhost ~]#

安装PPP包

[root@localhost ~]# yum install ppp

下载

[root@localhost ~]# wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.i686.rpm

查看pptpd二进制包安装路径

[root@localhost ~]# rpm -lpq pptpd-1.3.4-2.el6.i686.rpm
 warning: pptpd-1.3.4-2.el6.i686.rpm: Header V3 DSA/SHA1 Signature, key ID 862acc42: NOKEY
 /etc/ppp/options.pptpd
 /etc/pptpd.conf
 /etc/rc.d/init.d/pptpd
 /usr/bin/vpnstats.pl
 /usr/bin/vpnuser
 /usr/lib/pptpd/pptpd-logwtmp.so
 /usr/sbin/bcrelay
 /usr/sbin/pptp-portslave
 /usr/sbin/pptpctrl
 /usr/sbin/pptpd
 /usr/share/doc/pptpd-1.3.4
 /usr/share/doc/pptpd-1.3.4/AUTHORS
 /usr/share/doc/pptpd-1.3.4/COPYING
 /usr/share/doc/pptpd-1.3.4/ChangeLog
 /usr/share/doc/pptpd-1.3.4/INSTALL
 /usr/share/doc/pptpd-1.3.4/README
 /usr/share/doc/pptpd-1.3.4/README.bcrelay
 /usr/share/doc/pptpd-1.3.4/README.cvs
 /usr/share/doc/pptpd-1.3.4/README.inetd
 /usr/share/doc/pptpd-1.3.4/README.logwtmp
 /usr/share/doc/pptpd-1.3.4/README.portslave
 /usr/share/doc/pptpd-1.3.4/README.slirp
 /usr/share/doc/pptpd-1.3.4/TODO
 /usr/share/doc/pptpd-1.3.4/samples
 /usr/share/doc/pptpd-1.3.4/samples/chap-secrets
 /usr/share/doc/pptpd-1.3.4/samples/options.pptpd
 /usr/share/doc/pptpd-1.3.4/samples/pptpd.conf
 /usr/share/man/man5/pptpd.conf.5.gz
 /usr/share/man/man8/pptpctrl.8.gz
 /usr/share/man/man8/pptpd.8.gz
 [root@localhost ~]#

安装pptp安装包

[root@localhost ~]# rpm -ivh pptpd-1.3.4-2.el6.i686.rpm
warning: pptpd-1.3.4-2.el6.i686.rpm: Header V3 DSA/SHA1 Signature, key ID 862acc42: NOKEY
Preparing...                ########################################### [100%]
1:pptpd                  ########################################### [100%]
[root@localhost ~]#

设置服务器端虚拟接口IP地址和客户端IP地址池

[root@localhost ~]# cp /etc/pptpd.conf /etc/pptpd.conf.backup
[root@localhost ~]# vi /etc/pptpd.conf
localip 10.0.192.1
remoteip 10.0.192.100-200

设置拨号账户用户名与密码

[root@localhost ~]# cd /etc/ppp/
[root@localhost ppp]# cp chap-secrets chap-secrets.backup
[root@localhost ppp]# vi chap-secrets
harvey          pptpd           78903456                *

第一列:用户名
第二列:服务器名称(与/etc/ppp/options.pptpd中对应)centos-pptp-01
第三列:密码
第四列:限定连接用户的IP地址

设定客户端DNS

[root@localhost ppp]# vi options.pptpd
ms-dns 8.8.8.8
ms-dns 8.8.4.4

查看并设置pptpd服务开机启动状态

[root@localhost ppp]# chkconfig --list pptpd
pptpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@localhost ppp]# chkconfig --level 35 pptpd on

启动pptpd服务器

[root@localhost ppp]# service pptpd start
Starting pptpd:                                            [  OK  ]
[root@localhost ppp]#

确认服务已运行且监听1723端口

[root@localhost ppp]# netstat -ltn |grep 1723
tcp        0      0 0.0.0.0:1723                0.0.0.0:*                   LISTEN
[root@localhost ppp]#

设置IP包转发
临时设置

[root@localhost ppp]# echo 1 > /proc/sys/net/ipv4/ip_forward

开机设置

[root@localhost ppp]# vi /etc/sysctl.conf
net.ipv4.ip_forward = 1

使用Windows作为客户端连接pptpd服务器

新建拨号连接

centos-pptp-02

拨号连接向导

centos-pptp-03 centos-pptp-04 centos-pptp-05 centos-pptp-06

输入VPN服务器的IP地址

centos-pptp-07 centos-pptp-08

点击新建的VPN拨号连接,输入用户名密码后点连接

centos-pptp-09

拨号连接成功

centos-pptp-10

查看本机拨号连接获得的IP地址

centos-pptp-11

查看服务器端PPP网关接口状态

centos-pptp-12

拨号连接后成功后,使用ping www.facebook.com超时,显示无法正常访问被限制网站

centos-pptp-13

防火墙转发设置

[root@localhost ~]# iptables -t nat -A POSTROUTING -o eth0 -s 10.0.192.0/24 -j SNAT --to 174.139.2.162
[root@localhost ~]# iptables save
Bad argument `save'
Try `iptables -h' or 'iptables --help' for more information.
[root@localhost ~]#
[root@localhost ~]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@hvpn ~]#
[root@localhost ~]# /etc/init.d/iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: nat             [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@localhost ~]#
[root@localhost ~]# service pptpd restart
Shutting down pptpd:                                       [  OK  ]
Starting pptpd:                                            [  OK  ]
Warning: a pptpd restart does not terminate existing
connections, so new connections may be assigned the same IP
address and cause unexpected results.  Use restart-kill to
destroy existing connections during a restart.
[root@localhost ~]#

查看已生效的转发策略

[root@localhost ~]# service iptables status
Table: nat
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination
1    SNAT       all  —  10.0.192.0/24        0.0.0.0/0           to:174.139.2.162

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

[root@localhost ~]#

 

在服务器添加防火墙转发规则以后再次ping www.facebook.com显示可以正常访问被限制网站

centos-pptp-14

iptables -I INPUT -p gre -j ACCEPT

相关下载:
(1)pptpd 1.3.4-2 rhel6 x86 rpm package (2) pptpd 1.3.4-2 rhel6 x86_64 rpm package

6 月 092013
 

本地或SSH登录成功后命令提示符出现之前显示的Banner信息

添加信息
[root@monitor ~]# vi /etc/motd

使用SSH远程登录时的显示信息

使用本地登录时显示的信息

使用SSH登录输入用户名后显示的信息 /etc/issue.net

[root@monitor ~]# vi /etc/issue.net

本地登录前显示的信息 /etc/issue

[root@monitor ~]# vi /etc/issuecentos-login-banner-01 centos-login-banner-02 centos-login-banner-03 centos-login-banner-04 centos-login-banner-05 centos-login-banner-06 centos-login-banner-07 centos-login-banner-08 centos-login-banner-09

6 月 082013
 

服务器配置双网卡

eth0 101.x.x.3 映射至 192.168.197.3

eth1 175.x.x.234

故障状态

查看当前eth0接口状态信息

rhrl54-bcm5709-driver-01

通过位于同一交换机连接下的其他主机ping当前主机eth0接口

rhrl54-bcm5709-driver-02

通过接口流量监控查看网络多次中断

rhrl54-bcm5709-driver-03

通过设备信息查看硬件错误信息

NETDEV WATCHDOG: eth0: transmit timed out

rhrl54-bcm5709-driver-04

临时解决方法

[root@localhost ~]# service network restart

再次确认问题

rhrl54-bcm5709-driver-05

查看当前内核驱动模块版本

rhrl54-bcm5709-driver-06

下载2.0.8e版本BCM57xx系列驱动并升级安装

执行安装脚本时的错误提示

rhrl54-bcm5709-driver-07

安装依赖软件包

rhrl54-bcm5709-driver-08

[root@localhost ~]# nohup ./install.sh –update –override &

[root@localhost ~]# tail nohup.out

rhrl54-bcm5709-driver-09

查看更新后的内核驱动模块版本信息

rhrl54-bcm5709-driver-10

重启系统(远程操作)或卸载并重新加载驱动模块(本地操作)

[root@localhost ~]# rmmod bnx2
[root@localhost ~]# modprobe bnx2

查看接口驱动加载情况

[root@localhost ~]# ethtool -i eth0
 driver: bnx2
 version: 2.0.8e
 firmware-version: bc 5.0.6 NCSI 2.0.3
 bus-info: 0000:0b:00.0
[root@localhost ~]#

 

相关下载:
(1) BCM