Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The -t option cannot be used in iptables-restore

I got this error when I want to restore my iptables rules from file.

iptables-restore v1.4.21: The -t option (seen in line 5) cannot be used in iptables-restore.

Error occurred at line: 5
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

There is my iptables:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-t nat -A POSTROUTING -o eth0 -j MASQUERADE
-A FORWARD -i eth0 -o lxcbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i lxcbr0 -o eth0 -j ACCEPT
COMMIT

I cannot do it without -t option.

like image 341
PumpkinSeed Avatar asked Feb 08 '16 14:02

PumpkinSeed


People also ask

How do I restore iptables?

To restore iptables rules use the iptables-restore command. It is used to restore an IP Tables from data specified from file. Use I/O redirection provided by your shell to read from a file.

What is the option in iptables?

Structure of iptables Options. The <table-name> option allows the user to select a table other than the default filter table to use with the command. The <command> option dictates a specific action to perform, such as appending or deleting the rule specified by the <chain-name> option.

Does iptables-restore flush?

If not specified, iptables-restore flushes (deletes) all previous contents of the respective IP Table. when adding or inserting rules into a chain, use command to load any necessary modules (targets, match extensions, etc).


1 Answers

I solved it:

*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [1:76]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT [95:5492]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [48:3648]
-A FORWARD -i eth0 -o lxcbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i lxcbr0 -o eth0 -j ACCEPT
COMMIT
like image 165
PumpkinSeed Avatar answered Sep 22 '22 12:09

PumpkinSeed