一、apache 防盗链    地址重写

http://192.168.4.254/254.html

盗链代码

192.168.4.254  web-server

vim  254.html

<html>

     <body>

         <a href="http://192.168.4.253/one.png" >  show p_w_picpath </a>

     </body>

</html>

 

192.168.4.253服务器上做防盗链配置

vim  httpd.conf

<Directory"/usr/local/httpd/htdocs">

   Options Indexes FollowSymLinks

   AllowOverride None

   Order allow,deny

   Allow from all

RewriteEngine on

RewriteCond %{HTTP_REFERER}  !^$

RewriteCond %{HTTP_REFERER}  !^http://192.168.4.253/.*$  [NC]

RewriteRule .*\.(jpg|gif|png|jpeg)$ http://192.168.4.253/err.html [R,L]

</Directory>

 

[root@localhost htdocs]# cat err.html

<html>

     <body>

          <h1>dao lian  ke  chi</h1>

     </body>

</html>

 

 

地址重写:修改客户端访问自己的url地址

 

常用指令

RewriteEngine:启用(设为On)重写引擎

RewriteCond:指定重写条件

RewriteRule:设置重写策略

 

 

a.jpeg

xxx.jpeg

 

 192.168.4.254

http://server-ip/254.html

                           盗链代码

 

 

 

启动ip192.168.4.253上服务器上的源码apache 服务

能够在客户端地址254pc上访问其下的网页文件。

 

 

搭建rsync服务器

本地同步

本地同步时不需要启动rsync服务

安装rsync软件包

一、rsync  (做数据远程同步的服务)

     同步数据时只同步数据源新产生的文件和有变化的文件

     数据传输时是加密的

 

