频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

五个顶级Linux安全工具

来源: 作者:佚名 出处:巧巧读书 2008-03-20 进入讨论组
上一页 1 2 3 4 5 6 下一页 

精华网络内容 :http://www.qqread.com/network/

 
  5、Iptables
 
  iptables是一款状态防火墙几乎集成到所有Linux发行版中了,这就意味着你可以使用它基于ip地址的规则来控制远程机器访问你的服务器,以及连接请求的类型。(旧的无状态的防火墙让你只能根据数据包的内容来做出判断,因此你被端口号限制,不能跟踪会话的存在,如FTP数据流),Debian用户可以通过apt-get install iptables conntrack来获取它。
 
  当你从终端登陆到机器上时请完成你的初始化测试,用一个错误的规则将你自己锁在外面,然后你亲自恢复,当所有数据包被允许通过,因此这如果不被接受,观察iptables-save和iptables-restore命令,这里有一个加上注释的例子脚本,它非常基础,但是基本上它可以告诉你iptables是如何工作的:
 
  

 #!/bin/bash
# example iptables script
# flush the old rules
iptables -F
# set the default policy of the chain to accept
iptables -P INPUT ACCEPT
# create a new table for logging and discarding
# unwanted packets
iptables -N LOGDROP
# use rate limiting on the logging, and
# add a prefix of 'filter: '
iptables -A LOGDROP -m limit -j LOG
?--log-prefix "filter: "
# drop unwanted TCP connections with a
# TCP ReSeT packet
iptables -A LOGDROP -p tcp -j REJECT
?--reject-with tcp-reset
# drop other packets by sending an ICMP
# port unreachable in response
iptables -A LOGDROP -j REJECT
?--reject-with icmp-port-unreachable
# now drop the packet
iptables -A LOGDROP -j DROP
#allow anything on the local interface
iptables -A INPUT -i lo -j RETURN
# allow packets that are related to
# an on-going conversation
iptables -A INPUT -p tcp -m conntrack
?--ctstate RELATED,ESTABLISHED -j
RETURN
iptables -A INPUT -p udp -m conntrack
?--ctstate RELATED,ESTABLISHED -j
RETURN
# allow SSH traffic
iptables -A INPUT -p tcp -m tcp
?--dport 22 -j RETURN
# allow HTTP and HTTPS traffic
iptables -A INPUT -p tcp -m tcp
?--dport 443 -j RETURN
iptables -A INPUT -p tcp -m tcp
?--dport 80 -j RETURN
# accept the following ICMP types -
# echo, echo reply, source quench,
ttl exceeded,
# destination unreachable - and drop the rest
iptables -A INPUT -p icmp -m icmp
?--icmp-type 0 -j RETURN
iptables -A INPUT -p icmp -m icmp
?--icmp-type 3 -j RETURN
iptables -A INPUT -p icmp -m icmp
?--icmp-type 4 -j RETURN
iptables -A INPUT -p icmp -m icmp
?--icmp-type 8 -j RETURN
iptables -A INPUT -p icmp -m icmp
?--icmp-type 11 -j RETURN
# if we haven't accepted it, drop and log it.
iptables -A INPUT -j LOGDROP

 
  如果你正在疑惑日志在哪里,象什么样子,这里有一个例子,来自系统日志/var/log/messages,一个来自192.168.50.40的UDP数据包,源端口30766,目标服务器是192.168.0.8,目标端口是1026,这个数据包被丢掉了,它可能是windows机器上了信使服务发出的垃圾信息:
 
  
 Nov 22 06:24:00 localhost kernel: filter: IN=eth0
OUT=MAC=00:0a:e6:4e:6d:49:00:14:6c:67:cc:9a:08:00
SRC=192.168.50.40 DST=192.168.0.8 LEN=402
TOS=0x00 PREC=0x00 TTL=47 ID=3345 PROTO=UDP
SPT=30766 DPT=1026 LEN=382


 
  日志输出看起来有点恐怖,但是你能容易地拣出你想要的信息,首先,你看到的是日期和主机名,IN和OUT描述了数据包是来自哪个端口和通过哪个端口出去的,MAC给出了源和目标MAC地址,SRC和DST是源和目标ip地址,PROTO是UDP,TCP,ICMP等等,SPT和DPT是源和目标端口号,例如:大部分到服务的连接如ssh都有一个临时的源端口,如35214,和一个目标端口22,那么象前面说道的windows机器的信使服务数据包,你可以安全地忽略它。
 
  当你安装号防火墙后,务必再从另外一台机器上运行一次nmap,来检查是否只打开了正确的端口。

更多文章 更多内容请看路由安全配置专题系统安全设置配置安全的操作系统专题,或进入讨论组讨论。
上一页 1 2 3 4 5 6 下一页 
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
讨论组问题推荐
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章