免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2628 | 回复: 10
打印 上一主题 下一主题

[系统安全] iptables 难题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-04-12 15:24 |只看该作者 |倒序浏览
本帖最后由 435095562 于 2013-04-12 15:48 编辑

在服务器使用iptables设置防火墙功能,只允许用户访问这台服务器的WWW服务,而服务器只能被动地接受连接请求,不能主动的发起连接。

这个怎么做?

急急急

论坛徽章:
0
2 [报告]
发表于 2013-04-13 12:30 |只看该作者
本帖最后由 inpool 于 2013-04-13 12:31 编辑

没写过iptables规则,试试这个,xxx换成真实的IP地址
  1. iptables -A INPUT -d xxx.xxx.xxx.xxx -p tcp --dport 80 -j ACCEPT
  2. iptables -A OUTPUT -s xxxx.xxxx.xxxx.xxxx -j DROP
复制代码

论坛徽章:
0
3 [报告]
发表于 2013-04-14 15:28 |只看该作者
谢谢! 还是不行

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:29:07CU大牛徽章
日期:2013-03-13 15:29:49CU大牛徽章
日期:2013-03-13 15:30:192015年迎新春徽章
日期:2015-03-04 09:57:09
4 [报告]
发表于 2013-04-14 19:15 |只看该作者
建议楼主使用图形话的配置工具,点点鼠标就OK啦。

论坛徽章:
0
5 [报告]
发表于 2013-04-15 14:16 |只看该作者
http服务还有主动连接和被动连接之分?我out了

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2013-04-15 15:03 |只看该作者
你说的主动连接是什么意思?http服务的运行方式是http服务一直在运行,有客户端请求时,http服务器将请求的数据发给客户端,htpp服务区不会直接去连接客户端的.

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
7 [报告]
发表于 2013-04-15 15:13 |只看该作者
试试
  1. iptables -P INPUT DROP
  2. iptables -P OUTPUT DROP
  3. iptables -A INPUT -d xxx.xxx.xxx.xxx -p tcp --dport 80 -j ACCEPT
  4. iptables -A OUTPUT -m  state --state RELATED,ESTABLISHED -j ACCEPT
复制代码

论坛徽章:
0
8 [报告]
发表于 2013-04-15 15:19 |只看该作者
开放80口,其他用不到的端口drop,这样不就行了。控制服务器向外的通信没必要也没意义。

#!/bin/bash
# The config create for EzLinux Base
# About new info please to http://system.aidns.cn

export PATH=/sbin:/usr/sbin:/bin:/usr/bin

iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X

## Enable local interface pass
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

##Allow forwarding
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

## To our web_server
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

## Enable sshd_server
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

## icmp
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

## Anything else not allowed
iptables -A INPUT -j DROP


论坛徽章:
0
9 [报告]
发表于 2013-04-15 17:12 |只看该作者
弄好了
iptables -F
iptables -X
iptables -Z
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

论坛徽章:
21
白羊座
日期:2013-08-23 15:49:17金牛座
日期:2013-10-08 17:00:03处女座
日期:2013-10-12 11:54:11CU十二周年纪念徽章
日期:2013-10-24 15:41:34午马
日期:2013-11-27 14:07:21巨蟹座
日期:2013-12-04 10:56:03水瓶座
日期:2013-12-04 15:58:00亥猪
日期:2014-05-24 16:02:3115-16赛季CBA联赛之辽宁
日期:2016-11-07 13:52:53戌狗
日期:2013-08-23 16:15:31白羊座
日期:2013-08-24 21:59:24巨蟹座
日期:2013-08-25 16:34:24
10 [报告]
发表于 2013-04-15 17:55 |只看该作者
基于状态的防火墙。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP