会员控制台 会员登陆 会员注册 最后更新 高级搜索 会员投稿 退出登陆
设为首页
收藏本站
留言给我
  首页 | 操作系统类 | 程序设计类 | 数据库类 | 应用服务类 | 网络及硬件类 | 其他技术 | GBunix论坛
操作系统类
程序设计类
数据库类
应用服务类
网络及硬件类
其他技术
Unix中文 / 操作系统类 / Linux / 解决RedHat9的VPNserver的DDOS问题
解决RedHat9的VPNserver的DDOS问题
2004-10-31    PXE2    www.linuxfans.org    点击:
解决RedHat9的VPNserver的DDOS问题
1. 简介

解决了CIPE 在处理异常条件下存在错误可导致产生拒绝服务攻击。如果应用程序接收到一个比它能处理最小CIPE包还小的包,就可以导致系统崩溃,停止后续处理。
CIPE运行在内核级别可以导致系统崩溃,或者不可测的数据丢失。

本是Linux Cipe+Masquerading mini-HOWTO. 本文解释如何使用cipe经由linux masquerading firewall主机,来建立一个介於您的局烛网(LAN)与其它局烛网之间的虚拟私有网络(Virtual Private Network)。

1.1. 版权声明

(C)opyright 1998 Anthony Ciaravalo, acj@home.com

除非特别声明,否则Linux HOWTO文件的版权是归原作者所有。只要保证版权受到保护,Linux HOWTO文件能够以任何电子或实体媒介来进行完整或部分的复制、散布。商业化的重制是被允许的,甚至加以鼓励;但前提是必须知会原作者。

所有源自於Linux HOWTO的文件(包括翻译、改编、汇整等等)都必须包含本版权声明。也就是说,任何人皆不能在文件的散布上加诸其它限制。除非在某些特定情况下,才得以用特例允许;详情请与Linux HOWTO coordinator洽询,联络方式见後述。

如果您有任何疑问,欢迎洽询Linux HOWTO coordinator Greg Hankins ,您可以查询(finger)这个帐号以取得联络电话或邮件地址。

1.2 责任承担声明

使用此份文件的范例或信息,必须自行承担风险。在经由Internet连接到网络上时,可能会衍生许多安全性的议题。即使是您的讯息已经经过加密,但不正确的firewall设定仍然会导致安全上的裂缝。关于cipe connection您必须要特别小心谨慎,然而,仍然无法保障100%的安全。作者并不保证在本文件中所提供的信息同时也提供了一个安全的网络环境。

1.3. 使用回报

如果您有任何问题、建议、更正,或评论,欢迎您写信到 acj@home.net.

1.4. 本文件之最新版本

新版的文件将会发表到 cipe mailing list 并且email 给 Linux HOWTO coordinator 并且建档成 Linux HOWTO。

1.5 取得文件

本文件是针对 cipe 所写成的。您可以从 http://sites.inka.de/~bigred/sw/cipe-1.6.0.tar.gz取得文件文件。

2. 机器设定

2.1 Firewall 设定

本文件假设您的 kernel 已经设定成支持 IP masquerade 并且已经正常执行 firewall 相关设定。本文中并不解释如何去设定 masquerading firewall,而只介绍设定规则的范例,以说明在使用 masquerading firewall 时,如何让cipe能够正常运作。您可以在参考文件中找到如何设定 linux IP masquerade firewall.

2.2. The Star/Hub 设定

这个设定使用 star/hub 架构,因此如果 machine A 停止运作,那么machine B 和 C 将无法连线。您可以考虑在 machine B 和 C 之间增加一个 cipe connection 来解决这个问题。而当您将许多网络连结在一起的时候,就会开始变得有危机存在。本文件只介绍了 star/hub 设定的范例。

Machine A
eth0: 10.10.1.1
eth1: real ip 1
/
/
Machine B Machine C
eth0: 10.10.2.1 eth0:10.10.3.1
eth1: real ip 2 eth1: real ip 3

2.3. 名词参考

eth0 是 local network (fake address)
eth1 是 internet address (real address)

Port A 是任何您可以选择的有效通讯端口
Port B 是任何其余您可以选择的有效通讯端口

Key A 是任何您可以选择的有效 key (详情请阅读 cipe 文件)
Key B 是任何您可以选择的有效 key

2.4. Machine A 的设定

2.4a. /etc/cipe/ip-up

#a trimmed down version of the sample ip-up that comes with the
distribution
#!/bin/sh
umask 022
PATH=/sbin:/bin:/usr/sbin:/usr/bin
echo "UP $*" >> /tmp/cipe
echo $3 > /var/run/$1.pid
#笔者倾向於在设定 routing 时分成不同的文件来设,详述如下。

2.4b. /etc/cipe/options.machineB

#设备域名
device cip3b0
# the peers internal (fake) ip address
ptpaddr 10.10.2.1
# my cipe (fake) ip address
ipaddr 10.10.1.1
# my real ip address and cipe port
me (real ip 1):(port A)
# the peers ip address and cipe port
peer (real ip 2):(port A)
#128 比特的加密 key,应予以保密
key (Key A)

2.4c. /etc/cipe/options.machineC

#设备域名
device cip3b1
# the peers internal (fake) ip address
ptpaddr 10.10.3.1
# my cipe (fake) ip address
ipaddr 10.10.1.1
# my real ip address and cipe port
me (real ip 1):(port B)
# the peers ip address and cipe port
peer (real ip 3):(port B)
#128 比特的加密 key,应予以保密
key (Key B)

2.4d. /etc/cipe/setroute

#!/bin/sh
#设定 routing table 的文件
#设定 Machine B 的 routing table
/sbin/route add -host 10.10.2.1 dev cip3b0
/sbin/route add -net 10.10.2.0 netmask 255.255.255.0 gw 10.10.2.1
#设定 Machine C 的 routing table
/sbin/route add -host 10.10.3.1 dev cip3b1
/sbin/route add -net 10.10.3.0 netmask 255.255.255.0 gw 10.10.3.1

2.4e. /etc/rc.d/rc.local

echo Configuring VPN network
/usr/local/sbin/ciped -o /etc/cipe/options.machineB
/usr/local/sbin/ciped -o /etc/cipe/options.machineC
/etc/cipe/setroute

2.4f. Firewall 规则

#去除所有 incoming firewall 的规则,并将缺省值设为 deny
/sbin/ipfwadm -I -f
/sbin/ipfwadm -I -p deny
#允许所有新进的封包 (packets) 经由 cipe links 送至您的网络中
/sbin/ipfwadm -I -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
/sbin/ipfwadm -I -a accept -W cip3b1 -S 10.10.0.0/16 -D 10.10.0.0/16
#您可以再增加一些额外的封包进入规则

#去除所有 outgoing firewall 的规则,并将缺省值设为 deny
/sbin/ipfwadm -O -f
/sbin/ipfwadm -O -p deny
#允许所有送出的封包 (packets) 经由 cipe links 送至其它网络
/sbin/ipfwadm -O -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
/sbin/ipfwadm -O -a accept -W cip3b1 -S 10.10.0.0/16 -D 10.10.0.0/16
#您可以再增加一些额外的封包送出规则

#去除所有 forwarding firewall 的规则,并将缺省值设为 deny
/sbin/ipfwadm -F -f
/sbin/ipfwadm -F -p deny
#允许所有转送的封包 (packets) 经由 cipe links 送至其它网络
/sbin/ipfwadm -F -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
/sbin/ipfwadm -F -a accept -W cip3b1 -S 10.10.0.0/16 -D 10.10.0.0/16
#允许从这台机器的真实 ip forward 到其它机器的真实 ip
/sbin/ipfwadm -F -a accept -W eth1 -S (real ip 1) -D (real ip 2)
/sbin/ipfwadm -F -a accept -W eth1 -S (real ip 1) -D (real ip 3)
#允许经由 local interface (fake ip address) 转送到其它网络上
/sbin/ipfwadm -F -a accept -W eth0 -S 10.10.0.0/16 -D 10.10.0.0/16
#您可以再增加一些额外的封包转送规则

2.4g. 网关 (Gateway)

所有在 10.10.1.0 网络上的机器必须以 10.10.1.1 来当作网关,如果您不是如此设定,那么将无法正常运作。

