{"id":3731,"date":"2016-01-26T16:30:40","date_gmt":"2016-01-26T16:30:40","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2016\/01\/26\/how-to-allow-ports-in-apf-on-your-dedicated-server\/"},"modified":"2021-07-30T14:53:10","modified_gmt":"2021-07-30T18:53:10","slug":"allow-ports-apf","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/","title":{"rendered":"Allowing Ports in APF"},"content":{"rendered":"<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-1024x538.png\" alt=\"Allow Ports in APF Hero Image\" class=\"wp-image-70436\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-1024x538.png 1024w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-300x158.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-768x403.png 768w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png 1200w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/figure>\n\n\n\n<p>One of the most important aspects of server security is the firewall server configuration. Generally speaking, firewalls function by preventing unauthorized traffic from accessing your server. By default, <strong>APF (Advanced Policy Firewall)<\/strong> blocks most ports except those needed for web servers to operate, such as port 80, 443, etc. Occasionally, you may need to open ports for specific software operations. Unfortunately,  as there is no default way to modify APF within WHM, you can only add IP addresses to the firewall\u2019s whitelist via the command-line interface. In this article, we will outline the process of allowing specific ports in APF.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Allow Access to a Specific Port from all IPs<\/h2>\n\n\n\n<ol class=\"article_list wp-block-list\"><li>First, log into your Dedicated Server via <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/connect-ssh\/\">SSH<\/a> as the <a href=\"https:\/\/www.inmotionhosting.com\/support\/amp\/obtain-root-access\/\">root user<\/a>. <div style=\"clear: both;\">\u00a0<\/div><\/li><li>Next, edit the following file with a text editor. In the below example, we will be using <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/vim\/\" target=\"_blank\" rel=\"noreferrer noopener\">vim<\/a>. <pre>vim \/etc\/apf\/conf.apf<\/pre><\/li><li>Once you are editing the file, search for the term <strong>ingress<\/strong>. Within the conf.apf file you should find common inbound TCP ports.<\/li><li>Next, add the port you wish to open by adding it to the comma separated list as shown below:<pre>IG_TCP_CPORTS=\"20,21,25,53,80,110,143,443,465,587,993,995,2079,<br>2080,2082,2083,2086,2087,2095,2096,3306,<strong>9091<\/strong>,30000_35000\"<\/pre><\/li><li>Once done, save the file. <div style=\"clear: both;\">\u00a0<\/div><\/li><li>Finally, save the new APF settings by running the following command. <pre>apf -r<\/pre><\/li><li>If you look through the output you should see the following line:<pre>apf(11760): {glob} opening inbound tcp port 9091 on 0\/0<\/pre><\/li><\/ol>\n\n\n\n<p>Congratulations, now you know how to allow ports in APF via the command line! Using this process, you can open up specific ports to facilitate the usage of various applications that do not rely on the standard default ports. When modifying your firewall, it is important to ensure that you are only accepting legitimate traffic. By paying attention to the security requirements of the software you\u2019re using you can ensure that your APF setup is configured correctly. <\/p>\n\n\n\n<p>Need more help with APF? Familiarize yourself with some <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/basic-apf-commands\/\">basic APF commands<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most important aspects of server security is the firewall server configuration. Generally speaking, firewalls function by preventing unauthorized traffic from accessing your server. By default, APF (Advanced Policy Firewall) blocks most ports except those needed for web servers to operate, such as port 80, 443, etc. Occasionally, you may need to open<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4299],"tags":[],"class_list":["post-3731","post","type-post","status-publish","format-standard","hentry","category-security"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>APF: Allowing Ports via Command-Line on Dedicated Servers<\/title>\n<meta name=\"description\" content=\"In this article, we will outline the process of allowing specific ports in APF via the command-line on a dedicated server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"APF: Allowing Ports via Command-Line on Dedicated Servers\" \/>\n<meta property=\"og:description\" content=\"In this article, we will outline the process of allowing specific ports in APF via the command-line on a dedicated server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-26T16:30:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-30T18:53:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\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:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"Allowing Ports in APF\",\"datePublished\":\"2016-01-26T16:30:40+00:00\",\"dateModified\":\"2021-07-30T18:53:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\"},\"wordCount\":302,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-1024x538.png\",\"articleSection\":[\"Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\",\"name\":\"APF: Allowing Ports via Command-Line on Dedicated Servers\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-1024x538.png\",\"datePublished\":\"2016-01-26T16:30:40+00:00\",\"dateModified\":\"2021-07-30T18:53:10+00:00\",\"description\":\"In this article, we will outline the process of allowing specific ports in APF via the command-line on a dedicated server.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png\",\"width\":1200,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Allowing Ports in APF\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"APF: Allowing Ports via Command-Line on Dedicated Servers","description":"In this article, we will outline the process of allowing specific ports in APF via the command-line on a dedicated server.","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:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/","og_locale":"en_US","og_type":"article","og_title":"APF: Allowing Ports via Command-Line on Dedicated Servers","og_description":"In this article, we will outline the process of allowing specific ports in APF via the command-line on a dedicated server.","og_url":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2016-01-26T16:30:40+00:00","article_modified_time":"2021-07-30T18:53:10+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png","type":"image\/png"}],"author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"Allowing Ports in APF","datePublished":"2016-01-26T16:30:40+00:00","dateModified":"2021-07-30T18:53:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/"},"wordCount":302,"commentCount":2,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-1024x538.png","articleSection":["Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/","url":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/","name":"APF: Allowing Ports via Command-Line on Dedicated Servers","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF-1024x538.png","datePublished":"2016-01-26T16:30:40+00:00","dateModified":"2021-07-30T18:53:10+00:00","description":"In this article, we will outline the process of allowing specific ports in APF via the command-line on a dedicated server.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/Allow-Ports-in-APF.png","width":1200,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/security\/allow-ports-apf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Allowing Ports in APF"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4323,"name":"Dedicated Hosting","slug":"dedicated-hosting","link":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/dedicated-hosting\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3731"}],"version-history":[{"count":9,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3731\/revisions"}],"predecessor-version":[{"id":81763,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3731\/revisions\/81763"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}