为什么我的iptables-save不能重定向???

king_boss
为什么我的iptables-save不能重定向???

1. 直接用iptables-save输出到标准输出:
[root@localhost sysconfig]# iptables-save
# Generated by iptables-save v1.3.8 on Tue Apr 22 03:43:06 2008
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2295:275554]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Apr 22 03:43:06 2008

2. 但是把它重定向到某个文件却发现文件是空的:
[root@localhost sysconfig]# iptables-save > 1.txt
[root@localhost sysconfig]# cat 1.txt
[root@localhost sysconfig]#
1.txt是空的!

请问这是为什么啊? 各位大侠帮忙了~~~~  

PS: 我的版本是F8, 跟发行版应该没什么关系吧?

platinum
如果确认 iptables-save 直接可以看到信息,那么用 iptables-save &>1.txt 试试呢?

king_boss
[quote]原帖由 [i]platinum[/i] 于 2008-4-21 23:04 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6563236&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]
如果确认 iptables-save 直接可以看到信息,那么用 iptables-save &>1.txt 试试呢? [/quote]

也不行哦
cat 1.txt 还是空的

jerrywjl
我估计你的iptables服务就没有开。你把服务先确认开启,然后再导出。

king_boss
[quote]原帖由 [i]jerrywjl[/i] 于 2008-4-22 10:00 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6563721&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]
我估计你的iptables服务就没有开。你把服务先确认开启,然后再导出。 [/quote]


重新启动:
[root@localhost ~]# chkconfig --list | grep iptables
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off


[root@localhost sysconfig]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
RH-Firewall-1-INPUT  all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain RH-Firewall-1-INPUT (1 references)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     esp  --  anywhere             anywhere            
ACCEPT     ah   --  anywhere             anywhere            
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:mdns
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited


这证明iptables服务是开的吧??


[root@localhost sysconfig]# pwd
/etc/sysconfig
[root@localhost sysconfig]# rm 1.txt
[root@localhost sysconfig]# iptables-save > 1.txt
[root@localhost sysconfig]# cat 1.txt
[root@localhost sysconfig]#
还是空 .......................

ssffzz1
1、你没有设置过特殊的系统变量吗?
2、是标准的LINUX安装吗?
3、有修改过IPTABLES-SAVE脚本吗?

4、命令本身没有问题,问题在系统。

king_boss
[quote]原帖由 [i]ssffzz1[/i] 于 2008-4-22 12:36 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6564082&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]
1、你没有设置过特殊的系统变量吗?
2、是标准的LINUX安装吗?
3、有修改过IPTABLES-SAVE脚本吗?

4、命令本身没有问题,问题在系统。 [/quote]



# ls > 1.txt
# cat 1.txt
app
command
ui
conf

这个说明我的重定向没问题吧!  是安装的F 8, 也没有修改过iptables-save这个脚本 ,iptables本来也是安装的标准配置,原本没有打开ftp 的端口
我加上脚本打开,想用iptables-save来保存,才发现F 8的iptables-save 有问题

我刚刚在我的suse10 上试过了, iptables-save > 1.txt完全可以

ssffzz1
那可能就是脚本的问题了.

platinum
99.9% 是由于某低级错误造成的

codekiller
很奇怪的问题, 建议从其它的机器上拷贝一个 iptables-save 脚本试试

jerrywjl
strace -o file iptables-save > 1.txt

看看file文件,这是在没有你环境测试下的最后方法。

suntoltti
麻烦把1.txt的路径写全,谢谢

king_boss
[quote]原帖由 [i]suntoltti[/i] 于 2008-4-23 09:36 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6565450&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]
麻烦把1.txt的路径写全,谢谢 [/quote]

晕! BASH的重定向不写全就表示重定向到当前路径的指定文件下:

# iptables-save > /1.txt
# cat /1.txt
#
也为空

XIII
# iptables-save 2> /1.txt
你试试这样看看

platinum
[quote]原帖由 [i]king_boss[/i] 于 2008-4-23 09:57 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6565481&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]


晕! BASH的重定向不写全就表示重定向到当前路径的指定文件下:

# iptables-save > /1.txt
# cat /1.txt
#
也为空 [/quote]
已经告诉过你了,先试试 iptables-save 有没有问题
你只试过 iptables -vnL,这和 iptables-save 是不一样的
既然你试过 ls > 1.txt 没问题则证明你的系统没问题,问题可能在 iptables-save 上
如果你 iptables-save 没问题,那么用 iptables-save &>/1.txt 试试
如果还不行,那么或许是 cat 的问题也说不定(bash),你试试 vi 能否打开
如果以上都排除了,那么就是你的人品问题了

king_boss
[quote]原帖由 [i]platinum[/i] 于 2008-4-23 10:25 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6565519&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]

已经告诉过你了,先试试 iptables-save 有没有问题
你只试过 iptables -vnL,这和 iptables-save 是不一样的
既然你试过 ls > 1.txt 没问题则证明你的系统没问题,问题可能在 iptables-save 上
如果你 ipt ... [/quote]

谢谢大家都好意,我昨晚在自家下了个f8-i386-dvd.iso,安装之后,默认配置,发现iptables-save也没有重定向
我在suse 10上是能的,  所以估计只能是f8这个发行版的iptables-save 的问题了

platinum
[quote]原帖由 [i]king_boss[/i] 于 2008-4-23 11:00 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6565599&ptid=994159][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]


谢谢大家都好意,我昨晚在自家下了个f8-i386-dvd.iso,安装之后,默认配置,发现iptables-save也没有重定向
我在suse 10上是能的,  所以估计只能是f8这个发行版的iptables-save 的问题了 [/quote]
未必

victorczk
这位兄才,我装了F9也碰到和你一样的问题,iptables-save定向出去为空。其实不然!

victorczk
Fedora的iptables是自动保存的,每次关机都会把iptables中的列表,包括nat列表都写入/etc/sysconfig/iptables中,重启也是直接自动恢复,所以不用担心。

daizhongxian
人品问题 :mrgreen: :mrgreen: