{"id":1307,"date":"2014-05-21T11:05:23","date_gmt":"2014-05-21T16:05:23","guid":{"rendered":"http:\/\/swildow.darktech.org\/wp\/?p=1307"},"modified":"2014-05-21T11:05:23","modified_gmt":"2014-05-21T16:05:23","slug":"examples-saving-and-restoring-iptables-rules","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=1307","title":{"rendered":"Examples: Saving and Restoring Iptables Rules"},"content":{"rendered":"<h2 style=\"padding: 0px; margin: 1.833em 0px 0.611em; font-weight: bold; color: #111111; font-size: 1.286em; line-height: 1.222em; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;\">Examples: Saving and Restoring Iptables Rules<\/h2>\n<p><a href=\"http:\/\/www.cyberciti.biz\/faq\/how-do-i-save-iptables-rules-or-settings\/\" target=\"_blank\">http:\/\/www.cyberciti.biz\/faq\/how-do-i-save-iptables-rules-or-settings\/ <\/a><\/p>\n<p><!--more--><\/p>\n<p style=\"padding: 0px; margin: 0px 0px 1.571em; color: #111111; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21.993999481201172px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;\">In this example, save current iptables firewall rules to a file called \/root\/dsl.fw, enter:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\"># iptables-save &gt; \/root\/dsl.fw<\/code><br style=\"padding: 0px; margin: 0px;\" \/>To restore iptables rules, enter:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\"># iptables-restore &lt; \/root\/dsl.fw<\/code><\/p>\n<p style=\"padding: 0px; margin: 0px 0px 1.571em; color: #111111; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21.993999481201172px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;\">To restore rules automatically upon Linux system reboot add following command to your \/etc\/rc.local file, enter:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\"># vi \/etc\/rc.local<\/code><br style=\"padding: 0px; margin: 0px;\" \/>Append the line:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\">\/sbin\/iptables-restore &lt; \/root\/dsl.fw<\/code><br style=\"padding: 0px; margin: 0px;\" \/>Save and close the file. Please note that under Red Hat enterprise Linux (RHEL) \/ CentOS \/ Fedora Linux you can use following commands to save and restore firewall rules. To Save the rules to \/etc\/sysconfig\/iptables file:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\"># \/etc\/init.d\/iptables save<\/code><br style=\"padding: 0px; margin: 0px;\" \/>To restore the rules from \/etc\/sysconfig\/iptables file:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\"># \/etc\/init.d\/iptables start<\/code><br style=\"padding: 0px; margin: 0px;\" \/>If you are using Debian \/ Ubuntu Linux open<span class=\"Apple-converted-space\">\u00a0<\/span><a style=\"padding: 0px; margin: 0px; text-decoration: underline; color: #2361a1;\" href=\"http:\/\/www.cyberciti.biz\/faq\/setting-up-an-network-interfaces-file\/\">\/etc\/network\/interfaces<\/a>:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\"># vi \/etc\/network\/interfaces<\/code><br style=\"padding: 0px; margin: 0px;\" \/>Append the line to eth0 section:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"padding: 0.667em 0.917em; margin: 0px 0px 1.833em; line-height: 1.5em; background-image: none; background-attachment: scroll; background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 0.857em; overflow: auto; border: 1px solid #dddddd; display: block; background-position: 0px 0px; background-repeat: repeat repeat;\">post-up iptables-restore<br style=\"padding: 0px; margin: 0px;\" \/>Close and save the file. Reboot the system.<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Examples: Saving and Restoring Iptables Rules http:\/\/www.cyberciti.biz\/faq\/how-do-i-save-iptables-rules-or-settings\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1307","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1307"}],"version-history":[{"count":1,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1307\/revisions"}],"predecessor-version":[{"id":1308,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1307\/revisions\/1308"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1307"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}