- 论坛徽章:
- 0
|
/sbin/iptables -A FORWARD -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -i eth2 -m state --state ESTABLISHED,RELATED -j ACCEPT
以上两句有何用途?
虽然我自己也搞了个IPTABLES的防火墙,但对IPTABLES的精髓还不了解。我自己做的那个防火墙有个比较奇怪的现象,就是向外网转发时不时中断……大概6~8个包又自动恢复正常了。情况就象下面这样:
C:\>ping www.21cn.com -t
Pinging www.cdn.21cn.com [61.140.60.90] with 32 bytes o
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=18ms TTL=241
Reply from 61.140.60.90: bytes=32 time=17ms TTL=241
Reply from 61.140.60.90: bytes=32 time=17ms TTL=241
Request timed out.
Reply from 61.140.60.90: bytes=32 time=9ms TTL=241
Reply from 61.140.60.90: bytes=32 time=30ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=23ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=9ms TTL=241
Reply from 61.140.60.90: bytes=32 time=9ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=9ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=18ms TTL=241
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=18ms TTL=241
Reply from 61.140.60.90: bytes=32 time=19ms TTL=241
Request timed out.
Reply from 61.140.60.90: bytes=32 time=24ms TTL=241
Reply from 61.140.60.90: bytes=32 time=21ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=16ms TTL=241
Reply from 61.140.60.90: bytes=32 time=19ms TTL=241
Reply from 61.140.60.90: bytes=32 time=17ms TTL=241
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=9ms TTL=241
Reply from 61.140.60.90: bytes=32 time=20ms TTL=241
Reply from 61.140.60.90: bytes=32 time=19ms TTL=241
Reply from 61.140.60.90: bytes=32 time=20ms TTL=241
Reply from 61.140.60.90: bytes=32 time=18ms TTL=241
Request timed out.
Request timed out.
Reply from 61.140.60.90: bytes=32 time=11ms TTL=241
Reply from 61.140.60.90: bytes=32 time=13ms TTL=241
Reply from 61.140.60.90: bytes=32 time=9ms TTL=241
Reply from 61.140.60.90: bytes=32 time=23ms TTL=241
Reply from 61.140.60.90: bytes=32 time=26ms TTL=241
Reply from 61.140.60.90: bytes=32 time=13ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=15ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Reply from 61.140.60.90: bytes=32 time=10ms TTL=241
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 61.140.60.90: bytes=32 time=23ms TTL=241
Reply from 61.140.60.90: bytes=32 time=28ms TTL=241
Request timed out.
Request timed out.
请问是配置有问题吗?以下是配置(基于安全考虑,把地址用x.x.x.x代替):
#!/bin/sh
echo "1" >/proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -A POSTROUTING -o eth1 -s x.x.x.x -j SNAT --to-source x.x.x.x
iptables -t nat -A POSTROUTING -o eth1 -m iprange --src-range x.x.x.x-x.x.x.x-j SNAT --to-source x.x.x.x
iptables -A FORWARD -m iprange --src-range x.x.x.x-x.x.x.x -m ipp2p --edk --kazaa --bit -j DROP
iptables -A FORWARD -p tcp -m iprange --src-range x.x.x.x-x.x.x.x -m ipp2p --ares -j DROP
iptables -A FORWARD -p udp -m iprange --src-range x.x.x.x-x.x.x.x -m ipp2p --kazaa -j DROP
[ 本帖最后由 welldrong 于 2006-6-13 16:13 编辑 ] |
|