[SOLVED] Output redirection doesn't work with iptables (Fedora Core 11)
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Output redirection doesn't work with iptables (Fedora Core 11)
Well, as I'm a newbie I don't understand this behavior:
I have an old box, with Fedora 11 successfully installed. I'm currently trying to work with iptables. Some info:
I think I'm missing some simple configuration parameter, but I don't know what could it be.
Sorry for my English is not so well, I do the best I can.
Thanks everybody in advance.
Well, as I'm a newbie I don't understand this behavior:
I have an old box, with Fedora 11 successfully installed. I'm currently trying to work with iptables. Some info:
I think I'm missing some simple configuration parameter, but I don't know what could it be.
Sorry for my English is not so well, I do the best I can.
Thanks everybody in advance.
Does the rules list print to the screen if you do this:
Does the rules list print to the screen if you do this:
Code:
# iptables -L
If so, then this should also work:
Code:
# iptables -L > dump.txt
I just tested it.
Yes, sorry if I didn't let that clear. That's precisely the problem: screen output works. I'm not gonna type all output, but it is just like a normal "iptables -L" one:
# iptables -L Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED, ESTABLISHED
ACCEPT icmp -- anywhere anywhere
[...]
An so on, listing of course FORWARD and OUTPUT chains, etc.
I tried also changing output file destination directory and name (even using "dump.txt"), and still doesn't work.
I know it seems hard to believe...
Thanks, but sometimes it's hard to explain the nature of the problem.
I know that command exists (it's iptables-save, in fact, and it works), but i am not looking for an alternative way to do this. I wish to save the exact output of iptables -L, or at least to know why it isn't working by this way. Let's say that the following questions are related:
Why it isn't working? Why did it work in Lenny? Do you think it's related to iptables set itself, or there's something I'm missing about redirection mechanism?
The background of this is that I did have other strange problems with F11 command-line standard commands (like cp), and I need to distinguish between distro serious problems and my ignorance .
Thanks, but sometimes it's hard to explain the nature of the problem.
I know that command exists (it's iptables-save, in fact, and it works), but i am not looking for an alternative way to do this. I wish to save the exact output of iptables -L, or at least to know why it isn't working by this way. Let's say that the following questions are related:
Why it isn't working? Why did it work in Lenny? Do you think it's related to iptables set itself, or there's something I'm missing about redirection mechanism?
The background of this is that I did have other strange problems with F11 command-line standard commands (like cp), and I need to distinguish between distro serious problems and my ignorance .
Have you tried:
Code:
# iptables -L > output.txt 2>&1
Quote:
Originally Posted by andrei.wap
Thanks, but sometimes it's hard to explain the nature of the problem.
More words specifically related to the problem, and fewer words of background, would help.
Yes, no errors were listed. It created again an empty file called output.txt
I finally did:
Code:
iptables -L | grep '' > output.txt
It worked, and I got the output, but I'm still wondering why the original redirection doesn't work.
Quote:
Originally Posted by lutusp
More words specifically related to the problem, and fewer words of background, would help.
I was just trying that nice people like Chrism01 doesn't waste his/her time, because I'm focused in "iptables -L" output, and I'm curious about redirection behavior.
Not so much to say about the problem itself. I tried overwriting an existing file, adding options to the command (i.e, iptables -L -n, iptables -L -v), adding output to the file (i.e., using ">>"), and reading iptables and bash documentation.
If you don't have patience for beginners, maybe you shouldn't answer his questions.
Thanks anyway.
This is a really old thread, but Google sent me here and as there was no posted solution, I figured I'd update with my fix. I'm running RHEL 6 and temporarily disabling selinux solved the issue for me. Command to do that is "echo 0 > /selinux/enforce". To change back, "echo 1 > /selinux/enforce".
To summarize, the regular "iptables -L" and "iptables-save" commands produce the expected result. If I try to redirect that output to a file, however, no output is written to the file. Here's a demonstration:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.