首页>
技术资讯>
详情

安全防线,由http暗藏通道看网络安全

2016-06-18 来源:CloudBest 阅读量: 105
关键词: 应用技术


  1.获取
  1.1. 本文件之最新版本
  
  新版的文件将会发表到 cipe mailing list 并且email 给 Linux HOWTO coordinator 并且建档成 Linux HOWTO。
  
  1.2取得文件
  
  本文件是针对 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 网络上

热门推荐 查看更多