2.5. Machine B 的设定

2.5a. /etc/cipe/ip-up

#a trimmed down version of the sample ip-up that comes with the
distribution
#!/bin/sh
umask 022
PATH=/sbin:/bin:/usr/sbin:/usr/bin
echo "UP $*" >> /tmp/cipe
echo $3 > /var/run/$1.pid
#笔者倾向於在设定 routing 时分成不同的文件来设,详述如下。

2.5b. /etc/cipe/options.machineA

#设备域名
device cip3b0
# the peers internal (fake) ip address
ptpaddr 10.10.1.1
# my cipe (fake) ip address
ipaddr 10.10.2.1
# my real ip address and cipe port
me (real ip 1):(port A)
# the peers ip address and cipe port
peer (real ip 2):(port A)
#128 比特的加密 key,应予以保密
key (Key A)

2.5c. /etc/cipe/setroute

#!/bin/sh
#设定 routing table 的文件
#设定 Machine A 的 routing table
/sbin/route add -host 10.10.1.1 dev cip3b0
/sbin/route add -net 10.10.1.0 netmask 255.255.255.0 gw 10.10.1.1

2.5d. /etc/rc.d/rc.local

echo Configuring VPN network
/usr/local/sbin/ciped -o /etc/cipe/options.machineA
/etc/cipe/setroute
2.5e. Firewall 规则

(以下请参照 2.4f 的注解说明)

#flush all incoming firewall rules and set default policy to deny
/sbin/ipfwadm -I -f
/sbin/ipfwadm -I -p deny
#allow incoming packets to your network via the cipe link
/sbin/ipfwadm -I -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
#add rest of your incoming rules here

#flush all outgoing firewall rules and set default policy to deny
/sbin/ipfwadm -O -f
/sbin/ipfwadm -O -p deny
#allow outgoing packets to your network via the cipe link
/sbin/ipfwadm -O -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
#add rest of your outgoing rules here

#flush all forwarding firewall rules and set default policy to deny
/sbin/ipfwadm -F -f
/sbin/ipfwadm -F -p deny
#allow packets to be forwarded to the other networks via the cipe
links
/sbin/ipfwadm -F -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
#allow forwarding from real ip of this machine to the real ip address
of the other machines
/sbin/ipfwadm -F -a accept -W eth1 -S (real ip 2) -D (real ip 1)
#allow packets to be forwarded to the other networks via the local
interface (fake ip address)
/sbin/ipfwadm -F -a accept -W eth0 -S 10.10.0.0/16 -D 10.10.0.0/16
#add rest of your forwarding rules here

2.5f. 网关

所有在 10.10.2.0 网络上的机器必须以 10.10.2.1 来当作网关,如果您不是如此设定,那么将无法正常运作。

2.6. Machine C 的设定

2.6a. /etc/cipe/ip-up

#a trimmed down version of the sample ip-up that comes with the
distribution
#!/bin/sh
umask 022
PATH=/sbin:/bin:/usr/sbin:/usr/bin
echo "UP $*" >> /tmp/cipe
echo $3 > /var/run/$1.pid
#笔者倾向於在设定 routing 时分成不同的文件来设,详述如下。

2.6b. /etc/cipe/options.machineA

#设备域名
device cip3b0
# the peers internal (fake) ip address
ptpaddr 10.10.1.1
# my cipe (fake) ip address
ipaddr 10.10.3.1
# my real ip address and cipe port
me (real ip 3):(port B)
# the peers ip address and cipe port
peer (real ip 1):(port B)
#128 比特的加密 key,应予以保密
key (Key B)

2.6c. /etc/cipe/setroute

#!/bin/sh
#设定 routing table 的文件
#设定 Machine A 的 routing table
/sbin/route add -host 10.10.1.1 dev cip3b0
/sbin/route add -net 10.10.1.0 netmask 255.255.255.0 gw 10.10.1.1

2.6d. /etc/rc.d/rc.local

echo Configuring VPN network
/usr/local/sbin/ciped -o /etc/cipe/options.machineA
/etc/cipe/setroute
2.6e. Firewall Rules

