论坛风格切换切换到宽版
  • 574阅读
  • 8回复

[问题求助]求www的iptables实例 [复制链接]

上一主题 下一主题
离线yy12345678.
 
发帖
1953
C币
-61089
威望
319
贡献值
1
银元
-5
铜钱
4298
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
我想找一个iptables实例,是www服务器的,对ip1和.ip2两个ip开.放ssh服务            杀毒

评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
离线neverbye.
发帖
2058
C币
-60785
威望
381
贡献值
1
银元
0
铜钱
4567
人人网人气币
0
只看该作者 沙发  发表于: 2010-04-13
谁好心帮我啊

离线tommytino.
发帖
2080
C币
-198682
威望
371
贡献值
1
银元
0
铜钱
4552
人人网人气币
0
只看该作者 板凳  发表于: 2010-04-13
去找一下 iptables 的 script 吧, 本版有很多呀!
iptables -A INPUT -s ip1/32 --dport 22 -j ACCEPT
iptables -A INPUT -s ip2/32 --dport 22 -j ACCEPT

发帖
2065
C币
-235577
威望
384
贡献值
1
银元
-1
铜钱
4528
人人网人气币
0
只看该作者 地板  发表于: 2010-04-13
#!/bin/bash
# llzqq, 02/28/2004

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

modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe ipt_limit

echo 1 >;/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 >;/proc/sys/net/ipv4/conf/all/accept_source_route
echo 0 >;/proc/sys/net/ipv4/conf/all/accept_redirects
echo 1 >;/proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 1 >;/proc/sys/net/ipv4/conf/all/log_martians
echo 1 >;/proc/sys/net/ipv4/tcp_syncookies
iptables -F
iptables -X
iptables -Z


## Loopback - Allow unlimited traffic
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

## SYN-Flooding Protection
iptables -N syn-flood
iptables -A INPUT -i ppp0 -p tcp --syn -j syn-flood
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j RETURN
iptables -A syn-flood -j DROP

## Make sure that new TCP connections are SYN packets
iptables -A INPUT -i eth0 -p tcp ! --syn -m state --state NEW -j DROP


## HTTP
iptables -A INPUT -i ppp0 -p tcp -s 0/0 --sport 80 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -s 0/0 --sport 443 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -d 0/0 --dport 80 -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -d 0/0 --dport 443 -j ACCEPT

## DNS
iptables -A INPUT -i ppp0 -p udp -s 0/0 --sport 53 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -d 0/0 --dport 53 -j ACCEPT

## IP packets limit
iptables -A INPUT -f -m limit --limit 100/s --limit-burst 100 -j ACCEPT
iptables -A INPUT -i eth0 -p icmp -j DROP


## SSH
iptables -A INPUT -p tcp -s ip1/32 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -s ip2/32 --dport 22 -j ACCEPT


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

离线妖童.
发帖
2015
C币
-235496
威望
383
贡献值
1
银元
-2
铜钱
4444
人人网人气币
0
只看该作者 4楼 发表于: 2010-04-13
以下是它自己生成的在/etc/sysconfig/iptables下的文件

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0]
:FORWARD ACCEPT [0]
:OUTPUT ACCEPT [0]
:RH-Firewall-1-INPUT - [0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
#-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

我把-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
这行去掉还是可以ping的通,这个icmp不是于ping密切相关的吗?
为什么我没开ssh的22端口却还是可以登陆呢?
我用super scan扫描一下看到开了32768这个端口,这个是干什么用的。是怎么回事呢
下面是我netstat -an看到的
udp        0      0 0.0.0.0:32768           0.0.0.0:*

离线taimushan.
发帖
2270
C币
-60211
威望
434
贡献值
1
银元
-3
铜钱
5074
人人网人气币
0
只看该作者 5楼 发表于: 2010-04-13
service iptables status 看看先.

离线sk19880221.
发帖
2128
C币
-152225
威望
402
贡献值
1
银元
-3
铜钱
4827
人人网人气币
0
只看该作者 6楼 发表于: 2010-04-13
Table: filter
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

服务是起来的呀,开机我也看到了,这个我看过,有什么不对吗?

离线evasyy.
发帖
2023
C币
-60854
威望
372
贡献值
1
银元
0
铜钱
4499
人人网人气币
0
只看该作者 7楼 发表于: 2010-04-13
兄弟,  第一句就是 accept all any any ,  别的当然都不管用了呀!

离线sinxyz.
发帖
2007
C币
-60545
威望
390
贡献值
1
银元
0
铜钱
4476
人人网人气币
0
只看该作者 8楼 发表于: 2010-04-13
08C,你说的还不对,他前2条都是这个东西
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
上一个 下一个