[问题]ppp0的iptables规则,哪个更好点呢?

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
health_kxy
帖子: 30
注册时间: 2006-08-28 23:21

[问题]ppp0的iptables规则,哪个更好点呢?

#1

帖子 health_kxy » 2008-08-20 0:00

我一个机器直接ppp链接到internet.拒绝任何接入。网上查到两个设置办法
1)
iptables -P INPUT DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

2)
iptables -N block
iptables -A block -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A block -m state --state NEW -i ! ppp0 -j ACCEPT <--- 另外一个问题,why use ! ppp0
iptables -A block -j DROP
iptables -A INPUT -j block
iptables -A FORWARD -j block

这两种有什么不同,效果是否一样呢?哪个更好呢?

谢谢。
头像
str263
帖子: 56
注册时间: 2006-09-13 23:59

#2

帖子 str263 » 2008-08-23 1:38

第二个比较好!
use !ppp0是因为本机的有些服务是驻留在lo接口上,要让这些服务正常运行,必须能够在lo接口上发送或者接收syn包,这也是!ppp0接口可以接收NEW状态包原因。
chasye
帖子: 333
注册时间: 2007-05-13 15:20

#3

帖子 chasye » 2008-08-24 13:38

两个都不行,用用就知道了

试试这个啦

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT

#访问一般的网络服务
iptables -A INPUT -p tcp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT

#不用时间同步的可以不要
iptables -A INPUT -p udp -sport 123 -m state --state RELATED,ESTABLISHED -j ACCEPT

#Ping回显
iptables -A INPUT -p icmp -m state --state ESTABLISHED --icmp-type 0 -j ACCEPT

#不正常的数据包
iptables -A INPUT -m state --state INVALID -j DROP

#记录正常,但不但规则的数据包
iptables -A INPUT -j LOG --log-prefix "Unknown Package: "
health_kxy
帖子: 30
注册时间: 2006-08-28 23:21

#4

帖子 health_kxy » 2008-08-25 11:07

chasye 写了:两个都不行,用用就知道了

试试这个啦

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT

#访问一般的网络服务
iptables -A INPUT -p tcp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT

#不用时间同步的可以不要
iptables -A INPUT -p udp -sport 123 -m state --state RELATED,ESTABLISHED -j ACCEPT

#Ping回显
iptables -A INPUT -p icmp -m state --state ESTABLISHED --icmp-type 0 -j ACCEPT

#不正常的数据包
iptables -A INPUT -m state --state INVALID -j DROP

#记录正常,但不但规则的数据包
iptables -A INPUT -j LOG --log-prefix "Unknown Package: "
你的这个貌似只是开了1024这个端口。
health_kxy
帖子: 30
注册时间: 2006-08-28 23:21

#5

帖子 health_kxy » 2008-08-25 11:07

str263 写了:第二个比较好!
use !ppp0是因为本机的有些服务是驻留在lo接口上,要让这些服务正常运行,必须能够在lo接口上发送或者接收syn包,这也是!ppp0接口可以接收NEW状态包原因。
第二个好的原因是什么呢?
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

#6

帖子 oneleaf » 2008-08-25 11:44

如果你同时配置了vpn接入服务,将会出现ppp1,ppp2... 这样第一种就有问题了,第二种就不会。
chasye
帖子: 333
注册时间: 2007-05-13 15:20

#7

帖子 chasye » 2008-08-26 20:38

health_kxy 写了:
chasye 写了:两个都不行,用用就知道了

试试这个啦

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT

#访问一般的网络服务
iptables -A INPUT -p tcp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT

#不用时间同步的可以不要
iptables -A INPUT -p udp -sport 123 -m state --state RELATED,ESTABLISHED -j ACCEPT

#Ping回显
iptables -A INPUT -p icmp -m state --state ESTABLISHED --icmp-type 0 -j ACCEPT

#不正常的数据包
iptables -A INPUT -m state --state INVALID -j DROP

#记录正常,但不但规则的数据包
iptables -A INPUT -j LOG --log-prefix "Unknown Package: "
你的这个貌似只是开了1024这个端口。
你看不到1024后的“:”吗???
health_kxy
帖子: 30
注册时间: 2006-08-28 23:21

#8

帖子 health_kxy » 2008-08-27 16:43

chasye 写了:
health_kxy 写了:
chasye 写了:两个都不行,用用就知道了

试试这个啦

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT

#访问一般的网络服务
iptables -A INPUT -p tcp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT

#不用时间同步的可以不要
iptables -A INPUT -p udp -sport 123 -m state --state RELATED,ESTABLISHED -j ACCEPT

#Ping回显
iptables -A INPUT -p icmp -m state --state ESTABLISHED --icmp-type 0 -j ACCEPT

#不正常的数据包
iptables -A INPUT -m state --state INVALID -j DROP

#记录正常,但不但规则的数据包
iptables -A INPUT -j LOG --log-prefix "Unknown Package: "
你的这个貌似只是开了1024这个端口。
你看不到1024后的“:”吗???
ok,那低于1024的端口呢?
health_kxy
帖子: 30
注册时间: 2006-08-28 23:21

#9

帖子 health_kxy » 2008-08-27 17:11

chasye 写了:两个都不行,用用就知道了

试试这个啦

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT

#访问一般的网络服务
iptables -A INPUT -p tcp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT

#不用时间同步的可以不要
iptables -A INPUT -p udp -sport 123 -m state --state RELATED,ESTABLISHED -j ACCEPT

#Ping回显
iptables -A INPUT -p icmp -m state --state ESTABLISHED --icmp-type 0 -j ACCEPT

#不正常的数据包
iptables -A INPUT -m state --state INVALID -j DROP

#记录正常,但不但规则的数据包
iptables -A INPUT -j LOG --log-prefix "Unknown Package: "
你用过吗?自己试验过吗???
chasye
帖子: 333
注册时间: 2007-05-13 15:20

#10

帖子 chasye » 2008-08-27 18:24

health_kxy 写了:
chasye 写了:两个都不行,用用就知道了

试试这个啦

iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT

#访问一般的网络服务
iptables -A INPUT -p tcp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT

#不用时间同步的可以不要
iptables -A INPUT -p udp -sport 123 -m state --state RELATED,ESTABLISHED -j ACCEPT

#Ping回显
iptables -A INPUT -p icmp -m state --state ESTABLISHED --icmp-type 0 -j ACCEPT

#不正常的数据包
iptables -A INPUT -m state --state INVALID -j DROP

#记录正常,但不但规则的数据包
iptables -A INPUT -j LOG --log-prefix "Unknown Package: "
你用过吗?自己试验过吗???
我用那个和这个不同~~~不过这个基本是按你的要求写的, 你试试一试就知道了,不过不知道有没有打错字
1024以下是保留的,不开服务器一般都不同~~~盾你的情况应该是用不到的
回复