(以下请参照 2.4f 的注解说明)

#flush all incoming firewall rules and set default policy to deny
/sbin/ipfwadm -I -f
/sbin/ipfwadm -I -p deny
#allow incoming packets to your network via the cipe link
/sbin/ipfwadm -I -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
#add rest of your incoming rules here

#flush all outgoing firewall rules and set default policy to deny
/sbin/ipfwadm -O -f
/sbin/ipfwadm -O -p deny
#allow outgoing packets to your network via the cipe link
/sbin/ipfwadm -O -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
#add rest of your outgoing rules here

#flush all forwarding firewall rules and set default policy to deny
/sbin/ipfwadm -F -f
/sbin/ipfwadm -F -p deny
#allow packets to be forwarded to the other networks via the cipe
links
#this machine to the real ip address of the other machines
/sbin/ipfwadm -F -a accept -W cip3b0 -S 10.10.0.0/16 -D 10.10.0.0/16
#allow forwarding from real ip of this machine to the real ip address
of the other machine
/sbin/ipfwadm -F -a accept -W eth1 -S (real ip 3) -D (real ip 1)
#allow packets to be forwarded to the other networks via the local
interface (fake ip address)
/sbin/ipfwadm -F -a accept -W eth0 -S 10.10.0.0/16 -D 10.10.0.0/16
#add rest of your forwarding rules here

2.6f. 网关

所有在 10.10.3.0 网络上的机器必须以 10.10.3.1 来当作网关,如果您不是如此设定,那么将无法正常运作。

3. 启动

在每台机器上手动地执行被增加到 rc.local 的指令

4. 连接到 WAN.

设定到此为止,您的 WAN应该能够顺利连接。您可以试著去 ping其它网络上的机器。而下一个步骤,即是让您的网络能够以 SAMBA 来彼此互相存取。有一些小提示: lmhosts 或 wins server是必须的,特别是在 NT 底下。笔者已经实地设定成功过,但不打算在本篇文章中介绍这个部分。

5. 参考文件:

5.1. Web 网址

Cipe HomePage http://sites.inka.de/~bigred/devel/cipe.html
Masq Home Page http://ipmasq.home.ml.org
Samba Home Page http://samba.anu.edu.au
Linux HQ http://www.linuxhq.com --- 一个关于Linux信息的不错网站

5.2. 文件

cipe.info: 包含有关cipe软件套件信息的文件 Firewall HOWTO,由Mark Grennan 所著 IP Masquerade mini-HOWTO, 由Ambrose Au 所著

参考:

1. http://sites.inka.de/~bigred/sw/cipe-1.0.0.tar.gz
2. http://sites.inka.de/~bigred/devel/cipe.html
3. http://ipmasq.home.ml.org/
4. http://samba.anu.edu.au/
5. http://www.linuxhq.com/
6. http://www.unixsp.com/

了解更多详情,参与讨论,请进入GBUNIX论坛

http://www.gbunix.com/bbs/index.php
责任编辑: trotter

相关文章
Fedora core 2下建立支持MPPE/MPPC的PPTP VPN服务器 - 06-03 09:44 pm - 点击: 2439
架设Linux下最简单的VPN系统 - 12-28 11:34 pm - 点击: 797
Reahat 7.2 + PoPtoP 实现VPN一例 - 08-11 08:59 pm - 点击: 796
可加密VPN服务器的简单架设 - 08-10 05:19 pm - 点击: 711
利用openvpn+linux快速建立企业VPN - 07-09 12:02 am - 点击: 712
使用SSH建立基于Linux/Unix的VPN网络 - 07-08 11:26 pm - 点击: 1012
RedHat7.2实现免费的VPN - 07-02 11:19 pm - 点击: 1036

发表评论 查看评论 加入收藏 Email给朋友 打印本文
给该文章评分
1 2 3 4 5 6 7 8 9 10
平均得分 0, 共 0 人评分
1 2 3 4 5 6 7 8 9 10
发表评论
标题:
内容:
声明:本站资讯均来自互联网,所有文章版权归原作者和出版者所有,如涉及版权问题,请来信告知!
Copyright © 2002-2004 GBunix.com. All rights reserved.