{"id":773,"date":"2013-08-07T00:09:02","date_gmt":"2013-08-06T22:09:02","guid":{"rendered":"http:\/\/marc.storck.lu\/blog\/?p=773"},"modified":"2013-08-11T20:43:10","modified_gmt":"2013-08-11T18:43:10","slug":"basic-paranoid-iptables-firewall-for-an-amprnet-gateway","status":"publish","type":"post","link":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/","title":{"rendered":"Basic paranoid iptables firewall for an AMPRnet gateway"},"content":{"rendered":"<p>I have been asked a couple of times to provide a starting point for a firewall based on iptables for AMPRnet gateways based on Linux. I&#8217;ll try to accomplish this here.<\/p>\n<p>I&#8217;m assuming your Linux gateway uses the following interfaces:<\/p>\n<ul>\n<li>eth0 : connected to the Internet, has a public static IP address (<span style=\"text-decoration: underline; color: #ff0000;\"><strong>this post does NOT cover AMPRnet gateways behind NAT or within DMZ<\/strong><\/span>)<\/li>\n<li>eth1 : connected to your local AMPRnet LAN, has a static 44net IP address<\/li>\n<li>tunl0 : the IPIP tunnel interface<\/li>\n<\/ul>\n<p>The following script will allow to receive IPIP, RIPv2 and Management traffic. It will also allow connection to be initiated from the gateway or the LAN by employing a stateful firewall:<\/p>\n<p><!--more--><\/p>\n<p>(<span style=\"text-decoration: underline; color: #ff0000;\"><strong>ATTENTION<\/strong><\/span>: you will most probably lose connectivity to your gateway if you apply these rules remotely)<\/p>\n<blockquote><p>### Drop everything by default<br \/>\niptables -P INPUT DROP<br \/>\niptables -P OUTPUT DROP<br \/>\niptables -P FORWARD DROP<\/p>\n<p>### Allow traffic on loopback interface<br \/>\niptables -A INPUT -i lo -j ACCEPT<br \/>\niptables -A OUTPUT -o lo -j ACCEPT<\/p>\n<p>### ICMP is important and must work<br \/>\niptables -A INPUT -p icmp -j ACCEPT<br \/>\niptables -A FORWARD -p icmp -j ACCEPT<br \/>\niptables -A OUTPUT -p icmp -j ACCEPT<\/p>\n<p>### Allow remote management via SSH<br \/>\n### repeat for every subnet or IP address you want to allow<br \/>\niptables -A INPUT -p tcp &#8211;dport 22 -s 192.0.2.0\/24 -j ACCEPT<\/p>\n<p>### allow inbound IPIP packets (from everywhere)<br \/>\niptables -A INPUT -i eth0 -p 4 -j ACCEPT<\/p>\n<p>### allow inbound RIPv2 messages<br \/>\niptables -A INPUT -i tunl0 -s 44.0.0.1 -p udp &#8211;port 520 -j ACCEPT<\/p>\n<p>### allow inbound packets related to outbound packets (answers to request initiated locally)<br \/>\niptables -A INPUT -i eth0 -p udp\u00a0-m conntrack &#8211;ctstate ESTABLISHED,RELATED -j ACCEPT<br \/>\niptables -A INPUT -i eth0 -p tcp -m conntrack &#8211;ctstate ESTABLISHED,RELATED -j ACCEPT<\/p>\n<p>### allow outbound IPIP packets (to everywhere)<br \/>\niptables -A OUTPUT -o eth0 -p 4 -j ACCEPT<\/p>\n<p>### allow outbound connections from the local gateway<br \/>\niptables -A OUTPUT -o eth0 -p udp -j ACCEPT<br \/>\niptables -A OUTPUT -o eth0 -p tcp -j ACCEPT<\/p>\n<p>### allow traffic from LAN to outside (BCP38 applied)<br \/>\niptables -A FORWARD -i eth1 -s 44.256.0.0\/24 -p udp -j ACCEPT<br \/>\niptables -A FORWARD -i eth1 -s 44.256.0.0\/24\u00a0-p tcp -j ACCEPT<\/p>\n<p>### allow packets related to outbound packets (answers to request initiated locally) to be forwarded<br \/>\niptables -A FORWARD -i tunl0 -p udp\u00a0-m conntrack &#8211;ctstate ESTABLISHED,RELATED -j ACCEPT<br \/>\niptables -A FORWARD -i tunl0 -p tcp -m conntrack &#8211;ctstate ESTABLISHED,RELATED -j ACCEPT<\/p><\/blockquote>\n<p><span style=\"color: #3366ff;\"><strong>MODIFICATIONS<\/strong><\/span> to do by you:<\/p>\n<ul>\n<li>replace 192.0.2.0\/24 by the subnet or IP from where you want to connect to your gateway to manage it.<\/li>\n<li>replace 44.256.0.0\/24 by your AMPRnet subnet.<\/li>\n<\/ul>\n<p><span style=\"color: #339966;\"><strong>TODO:<\/strong><\/span><\/p>\n<ul>\n<li>Add more rules to allow specific services (please provide your ideas\/wishes)<\/li>\n<li>Allow more protocols from LAN to outside<\/li>\n<\/ul>\n<p><strong><span style=\"color: #ffcc00;\">UPDATES:<\/span><\/strong><\/p>\n<ul>\n<li>\u00a0Tried to make it clear that this post does NOT (yet) cover AMPRnet gateways behind NAT.<\/li>\n<li>Corrected typo &#8211;port instead of &#8211;dport.<\/li>\n<li>Allow traffic on loopback interface.<\/li>\n<li>Allow ICMP everywhere.<\/li>\n<li>Corrected last pair of rules where I accidentally had -i eth0 instead of -i tunl0<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I have been asked a couple of times to provide a starting point for a firewall based on iptables for AMPRnet gateways based on Linux. I&#8217;ll try to accomplish this here. I&#8217;m assuming your Linux gateway uses the following interfaces: &hellip; <a href=\"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,52],"tags":[58,59,9],"class_list":["post-773","post","type-post","status-publish","format-standard","hentry","category-hobbies","category-interests","tag-amprnet","tag-ham-radio","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Basic paranoid iptables firewall for an AMPRnet gateway - Marc&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic paranoid iptables firewall for an AMPRnet gateway - Marc&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"I have been asked a couple of times to provide a starting point for a firewall based on iptables for AMPRnet gateways based on Linux. I&#8217;ll try to accomplish this here. I&#8217;m assuming your Linux gateway uses the following interfaces: &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/\" \/>\n<meta property=\"og:site_name\" content=\"Marc&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-06T22:09:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-08-11T18:43:10+00:00\" \/>\n<meta name=\"author\" content=\"Marc\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marc\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/\"},\"author\":{\"name\":\"Marc\",\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/#\\\/schema\\\/person\\\/f27bff846342220e94f4112cf42ca433\"},\"headline\":\"Basic paranoid iptables firewall for an AMPRnet gateway\",\"datePublished\":\"2013-08-06T22:09:02+00:00\",\"dateModified\":\"2013-08-11T18:43:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/\"},\"wordCount\":497,\"commentCount\":16,\"publisher\":{\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/#\\\/schema\\\/person\\\/f27bff846342220e94f4112cf42ca433\"},\"keywords\":[\"AMPRnet\",\"HAM Radio\",\"Linux\"],\"articleSection\":[\"Hobbies\",\"Interests\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/\",\"url\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/\",\"name\":\"Basic paranoid iptables firewall for an AMPRnet gateway - Marc&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/#website\"},\"datePublished\":\"2013-08-06T22:09:02+00:00\",\"dateModified\":\"2013-08-11T18:43:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/2013\\\/08\\\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Basic paranoid iptables firewall for an AMPRnet gateway\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/\",\"name\":\"Marc&#039;s Blog\",\"description\":\"Things from me about me ...\",\"publisher\":{\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/#\\\/schema\\\/person\\\/f27bff846342220e94f4112cf42ca433\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/#\\\/schema\\\/person\\\/f27bff846342220e94f4112cf42ca433\",\"name\":\"Marc\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g\",\"caption\":\"Marc\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g\"},\"url\":\"https:\\\/\\\/marc.storck.lu\\\/blog\\\/author\\\/mcs23\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic paranoid iptables firewall for an AMPRnet gateway - Marc&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/","og_locale":"en_US","og_type":"article","og_title":"Basic paranoid iptables firewall for an AMPRnet gateway - Marc&#039;s Blog","og_description":"I have been asked a couple of times to provide a starting point for a firewall based on iptables for AMPRnet gateways based on Linux. I&#8217;ll try to accomplish this here. I&#8217;m assuming your Linux gateway uses the following interfaces: &hellip; Continue reading &rarr;","og_url":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/","og_site_name":"Marc&#039;s Blog","article_published_time":"2013-08-06T22:09:02+00:00","article_modified_time":"2013-08-11T18:43:10+00:00","author":"Marc","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Marc","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/#article","isPartOf":{"@id":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/"},"author":{"name":"Marc","@id":"https:\/\/marc.storck.lu\/blog\/#\/schema\/person\/f27bff846342220e94f4112cf42ca433"},"headline":"Basic paranoid iptables firewall for an AMPRnet gateway","datePublished":"2013-08-06T22:09:02+00:00","dateModified":"2013-08-11T18:43:10+00:00","mainEntityOfPage":{"@id":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/"},"wordCount":497,"commentCount":16,"publisher":{"@id":"https:\/\/marc.storck.lu\/blog\/#\/schema\/person\/f27bff846342220e94f4112cf42ca433"},"keywords":["AMPRnet","HAM Radio","Linux"],"articleSection":["Hobbies","Interests"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/","url":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/","name":"Basic paranoid iptables firewall for an AMPRnet gateway - Marc&#039;s Blog","isPartOf":{"@id":"https:\/\/marc.storck.lu\/blog\/#website"},"datePublished":"2013-08-06T22:09:02+00:00","dateModified":"2013-08-11T18:43:10+00:00","breadcrumb":{"@id":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/marc.storck.lu\/blog\/2013\/08\/basic-paranoid-iptables-firewall-for-an-amprnet-gateway\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/marc.storck.lu\/blog\/"},{"@type":"ListItem","position":2,"name":"Basic paranoid iptables firewall for an AMPRnet gateway"}]},{"@type":"WebSite","@id":"https:\/\/marc.storck.lu\/blog\/#website","url":"https:\/\/marc.storck.lu\/blog\/","name":"Marc&#039;s Blog","description":"Things from me about me ...","publisher":{"@id":"https:\/\/marc.storck.lu\/blog\/#\/schema\/person\/f27bff846342220e94f4112cf42ca433"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/marc.storck.lu\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/marc.storck.lu\/blog\/#\/schema\/person\/f27bff846342220e94f4112cf42ca433","name":"Marc","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g","caption":"Marc"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/5bd58717bd32e93b66cdbe59441798a1d9cbf4003a7ad5333e5919016683201d?s=96&d=mm&r=g"},"url":"https:\/\/marc.storck.lu\/blog\/author\/mcs23\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pqZFU-ct","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/posts\/773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/comments?post=773"}],"version-history":[{"count":7,"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/posts\/773\/revisions"}],"predecessor-version":[{"id":781,"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/posts\/773\/revisions\/781"}],"wp:attachment":[{"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/media?parent=773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/categories?post=773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marc.storck.lu\/blog\/wp-json\/wp\/v2\/tags?post=773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}