本地数据同步(要有rsync命令 /boot    /bootbak

rpm -q  rsync

命令格式

rsync  【选项】    源文件    目标目录

 rsync     –av            /usr/http           /http        备份包含http这个文件夹在内的所有文件

 rsync    –av            /usr/http/         /http             备份http下所有文件

 

 mkdir  /webback

rsync -av /usr/local/httpd/htdocs     /webback/

 

rsync -av /usr/local/httpd/htdocs/ /webback/

选项

--delete:删除目标有而源没有的文件

--backup 删除目标有而源没有的文件时先备份删除的文件

--backup-dir=DIR  指定备份删除的文件的目录

--password-file=:指定认证口令文件

 

 

 

[root@mail testdir]# rsync  -av --backup --backup-dir=/backdir  --delete /testdir/     /testbak/

网络数据同步(rsync服务)

远程同步:

ip192.168.4.254的网站服务器的网页文件,IP192.168.4.253的网站服务器上下载

 

1

在服务器253254上运行网站服务器。

vim /etc/xinetd.d/rsync

2、在253上配置rsync服务共享目录

     /usr/local/httpd/htdocs/

2.1

[root@localhost htdocs]# rpm -q rsync

rsync-3.0.6-4.el5_7.1

 

2.2 启动rsync服务

 

非独立运行(不常驻内存)

*所有非独立运行的服务,统一有系统的xinetd服务管理。

vim /etc/xinetd.d/rsync

disable = no

#disable = yes

:wq

 

/etc/init.d/xinetd  restart

[root@localhost ~]# netstat  -untlap | grep :873

 

 

独立运行 (常驻内存)

[root@localhost ~]# vim  /etc/xinetd.d/rsync

       disable = yes

[root@localhost xinetd.d]#

/etc/init.d/xinetd  restart

touch /etc/rsyncd.conf  创建主配置文件

/usr/bin/rsync --daemon   启动服务

netstat -utnalp | grep :873

pkill -9 rsync    停止服务

 

rsync服务设置为独立启动模式:

[root@mail xinetd.d]# vim/etc/xinetd.d/rsync

[root@mail xinetd.d]# grep yes/etc/xinetd.d/rsync

       disable = yes

 

[root@mail xinetd.d]# /etc/init.d/xinetdrestart

 

[root@mail xinetd.d]# netstat -utnalp |grep :873

 

[root@mail xinetd.d]# touch  /etc/rsyncd.conf

[root@mail xinetd.d]# /usr/bin/rsync  --daemon

[root@mail xinetd.d]# netstat -utnalp |grep :873

 

 

编辑配置文件共享数据(与samba服务的共享方式一样)

vim  /etc/rsyncd.conf

[共享名]

path = 共享目录的物理路径

comment = 描述信息

read only = yes/no

auth users = 用户名

secrets file = 目录名/文件名(用户名:密码  600

 

 

192.168.1.100服务器 /testdir 目录共享给客户端 

访问时使用用户名 getuser  密码 get88  只有下载数据的权限

共享名sharedir

 

 

客户端下载数据的命令格式(客户端要提供rsync命令)

 

下载数据:

rsync -a  user@host::共享名  本地目录

 

 

 

[root@svr6 ~]# rsync    getuser@192.168.1.100::

 

客户端下载rsync服务器共享的数据到备份目录下

 

mkdir /bakdir

[root@svr6 ~]# touch /etc/user.txt

 

[root@svr6 ~]# vim  /etc/user.txt

get88

:wq

 

[root@svr6 ~]# chmod 600   /etc/user.txt

 

[root@svr6 ~]# rsync  -av --backup --backup-dir=/oldback --delete --password-file=/etc/user.txt getuser@192.168.1.100::sharedir  /bakdir

 

 

上传数据(rsync服务器端的开放用户的上传权限,目录本身要有被写的权限)

格式:

rsync  -a   本地目录     user@host::共享名

独立服务

 

[root@localhost xinetd.d]# vim/etc/xinetd.d/rsync

disabled = yes

[root@localhost xinetd.d]#/etc/init.d/xinetd restrart

[root@localhost xinetd.d]# touch/etc/rsyncd.conf

[root@localhost xinetd.d]# which rsync

/usr/bin/rsync

[root@localhost xinetd.d]# /usr/bin/rsync--daemon

 

编辑主配置文件共享目录给客户端

[root@localhost xinetd.d]# vim/etc/rsyncd.conf

 

[共享名]

path         =     /usr/local/httpd/htdocs/  --共享目录

read only           =       no     /yes          

auth users =  webuser                                    访问用户名

secrets     file    =       /etc/user_pass.txt           访问密码

 

vim /etc/user_pass.txt

webuser : 123456

:x

chmod 600 /etc/user_pass.txt

 

pkill          -9      rsync

 

  • 共享目录用户有上传的权限,低于文件系统本身的权限.

 

客户端访问:

rsync       -q     

 

 

rsync         -av    --delete    webuser@192.168.4.253::webdit          /var/www/html

 

 

 

man   rsyncd.conf     查看配置文件的帮助信息

编辑主配置文件共享目录给客户端

vim /etc/rsyncd.conf

[webdir]

path = /usr/local/httpd/htdocs/

read only =  no

auth  users = webuser

secrets file = /etc/user_pass.txt

:wq

vim /etc/user_pass.txt

webuser:123456

:wq

chmod 600  /etc/user_pass.txt

pkill  -9   rsync

/usr/bin/rsync   --daemon

 

*配置文件中的权限,低于文件系统本身的权限。

 

客户端访问:

安装提供访问rsync服务器的rsync命令

rpm -q  rsync

 

rsync   rsync_ip::    查看服务器端的共享名

 

 

下载数据的命令格式

rsync 选项  username@rsync_ip::共享名  本地目录

 

创建保存用户密码的文件

echo  123456  >    /etc/userp.txt

chmod 600  /etc/userp.txt

 

从服务器上下载文件

[root@localhost html]# rsync -a --delete--password-file=/etc/userp.txt webuser@192.168.4.253::webdir  /var/www/html/

 

rsync服务练习

rsync服务器本机网站目录共享,客户端可以使用webuser用户访问时有上传和下载的权限  密码是webuser88

 

rsync服务器本机/homewok目录共享 客户端可以使用webuser用户访问,只有下载数据权限。下载数据时,备份删除的文件到本机的/bakdir目录里。

 

把用户用户上传、下载数据的操作使用计划任务完成,执行任务周期自己设置。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

二、ntp  

 

服务器   192.168.1.100

 

 

客户端    192.168.1.200

 

ntpq -p  192.168.1.100

 

remote :响应这个请求的NTP服务器的名称

refid NTP服务器使用的上一级ntp服务器

st remote远程服务器的级别.从高到低可以设定为1-16.为了减缓负荷和网络堵塞,原则上应该避免直接连接到级别为1的服务器的.

when:上一次成功请求之后到现在的秒数。

poll :本地机和远程服务器多少时间进行一次同步(单位为秒).在一开始运行NTP的时候这个poll值会比较小,那样和服务器同步的频率也就增加了,可以尽快调整到正确的时间范围,之后poll值会逐渐增大,同步的频率也就会相应减小

reach :这是一个八进制值,用来测试能否和服务器连接.每成功连接一次它的值就会增加

delay :从本地机发送同步要求到ntp服务器的roundtrip time

offset :主机通过NTP时钟同步与所同步时间源的时间偏移量,单位为毫秒(ms)。offset越接近于0,主机和ntp服务器的时间越接近

jitter :这是一个用来做统计的值.它统计了在特定个连续的连接数里offset的分布情况.简单地说这个数值的绝对值越小,主机的时间就越精确