{"id":453,"date":"2012-06-26T09:11:55","date_gmt":"2012-06-26T01:11:55","guid":{"rendered":"http:\/\/rmohan.com\/?p=453"},"modified":"2012-06-26T09:15:09","modified_gmt":"2012-06-26T01:15:09","slug":"shorewall-firewall-2","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=453","title":{"rendered":"Shorewall Firewall"},"content":{"rendered":"<p><strong>Installing and configuring Shorewall in CentOS<\/strong><\/p>\n<p>Netfilter is a packet filtering in Linux 2.4.x and 2.6.x kernels Enables packet filtering (network address and port), NAT and other packages. Redesigned and highly improved from the previous kernel 2.2.x, ipchains and ipfwadm kernel 2.0.x.<\/p>\n<p>Netfilter is a set of structures within the kernel that allows modules to register with the network functions.<\/p>\n<p>A record of the information is returned to tell the fate of this package. DENY, ACCEPT, REJECT is returned information to inform the target \/ request.<\/p>\n<p>DROP &#8211; Reject the packet without sending a message.<\/p>\n<p>REJECT &#8211; Do the same function as DROP, with the difference that sends an ICMP &#8220;icmp-port-unreachable&#8221; to the source machine.<\/p>\n<p>Iptables is a table structure for the definition of rulesets. Each rule within a table (IP) consists of a request and action (rules).<\/p>\n<p>Netfilter, ip_tables, connection tracking (ip_conntrack, nf_conntrack) and NAT are subsystems together to build the main parts of the structure.<\/p>\n<p>Reference: http:\/\/www.netfilter.org<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Shoreline Firewall (netfilter)<\/strong><br \/>\nSite Developer: www.shorewall.net \/ index.htm<br \/>\nGo to Documentation (Documentation) that there is going item by item and include other things that can add to Shorewall.<br \/>\nUsing the &#8220;shorewall&#8221; you will be using iptables, but in an easier way.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>yum install shorewall<\/strong><\/p>\n<p>Checking the processes that are to be started during reboot:<\/p>\n<p># <strong>Chkconfig &#8211; list<\/strong><\/p>\n<p>iptables 0: off 1: off 2: on 3: on 4: on 5: on 6: off<br \/>\nshorewall 0: off 1: off 2: off 3: off 4: off 5: off 6: off<\/p>\n<p>Note that Shorewall is off. That is, every time the machine is rebooted, Shorewall will not rise.<\/p>\n<p># <strong>Chkconfig shorewall on<\/strong><\/p>\n<p>Leaving it (shorewall) enabled looks like this:<\/p>\n<p>shorewall 0: off 1: off 2: on 3: on 4: on 5: on 6: off<\/p>\n<p>Shorewall configuration files:<\/p>\n<p>\/ etc \/ shorewall \/ shorewall.conf<br \/>\n\/ etc \/ shorewall \/ interfaces<br \/>\n\/ etc \/ shorewall \/ masq<br \/>\n\/ etc \/ shorewall \/ policy<br \/>\n\/ etc \/ shorewall \/ rules<br \/>\n\/ etc \/ shorewall \/ zones<\/p>\n<p>where:<\/p>\n<p>interfaces &#8211; each interface definition that will<br \/>\nmasq &#8211; Definition of Masquerade \/ SNAT (eth0, eth1, eth2 &#8230;)<br \/>\nPolice &#8211; Policies (ACCEPT, DROP, REJECT &#8230;)<br \/>\nrules &#8211; Firewall Rules<br \/>\nzones &#8211; zones Statement<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Configuring Shorewall<\/strong><br \/>\nChange in shorewall.conf:<\/p>\n<div><\/div>\n<div>STARTUP_ENABLED=Yes<\/div>\n<p>SHOREWALL_COMPILER=<\/p>\n<p>SHOREWALL_COMPILER=perl<\/p>\n<p>&nbsp;<\/p>\n<p><strong>cat \/etc\/shorewall\/interfaces<\/strong><\/p>\n<div>#<br \/>\n# Shorewall version 4 &#8211; Interfaces File<br \/>\n#<br \/>\n# For information about entries in this file, type &#8220;man shorewall-interfaces&#8221;<br \/>\n#<br \/>\n# The manpage is also online at<br \/>\n# http:\/\/www.shorewall.net\/manpages\/shorewall-interfaces.html<br \/>\n#<br \/>\n#######################################<br \/>\n#ZONE\u00a0\u00a0 INTERFACE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 BROADCAST\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPTIONS<br \/>\nnet\u00a0\u00a0\u00a0\u00a0 eth0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0detect\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tcpflags,dhcp,routefilter,nosmurfs,logmartians<br \/>\nloc\u00a0\u00a0\u00a0\u00a0 eth1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0detect\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tcpflags,nosmurfs<br \/>\n#LAST LINE &#8212; ADD YOUR ENTRIES BEFORE THIS ONE &#8212; DO NOT REMOVE# cat masq<br \/>\n#<br \/>\n# Shorewall version 4 &#8211; Masq file<br \/>\n#<br \/>\n# For information about entries in this file, type &#8220;man shorewall-masq&#8221;<br \/>\n#<br \/>\n# The manpage is also online at<br \/>\n# http:\/\/www.shorewall.net\/manpages\/shorewall-masq.html<br \/>\n#<br \/>\n#######################################<br \/>\n#INTERFACE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SOURCE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ADDRESS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PROTO\u00a0\u00a0 PORT(S) IPSEC\u00a0\u00a0 MARK<br \/>\neth0\u00a0\u00a0\u00a0 203.x.x.x<br \/>\neth0:1\u00a0 203.y.y.y<br \/>\neth1\u00a0\u00a0\u00a0\u00a010.x.y.z<br \/>\n#LAST LINE &#8212; ADD YOUR ENTRIES ABOVE THIS LINE &#8212; DO NOT REMOVE<\/div>\n<p>Note: Read the fine manual, has several options to configure.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>cat policy<\/strong><\/p>\n<div>#<br \/>\n# Shorewall version 4 &#8211; Policy File<br \/>\n#<br \/>\n# For information about entries in this file, type &#8220;man shorewall-policy&#8221;<br \/>\n#<br \/>\n# The manpage is also online at<br \/>\n# http:\/\/www.shorewall.net\/manpages\/shorewall-policy.html<br \/>\n#<br \/>\n#######################################<br \/>\n#SOURCE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DEST\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0POLICY\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LOG\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LIMIT:BURST<br \/>\nfw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 ACCEPT<br \/>\nfw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0net\u00a0\u00a0\u00a0\u00a0 ACCEPT<br \/>\nfw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ACCEPTloc\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ACCEPT<br \/>\nloc\u00a0\u00a0\u00a0\u00a0 net\u00a0\u00a0\u00a0\u00a0 ACCEPT<br \/>\nloc\u00a0\u00a0\u00a0\u00a0 loc\u00a0\u00a0\u00a0\u00a0 ACCEPTnet\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0DROP\u00a0\u00a0\u00a0\u00a0info<br \/>\nnet\u00a0\u00a0\u00a0\u00a0 loc\u00a0\u00a0\u00a0\u00a0 DROP\u00a0\u00a0\u00a0\u00a0info<br \/>\nnet\u00a0\u00a0\u00a0\u00a0 net\u00a0\u00a0\u00a0\u00a0 DROP\u00a0\u00a0\u00a0\u00a0info<\/p>\n<p>all\u00a0\u00a0\u00a0\u00a0 all\u00a0\u00a0\u00a0\u00a0 DROP\u00a0\u00a0\u00a0\u00a0info<br \/>\n#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LEVEL<br \/>\n#LAST LINE &#8212; DO NOT REMOVE<\/p>\n<\/div>\n<div><\/div>\n<div>\n<div id=\"gt-res-content\">\n<div dir=\"ltr\">Note: I left that last line (all all DROP info) because I decree that passes and does not pass the firewall and will generate a log of what is.<\/div>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><strong>cat rules<\/strong><\/p>\n<div>#<br \/>\n# Shorewall version 4 &#8211; Rules File<br \/>\n#<br \/>\n# For information on the settings in this file, type &#8220;man shorewall-rules&#8221;<br \/>\n#<br \/>\n# The manpage is also online at<br \/>\n# http:\/\/www.shorewall.net\/manpages\/shorewall-rules.html<br \/>\n#<br \/>\n############################################<br \/>\n#ACTION\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SOURCE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0DEST\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0PROTO\u00a0\u00a0 DEST\u00a0\u00a0\u00a0\u00a0SOURCE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ORIGINAL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0RATE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0USER\/\u00a0\u00a0 MARK<br \/>\n#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PORT\u00a0\u00a0\u00a0\u00a0PORT(S)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DEST\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LIMIT\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GROUP<br \/>\n#SECTION ESTABLISHED<br \/>\n#SECTION RELATED<br \/>\nSECTION NEW### NET to FWACCEPT\u00a0\u00a0net\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0 icmp\u00a0\u00a0echo-request<br \/>\nACCEPT\u00a0\u00a0net\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0 tcp\u00a0\u00a0 80<br \/>\nACCEPT\u00a0\u00a0net\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0 tcp\u00a0\u00a0 22<\/p>\n<p>### LOC to FW<\/p>\n<p>ACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0 tcp\u00a0\u00a0 ssh<br \/>\nACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0 icmp\u00a0\u00a0echo-request<br \/>\nACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 fw\u00a0\u00a0 udp\u00a0\u00a0 snmp<\/p>\n<p>### LOC to NET<\/p>\n<p>ACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 net\u00a0\u00a0udp\u00a0\u00a0 domain<br \/>\nACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 net\u00a0\u00a0tcp\u00a0\u00a0 domain<br \/>\nACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 net\u00a0\u00a0tcp\u00a0\u00a0 http,https<br \/>\nACCEPT\u00a0\u00a0loc\u00a0\u00a0\u00a0\u00a0 net\u00a0\u00a0icmp\u00a0\u00a0echo-request<br \/>\n#LAST LINE &#8212; ADD YOUR ENTRIES BEFORE THIS ONE &#8212; DO NOT REMOVE<\/p>\n<p># cat zones<br \/>\n#<br \/>\n# Shorewall version 4 &#8211; Zones File<br \/>\n#<br \/>\n# For information about this file, type &#8220;man shorewall-zones&#8221;<br \/>\n#<br \/>\n# The manpage is also online at<br \/>\n# http:\/\/www.shorewall.net\/manpages\/shorewall-zones.html<br \/>\n#<br \/>\n#######################################<br \/>\n#ZONE\u00a0\u00a0 TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OPTIONS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OUT<br \/>\n#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPTIONS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OPTIONS<br \/>\nfw\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0firewall<br \/>\nnet\u00a0\u00a0\u00a0\u00a0 ipv4<br \/>\nloc\u00a0\u00a0\u00a0\u00a0 ipv4<br \/>\n#LAST LINE &#8211; ADD YOUR ENTRIES ABOVE THIS ONE &#8211; DO NOT REMOVE<\/p>\n<p># service shorewall start<\/p>\n<\/div>\n<\/div>\n<div><\/div>\n<div>If you get any error:# Restart shorewall debugYou can check where the error is giving informed.<\/p>\n<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Installing and configuring Shorewall in CentOS<\/p>\n<p>Netfilter is a packet filtering in Linux 2.4.x and 2.6.x kernels Enables packet filtering (network address and port), NAT and other packages. Redesigned and highly improved from the previous kernel 2.2.x, ipchains and ipfwadm kernel 2.0.x.<\/p>\n<p>Netfilter is a set of structures within the kernel that allows modules to [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/453"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=453"}],"version-history":[{"count":4,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/453\/revisions"}],"predecessor-version":[{"id":455,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/453\/revisions\/455"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}