{"id":262,"date":"2011-03-02T15:37:43","date_gmt":"2011-03-02T20:37:43","guid":{"rendered":"http:\/\/www.serverprontouniversity.com\/?p=262"},"modified":"2018-08-21T10:55:11","modified_gmt":"2018-08-21T15:55:11","slug":"support-of-the-day-openclose-ports-on-ubuntu-distributions","status":"publish","type":"post","link":"https:\/\/www.serverpronto.com\/spu\/2011\/03\/support-of-the-day-openclose-ports-on-ubuntu-distributions\/","title":{"rendered":"Open\/Close Ports on Ubuntu distributions"},"content":{"rendered":"<p><strong>IPTables<\/strong> is an application program that allows to set up, maintain, and inspect the tables of IP packet filter rules provided by the Linux kernel.<\/p>\n<p>All IPTables rules are stored on \/etc\/iptables.rules<br \/>\nYou can open\/close any port from it and then restart the network by running &#8220;etc\/init.d\/networking restart&#8221;<\/p>\n<p>Before opening or closing ports, we recommend to first verify if the port is open or closed and who is using the port. There a number of different commands:<\/p>\n<p><strong>Commands to verify ports:<\/strong><\/p>\n<pre style=\"padding-left: 30px;\">nmap IP#<\/pre>\n<pre style=\"padding-left: 30px;\">nmap localhost<\/pre>\n<pre style=\"padding-left: 30px;\">netstat \u00e2\u20ac\u201cntulp<\/pre>\n<p>to verify the single port<\/p>\n<pre style=\"padding-left: 30px;\">netstat -nap | grep \u00c2\u00a0&lt;port #&gt;<\/pre>\n<p>to list all current rules in iptables<\/p>\n<pre style=\"padding-left: 30px;\">iptables -L\r\n<\/pre>\n<p><strong>For opening a TCP port:<\/strong><\/p>\n<pre style=\"padding-left: 30px;\">iptables -A INPUT\u00c2\u00a0 -p tcp \u00e2\u20ac\u201cdport &lt;port #&gt; -j ACCEPT<\/pre>\n<p><strong>For opening a UDP port:<\/strong><\/p>\n<pre style=\"padding-left: 30px;\">iptables -A INPUT -p udp \u00e2\u20ac\u201csport &lt;port #&gt;\u00c2\u00a0 -j ACCEPT<\/pre>\n<p><strong>Save changes:<\/strong><\/p>\n<pre style=\"padding-left: 30px;\">iptables-save &gt; \/etc\/iptables.rules<\/pre>\n<p><strong>If you need to disable the firewall temporarily, you can flush all the rules using:<\/strong><\/p>\n<pre style=\"padding-left: 30px;\">iptables -F\r\n<\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.serverpronto.com\">ServerPronto<\/a> offers the best affordable and secure hosting service in all dedicated server packages.<\/p>\n<p>&nbsp;<\/p>\n<p>For more detailed information visit<\/p>\n<p><a href=\"http:\/\/manpages.ubuntu.com\/manpages\/hardy\/man8\/iptables.8.html\">Iptables Description<\/a> by Ubuntu Manuals<\/p>\n<p><a href=\"https:\/\/help.ubuntu.com\/community\/IptablesHowTo#Allowing%20Incoming%20Traffic%20on%20Specific%20Ports\">Iptables How-To for Ubuntu<\/a> by Ubuntu Manuals<\/p>\n<p><a href=\"http:\/\/wiki.debian.org\/iptables\">Iptables How-To for Debian<\/a> by wiki.debian.org<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IPTables is an application program that allows to set up, maintain, and inspect the tables of IP packet filter rules provided by the Linux kernel. All IPTables rules are stored on \/etc\/iptables.rules You can open\/close any port from it and then restart the network by running &#8220;etc\/init.d\/networking restart&#8221; Before opening or closing ports, we recommend<\/p>\n","protected":false},"author":2,"featured_media":2653,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[123,17,112,22,48,18],"class_list":["post-262","post","type-post","status-publish","format-standard","has-post-thumbnail","category-support-of-the-day","tag-cloud","tag-dedicated-server","tag-hosting","tag-server","tag-ubuntu","tag-web-hosting"],"_links":{"self":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts\/262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":8,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":2688,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts\/262\/revisions\/2688"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/media\/2653"}],"wp:attachment":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}