Find the answer to your Linux question:
Results 1 to 9 of 9
Hello chaps, I need to avoid as much as possible buying a router, so i read about, and come across this lovely program...iptables* So, I follow the procedure defined @ ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    88

    Angry iptables-sav error


    Hello chaps,

    I need to avoid as much as possible buying a router, so i read about, and come across this lovely program...iptables*

    So, I follow the procedure defined @
    HTML Code:
    https://help.ubuntu.com/community/Internet/ConnectionSharing
    and the first four commands are fine.
    However, running the fifth
    Code:
     iptables-save |tree /etc/iptables.sav
    gives me this error:
    Code:
    /etc/iptables.sav [error opening dir]
    Any ideas why? I'm doing it as root, an have tried in normal user mode.

    Quick fix please...

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by njuguna View Post
    Hello chaps,

    I need to avoid as much as possible buying a router, so i read about, and come across this lovely program...iptables*

    So, I follow the procedure defined @
    HTML Code:
    https://help.ubuntu.com/community/Internet/ConnectionSharing
    and the first four commands are fine.
    However, running the fifth
    Code:
     iptables-save |tree /etc/iptables.sav
    gives me this error:
    Code:
    /etc/iptables.sav [error opening dir]
    Any ideas why? I'm doing it as root, an have tried in normal user mode.

    Quick fix please...
    just by looking at the guide you linked, don't you mean to do this:
    Code:
    sudo iptables-save | sudo tee /etc/iptables.sav
    or if root, without the sudo parts:
    Code:
    iptables-save | tee /etc/iptables.sav
    (you have tree)

    the next command fails b/c you did not create the file in the first command.

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    88
    I did create the file first, but the error recurred.

    The full error is
    Code:
    tree /etc/iptables.sav    [error opening dir]
    
    0 directories, 0 files
    What am I missing?
    Last edited by njuguna; 01-28-2012 at 05:58 AM. Reason: add info

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    this works perfectly for me:

    Code:
    user@localhost:~$ sudo iptables -A INPUT -i lo -j ACCEPT
    user@localhost:~$ sudo iptables-save |sudo tee /etc/iptables.sav
    # Generated by iptables-save v1.4.4 on Sat Jan 28 01:50:36 2012
    *filter
    :INPUT ACCEPT [163:18309]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [76:7728]
    -A INPUT -i lo -j ACCEPT 
    -A INPUT -i lo -j ACCEPT 
    COMMIT
    # Completed on Sat Jan 28 01:50:36 2012
    user@localhost:~$ cat /etc/iptables.sav 
    # Generated by iptables-save v1.4.4 on Sat Jan 28 01:50:36 2012
    *filter
    :INPUT ACCEPT [163:18309]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [76:7728]
    -A INPUT -i lo -j ACCEPT 
    -A INPUT -i lo -j ACCEPT 
    COMMIT
    # Completed on Sat Jan 28 01:50:36 2012
    user@localhost:~$ sudo iptables-restore < /etc/iptables.sav 
    user@localhost:~$ echo $?
    0
    Post the exact command you are running, and include any output the command generates.

  5. #5
    Just Joined!
    Join Date
    Sep 2008
    Posts
    88
    I'll do it shortly
    Actually, I run the commands as they are above, and the only output I get is the error I posted above in full:
    Code:
    tree /etc/iptables.sav [error opening dir]
    
    0 directories, 0 files
    Last edited by njuguna; 01-31-2012 at 05:20 AM.

  6. #6
    Linux Engineer MASONTX's Avatar
    Join Date
    May 2010
    Location
    Mason Texas
    Posts
    929
    Not my area, but I notice Atreyu's command is "sudo tee /etc/iptables.sav"
    while yours is "tree /etc/iptables.sav". Change "tree" to "tee" and see if it runs.
    Registered Linux user #526930

  7. #7
    Just Joined!
    Join Date
    Sep 2008
    Posts
    88
    Quote Originally Posted by MASONTX View Post
    Not my area, but I notice Atreyu's command is "sudo tee /etc/iptables.sav"
    while yours is "tree /etc/iptables.sav". Change "tree" to "tee" and see if it runs.
    I there such a command?

  8. #8
    Linux Engineer MASONTX's Avatar
    Join Date
    May 2010
    Location
    Mason Texas
    Posts
    929
    From Wikipedia: In computing, tee is a command in various command-line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which displays or pipes the output of a command and copies it into a file or a variable. It is primarily used in conjunction with pipes and filters.
    Contents
    [hide]

    1 Description and syntax
    1.1 Unix-like
    1.2 4DOS and 4NT
    1.3 Windows PowerShell
    2 Examples
    2.1 Unix-like
    2.2 4DOS and 4NT
    2.3 Windows PowerShell
    3 See also
    4 References
    5 External links

    [edit] Description and syntax

    tee is normally used to split the output of a program so that it can be seen on the display and also be saved in a file. The command can also be used to capture intermediate output before the data is altered by another command or program. The tee command reads standard input, then writes its content to standard output and simultaneously copies it into the specified file(s) or variables. The syntax differs depending on the command's implementation:
    Registered Linux user #526930

  9. #9
    Just Joined!
    Join Date
    Sep 2008
    Posts
    88
    Sorry atreyu, didn't post the exact command.

    Code:
    iptables-save |tree /etc/iptables.sav
    I see MASONTX, that the command was illegal because of the 'r' in 'tee' command.

    Thanks chaps.

    That's the case, I'll give it a try tonight. Update you tomorrow.
    Last edited by njuguna; 01-31-2012 at 12:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •