iptables-restore and ip6tables-restore commands are used to restore IP and IPv6 Tables from data being specified on the STDIN or in the file. Use I/O redirection provided by default from your shell to read from a file or specify the file as an argument.
iptables-restore [-chntv] [-M modprobe] [-T name] [file] ip6tables-restore [-chntv] [-M modprobe] [-T name] [file]
- -c, –counters : This option restores the values of all packet and byte counters.
- -h, –help : This option prints a short option summary.
- -n, –noflush : This option doesn’t flush the previous contents of the table. If it is not specified, both the commands flush (delete) all previous contents of the respective table.
- -t, –test : This option only parses and construct the ruleset, but do not commit it.
- -v, –verbose : This option prints additional debug info during ruleset processing.
- -M, –modprobe modprobe_program : This option Specifies the path to the modprobe program. By default, the iptables-restore will going to inspect /proc/sys/kernel/modprobe to determine the executable’s path.
- -T, –table name : This option restores only the named table even if the input stream contains other ones.
1) Create a new iptable which helps in restoring.
2) It will create a new file named iptableslist.txt. To see the contents of file run the following command on the terminal:
3) The content of the file is:
4) Now the last step is to restore from that file we just created. We can simply restore iptables using the following command.
- help Command in Linux with examples
- cal command in Linux with Examples
- mv command in Linux with examples
- cpp command in Linux with Examples
- tac command in Linux with Examples
- cvs command in Linux with Examples
- sum command in Linux with Examples
- w command in Linux with Examples
- cmp Command in Linux with examples
- tee command in Linux with examples
- df Command in Linux with examples
- cp command in Linux with examples
- gs command in Linux with Examples
- cut command in Linux with examples
- bc command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.