找回密码
 注册
查看: 626|回复: 6

一个IPTABLES 的问题请各位帮忙看看如何解决

[复制链接]
发表于 2004-7-9 00:27:21 | 显示全部楼层 |阅读模式
下面这个是我的防火墙脚本请大家指正。。。。因为我的用了该脚本后在局域内访问其它的外网的FTP服务。。很慢。。。其它正常。。请他们帮忙看看该如何加些什么?//

#!/bin/sh

# Diable forwarding
echo 0 > /proc/sys/net/ipv4/ip_forward

LAN_IP_NET="192.168.0.1/24"
LAN_NIC="eth1"
WAN_IP="61.93.222.78"
WAN_NIC="eth0"

# load some modules (if needed)
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe ipt_LOG
# Flush
iptables -t nat -F POSTROUTING
iptables -t nat -F PREROUTING
iptables -t nat -F OUTPUT
iptables -F

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

# enable Masquerade and forwarding
iptables -t nat -A POSTROUTING -s $LAN_IP_NET -j MASQUERADE
iptables -A FORWARD -j ACCEPT -i $LAN_NIC -s $LAN_IP_NET
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

# Open ports on router for server/services
iptables -A INPUT -j ACCEPT -p tcp --dport 22
iptables -A INPUT -j ACCEPT -p tcp --dport 21

# STATE RELATED for router
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Enable forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward

# Define packets from Internet server to Intranet
/sbin/iptables -A FORWARD -p tcp -d 198.168.0.0/24 ! --syn -i eth0 -j ACCEPT
/sbin/iptables -A FORWARD -p udp -d 198.168.0.0/24 -i eth0 -j ACCEPT

# Define packets from Intranet to Internet
/sbin/iptables -A FORWARD -s 198.168.0.0/24 -i eth1 -j ACCEPT

# Define fregment rule
/sbin/iptables -A FORWARD -f -m limit --limit 100/s --limit-burst 100 -j ACCEPT

# Define icmp rule
/sbin/iptables -A FORWARD -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
# Enable forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
其它的都没问题 就是在局域网内访外部的
FTP服务时反应慢。。。。。要响应很久是不是不要加些什么??//

局域网内部的架设的FTP服务反应正常。
发表于 2004-7-9 09:10:37 | 显示全部楼层
还在看中途先提醒一下和我一样用 ssh/telnet 远程登陆的朋友,不要直接照着上面:
[code:1]iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT [/code:1]

我已经吃鳖了。。。。-_-b
回复

使用道具 举报

发表于 2004-7-10 10:06:46 | 显示全部楼层
在最后加一句

/sbin/iptables -A INPUT -p tcp --dport 113 -j REJECT --reject-with tcp-reset
回复

使用道具 举报

发表于 2004-7-14 12:04:51 | 显示全部楼层
是不是MTU的问题?
TCPMSS
       This target allows to alter the MSS value of TCP SYN packets,  to  con-
       trol  the maximum size for that connection (usually limiting it to your
       outgoing interface's MTU minus 40).  Of course, it can only be used  in
       conjunction with -p tcp.
       This  target  is  used to overcome criminally braindead ISPs or servers
       which block ICMP Fragmentation Needed packets.  The  symptoms  of  this
       problem are that everything works fine from your Linux firewall/router,
       but machines behind it can never exchange large packets:
        1) Web browsers connect, then hang with no data received.
        2) Small mail works fine, but large emails hang.
        3) ssh works fine, but scp hangs after initial handshaking.
       Workaround: activate this option and add a rule to your  firewall  con-
       figuration like:
        iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \
                    -j TCPMSS --clamp-mss-to-pmtu
回复

使用道具 举报

发表于 2004-7-14 12:08:17 | 显示全部楼层
[quote:cabd33f788="Kuye"]还在看中途先提醒一下和我一样用 ssh/telnet 远程登陆的朋友,不要直接照着上面:
[code:1]iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT [/code:1]

我已经吃鳖了。。。。-_-b[/quote]

我的完全是
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
都没有问题哦。
Kuye,你的图像怎么变成了MM呢?哈哈,近来在泡MM吧?
回复

使用道具 举报

发表于 2004-7-14 14:45:22 | 显示全部楼层
我猜可能是 DNS 的问题,书上有写,FTP 和 mail ... 猜的,仅供参考。 -_-b

to pk: 我在服务器上把 INPUT 全部 DROP 后偶的 ssh 就直接断了,害我跑得老远重启服务器。。。-_-b
嘿嘿,MM 没泡,泡没 MM。总之一句话就是最近心情不错  
MM 是范冰冰~
回复

使用道具 举报

发表于 2004-7-15 07:19:56 | 显示全部楼层
如果要用到nat的Masquerading的话,动态ip最好还是用SNAT较好,这样客户机的网卡不容易丢包;动态ip就用MASQUERADE。DNS也有可能:-)


偶也跑ssh的哦。不过,如果策略都是DROP的,
一般接下来的两句就是
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT


##ssh
iptables -A INPUT -s $Lan_Net -i eth1 -m mac --mac-source $MAC -p tcp --dport ssh -j ACCEPT
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-13 01:05 , Processed in 0.020648 second(s), 15 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表