Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33696
  • 博文数量: 7
  • 博客积分: 459
  • 博客等级: 下士
  • 技术积分: 65
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-16 23:38
文章分类
文章存档

2010年(7)

分类: LINUX

2010-11-10 19:07:16

  • 系统环境
    • Redflag DC5 or Redhat AS4
  • 系统服务
    • sshd, mysql, apache, vsftpd, 其中sshd, apache, vsftp 端口必须打开
  • 目标
    • 屏蔽除sshd, apache, vsftp 之外的所有连接,但是服务器可以自由连接外网
  • iptables 规则配置
      iptables -F # 清除现有规则
      iptables -P INPUT DROP   # 更改 INPUT POLICY 为DROP
      iptables -P FORWARD DROP # 更改 FORWARD POLICY 为DROP
      iptables -A INPUT -i lo -j ACCEPT # 开放lo
      iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT # 允许 icmp 回显消息
      iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  #允许已建立连接的包直接通过,即可以自由连接外网
      iptables -A INPUT -p tcp --dport 22 -j ACCEPT # 允许ssh 端口
      iptables -A INPUT -p tcp --dport 80 -j ACCEPT # 允许apache httpd 端口
      iptables -A INPUT -p tcp --dport 21 -j ACCEPT # 允许ftp 端口
      iptables -A INPUT -p tcp --dport 20 -j ACCEPT # 允许ftp 数据传输端口
      iptables -A INPUT -p tcp --dport 30000:50000 -j ACCEPT # 允许passive ftp 数据传输
    
  • 规则保存
    • 执行完上述命令之后,执行:
        service iptables save # 保存规则
        chkconfig iptables on # 开机自启动防火墙
      
阅读(1396) | 评论(0) | 转发(0) |
0

上一篇:利用ssh 实现rsync 远程备份

下一篇:没有了

给主人留下些什么吧!~~