{"id":12,"date":"2005-02-11T13:25:58","date_gmt":"2005-02-11T13:25:58","guid":{"rendered":"http:\/\/bingo.bananasplit.info\/wordpress\/?p=12"},"modified":"2005-04-20T16:19:47","modified_gmt":"2005-04-20T16:19:47","slug":"firewall-config","status":"publish","type":"post","link":"https:\/\/blog.stmellion.org\/?p=12","title":{"rendered":"Firewall Config"},"content":{"rendered":"<p>My research has discovered various ways of loading iptables at boot.  I&#8217;m not saying this is the best way, but it works very nicely for me.  Note that iptables doesn&#8217;t currently work on an AMD 64bit K8 architecture.<\/p>\n<p>I create an iptables ruleset and save it under \/root as myfilters.  Mine is listed below:<\/p>\n<p># Required for DNS service<br \/>\niptables -A INPUT -p udp &#8211;sport 53 &#8211;dport 53 -j ACCEPT<\/p>\n<p># Network Time Protocol<br \/>\niptables -A INPUT -p udp &#8211;sport 123  &#8211;dport 123 -j ACCEPT<\/p>\n<p># Allow anything on the Loopback address<br \/>\niptables -A INPUT -i lo -j ACCEPT<\/p>\n<p># Allow incoming ICMP (such as Ping)<br \/>\niptables -A INPUT -p icmp &#8211;icmp-type any -j ACCEPT<\/p>\n<p># Allow established connections<br \/>\niptables -A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<\/p>\n<p># FTP<br \/>\niptables -A INPUT -s 82.133.6.112\/29 -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 21 -j ACCEPT<\/p>\n<p># SSH<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 22 -j ACCEPT<\/p>\n<p># Telnet<br \/>\niptables -A INPUT -s 82.133.6.112\/29 -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 23 -j ACCEPT<\/p>\n<p># SMTP<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 25 -j ACCEPT<\/p>\n<p># DNS (tcp &#038; udp)<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 53 -j ACCEPT<br \/>\niptables -A INPUT -m state &#8211;state NEW -m udp -p udp &#8211;dport 53 -j ACCEPT<\/p>\n<p># HTTP<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 80 -j ACCEPT<\/p>\n<p># POP3<br \/>\n#iptables -A INPUT -s 82.133.6.112\/29 -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 110 -j ACCEPT<\/p>\n<p># NNTP<br \/>\n#iptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 119 -j ACCEPT<\/p>\n<p># Network Time Protocol (tcp &#038; udp)<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 123 -j ACCEPT<br \/>\niptables -A INPUT -m state &#8211;state NEW -m udp -p udp &#8211;dport 123 -j ACCEPT<\/p>\n<p># HTTPS<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 443 -j ACCEPT<\/p>\n<p># SMTPS<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 465 -j ACCEPT<\/p>\n<p># NNTPS<br \/>\n#iptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 563 -j ACCEPT<\/p>\n<p># Mail Submission<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 587 -j ACCEPT<br \/>\niptables -A INPUT -m state &#8211;state NEW -m udp -p udp &#8211;dport 587 -j ACCEPT<\/p>\n<p># Additional SMTP port<br \/>\niptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 2525 -j ACCEPT<\/p>\n<p># Additional NNTPS port<br \/>\n#iptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 5563 -j ACCEPT<\/p>\n<p># Privoxy default port<br \/>\n#iptables -A INPUT -s 82.133.6.112\/29 -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 8118 -j ACCEPT<\/p>\n<p># Tor default port<br \/>\niptables -A INPUT -s 82.133.6.112\/29 -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 9050 -j ACCEPT<\/p>\n<p># Mixminion<br \/>\n#iptables -A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 48099 -j ACCEPT<\/p>\n<p># Enable the following to log messages to the console<br \/>\n# iptables -A INPUT -j LOG &#8211;log-level 3<\/p>\n<p># Reject anything else<br \/>\niptables -A INPUT -j REJECT &#8211;reject-with icmp-host-prohibited<\/p>\n<p>I try and keep the same file across all my machines and then just remark-out the parts I don&#8217;t need on a certain box.<\/p>\n<p>Execute this file with:<br \/>\n\/root\/myfilters<br \/>\nThen check the ruleset with:<br \/>\niptables -L -n<\/p>\n<p>If all looks good, the ruleset can be saved using:<br \/>\niptables-save > \/etc\/iptables<br \/>\nObviously the filename is just a matter of choice, it could go anywhere.<\/p>\n<p>Lastly, a section is required in the \/etc\/network\/interfaces file to activate this config when the interfaces are enabled.  This section should be:<br \/>\n# The following was added by Steve Crook to read in an iptables<br \/>\n# configuration.  The \/etc\/iptables file is created using iptables-save<br \/>\n# which in turn is created from \/root\/myfilters<br \/>\npre-up iptables-restore < \/etc\/iptables\n\nWorth noting that the command: iptables -F can be used to flush all firewall rules.  This is much better when testing than using -D and removing them one at a time.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to setup iptables on Debian<\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-debian","entry"],"_links":{"self":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12"}],"version-history":[{"count":0,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}