兄弟们帮我修改一下iptables的设置

由 lyl2001 在 03-24-2004 14:42 发表:

兄弟们帮我修改一下iptables的设置

#!/bin/sh

#清空防火墙

iptables -F

iptables -F -t nat

iptables -P INPUT ACCEPT

iptables -P FORWARD DROP

iptables -P OUTPUT ACCEPT

echo '1' > /proc/sys/net/ipv4/ip_forward

echo '1' > /proc/sys/net/ipv4/conf/eth0/forwarding

echo '1' > /proc/sys/net/ipv4/conf/eth1/forwarding

echo "8192" > /proc/sys/net/ipv4/ip_conntrack_max

iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT

iptables -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -t nat -A PREROUTING -p tcp -s 192.168.1.0/24 --dport 80 -j REDIRECT --to-port 3128

iptables -t nat -s 192.168.1.0/24 -A POSTROUTING -o eth0 -j MASQUERADE

各位兄弟帮我完善一下上面iptables的设置。主要功能实现内网能够收发邮件并能通过squid上网。


由 尘飞扬 在 03-24-2004 15:07 发表:


iptables -t nat -s 192.168.1.0/24 -A POSTROUTING -o eth0 -j MASQUERADE

网络环境没有交待清楚:

你有固定ip么?要不你的出口是eth0?如果有固定ip这里不要用MASQUERADE,改为SNAT。如果不是固定ip你拔号上网的话需要用ppp0.


清风徐来尘飞扬


由 lyl2001 在 03-25-2004 08:10 发表:


我有两块网卡

eth0对外有固定ip a.b.c.d

eth1对内ip是192.168.1.1

是不是把

iptables -t nat -s 192.168.1.0/24 -A POSTROUTING -o eth0 -j MASQUERADE

改为

iptables -t nat -s 192.168.1.0/24 -A POSTROUTING -o eth0 -j SNAT --to a.b.c.d


由 尘飞扬 在 03-25-2004 08:40 发表:


是的,不过习惯上好像都是这样写的:

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to a.b.c.d


清风徐来尘飞扬


由 lyl2001 在 03-25-2004 08:55 发表:


谢谢飞扬兄

还有我想封掉qq该怎样写


由 lyl2001 在 03-25-2004 09:08 发表:


还有我想把 iptables -P INPUT ACCEPT改为iptables -P INPUT DROP就上不了网了


由 尘飞扬 在 03-25-2004 09:12 发表:


http://bbs.chinaunix.net/forum/view...;highlight=封QQ

看看这个,其实关于iptables规则及应用,在论坛里有很多资料,可以先搜来看看。


清风徐来尘飞扬


由 尘飞扬 在 03-25-2004 09:14 发表:


> quote: > > * * * > > 最初由 lyl2001 发表
>
> 还有我想把 iptables -P INPUT ACCEPT改为iptables -P INPUT DROP就上不了网了 > > * * *

你都drop了,还上什么网。


清风徐来尘飞扬


由 Bomber 在 03-25-20

Published At
Categories with 服务器类
Tagged with
comments powered by Disqus