论坛风格切换切换到宽版
  • 627阅读
  • 6回复

[问题求助]iptables 的疑惑 [复制链接]

上一主题 下一主题
离线ilxd.
 
发帖
2128
C币
-60197
威望
412
贡献值
1
银元
-1
铜钱
4904
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
iptables 中的fil.ter表中的forward、output链有点模糊,什么时.候该用forward链,什么时候该用output链?
网关服务器主要为局域网接入internet,主要用forward链。那.什么情况下要用到output链呢.?--- 印刷
那位大哥能帮忙用实例解释一下!!.(广告)

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

精彩

感动

搞笑

开心

愤怒

无聊

灌水
离线zskj.
发帖
2010
C币
-262954
威望
359
贡献值
1
银元
-4
铜钱
4414
人人网人气币
0
只看该作者 沙发  发表于: 2010-04-13
Re:iptables
到本机来的是INPUT
从本机出去的是OUTPUT
在本机内中转的是FORWARD

离线lun0412.
发帖
2057
C币
-132078
威望
382
贡献值
1
银元
-2
铜钱
4590
人人网人气币
0
只看该作者 板凳  发表于: 2010-04-13
Re:iptables
看一下我的FIREWALL吧,自认为是非常不错,非常安全,非常全面!
#! /bin/bash

modprobe ip_conntrack_ftp fxp=1

modprobe ip_nat_ftp

iptables -F -t filter

iptables -F -t nat

iptables -P INPUT ACCEPT

iptables -P OUTPUT ACCEPT

iptables -P FORWARD ACCEPT

iptables -t nat -P PREROUTING ACCEPT

iptables -t nat -P POSTROUTING ACCEPT

iptables -t nat -P OUTPUT ACCEPT



# ALLOW ALL in PRIVATE NET

iptables -A INPUT -i lo -j ACCEPT

iptables -A INPUT -i eth1 -j ACCEPT



# FTP

iptables -A INPUT -m limit --limit 100/s --limit-burst 5 -p tcp --dport 21 -j ACCEPT



# SSH & TELNET

iptables -A INPUT -p tcp --dport 22 -j ACCEPT



# MAIL

#iptables -A INPUT -p tcp --dport 25 -j ACCEPT



# VPN

#iptables -A INPUT -p tcp --dport 1723 -j ACCEPT

#iptables -A INPUT -p gre -j ACCEPT



# WWW

iptables -A INPUT -m limit --limit 100/s --limit-burst 5 -p tcp --dport 80 -j ACCEPT



# MYSQL

# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT



# SOCKS5

iptables -A INPUT -p tcp --dport 8039 -j ACCEPT



# ICMP(PING)

iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT

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



# NAT

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE



# DNAT SQL-SERVER & RADMIN to PRIVATE NET

iptables -A PREROUTING -t nat -p tcp -s ! 192.168.0.0/24 --dport 4899 -j DNAT --to 192.168.0.2:4899

iptables -A PREROUTING -t nat -p tcp -s ! 192.168.0.0/24 --dport 5000 -j DNAT --to 192.168.0.3:4899

iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp --dport 80 -j DNAT --to 192.168.0.1:3128



# DENY OTHERS

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -j MIRROR
复制代码

此防火墙是“反弹式”的,反弹所有黑客攻击的火墙里未匹配的东西(经测试效果不错,黑客就=黑自己)

离线yinghua568.
发帖
2106
C币
-193246
威望
397
贡献值
1
银元
-3
铜钱
4783
人人网人气币
0
只看该作者 地板  发表于: 2010-04-13
Re:iptables


QUOTE:原帖由 "platinum" 发表:

此防火墙是“反弹式”的,反弹所有黑客攻击的火墙里未匹配的东西(经测试效果不错,黑客就=黑自己)


没看到什么反弹的部分呀,请说明一下好吗

是不是iptables -A INPUT -j MIRROR这个

离线tks1000.
发帖
2165
C币
-234974
威望
412
贡献值
1
银元
-4
铜钱
4945
人人网人气币
0
只看该作者 4楼 发表于: 2010-04-13
Re:iptables


QUOTE:原帖由 "platinum" 发表:

代码:

#! /bin/bash
modprobe ip_conntrack_ftp fxp=1
modprobe ip_nat_ftp
iptables -F -t filter
iptables -F -t nat
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT

# ALLOW ALL in PRIVATE NET
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT

# FTP
iptables -A INPUT -m limit --limit 100/s --limit-burst 5 -p tcp --dport 21 -j ACCEPT

# SSH & TELNET
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# MAIL
#iptables -A INPUT -p tcp --dport 25 -j ACCEPT

# VPN
#iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
#iptables -A INPUT -p gre -j ACCEPT

# WWW
iptables -A INPUT -m limit --limit 100/s --limit-burst 5 -p tcp --dport 80 -j ACCEPT

# MYSQL
# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT

# SOCKS5
iptables -A INPUT -p tcp --dport 8039 -j ACCEPT

# ICMP(PING)
iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT
iptables -A INPUT -p icmp --icmp-type ! echo-request -j ACCEPT

# NAT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE

# DNAT SQL-SERVER & RADMIN to PRIVATE NET
iptables -A PREROUTING -t nat -p tcp -s ! 192.168.0.0/24 --dport 4899 -j DNAT --to 192.168.0.2:4899
iptables -A PREROUTING -t nat -p tcp -s ! 192.168.0.0/24 --dport 5000 -j DNAT --to 192.168.0.3:4899
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp --dport 80 -j DNAT --to 192.168.0.1:3128

# DENY OTHERS
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -j MIRROR  


这位兄台,我有几个疑问?
1、你防火墙默认策略是accept,而你的规则也是accept 。我记得策略是accept,规则一般为drop。默认策略是drop,规则一般为accept。
2、防火墙默认策略是accept,
# ALLOW ALL in PRIVATE NET
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
# MYSQL
# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
# SOCKS5
iptables -A INPUT -p tcp --dport 8039 -j ACCEPT
# VPN
#iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
# MYSQL
# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
# SOCKS5
iptables -A INPUT -p tcp --dport 8039 -j ACCEPT
如果不加的话,我想也能连接到本机的以上端口。
感觉不起作用诶。(或许我理解错了)
3、iptables -A INPUT -j MIRROR  没用过,不懂。

离线纸风铃.
发帖
2171
C币
-234920
威望
418
贡献值
1
银元
0
铜钱
4977
人人网人气币
0
只看该作者 5楼 发表于: 2010-04-13
Re:iptables
MIRROR
       This is an experimental demonstration target which inverts  the  source
       and destination fields in the IP header and retransmits the packet.  It
       is only valid in the INPUT, FORWARD and PREROUTING  chains, and  user-
       defined  chains which are only called from those chains.  Note that the
       outgoing packets are NOT seen by any packet filtering  chains,  connec-
       tion tracking or NAT, to avoid loops and other problems.

离线cylczzj.
发帖
2088
C币
-60539
威望
413
贡献值
1
银元
-4
铜钱
4850
人人网人气币
0
只看该作者 6楼 发表于: 2010-04-13
Re:iptables
如果不加的话,直接走到规则MIRROR,则所有访问都被反弹了
快速回复
限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
上一个 下一个