{"id":1020,"date":"2010-08-01T10:19:10","date_gmt":"2010-08-01T14:19:10","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=1020"},"modified":"2013-03-20T08:43:17","modified_gmt":"2013-03-20T12:43:17","slug":"how-to-block-ftp-accessport-using-iptables-or-csf","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/how-to-block-ftp-accessport-using-iptables-or-csf","title":{"rendered":"How to Block Ftp Access\/Port using iptables OR CSF?"},"content":{"rendered":"<p>The default firewall of Linux is\u00a0<span style=\"color: #0000ff;\">iptables<\/span> which can be use to block Ftp access\/port on your server. If you have a CSF firewall (which also use iptables), see section 2.<\/p>\n<p><strong>Section 1:\u00a0 Iptables<\/strong><\/p>\n<p>Completely block Ftp access on the server:<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># iptables -A INPUT -p tcp --dport 21 -j DROP<\/span><\/pre>\n<\/blockquote>\n<p>Block Ftp access for a specific IP address, say 11.12.13.14<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># iptables -A INPUT -p tcp -s 11.12.13.14 --dport 21 -j DROP<\/span><\/pre>\n<\/blockquote>\n<p>Block Ftp access for a specific subnet<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># iptables -I INPUT -p tcp -s 11.12.13.0\/24 --dport 21 -j DROP<\/span><\/pre>\n<\/blockquote>\n<p>The rules need to be saved else they will be removed if the iptables service is restarted.<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># service iptables save<\/span><\/pre>\n<\/blockquote>\n<p><strong>Section 2: CSF<\/strong><\/p>\n<p>To completely block Ftp access, edit csf.conf file and remove port 21 from the TCP_IN list<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># pico \/etc\/csf\/csf.conf<\/span><\/pre>\n<\/blockquote>\n<p>To block Ftp access for a specific IP address, edit the csf.deny file<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># pico \/etc\/csf\/csf.deny<\/span><\/pre>\n<\/blockquote>\n<p>and place the following line<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">tcp:in:d=21:s=11.12.13.14<\/span><\/pre>\n<\/blockquote>\n<p>Save the file and don&#8217;t forget to restart the firewall.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default firewall of Linux is\u00a0iptables which can be use to block Ftp access\/port on your server. If you have a CSF firewall (which also use iptables), see section 2.<br \/>\nSection 1:\u00a0 Iptables<br \/>\nCompletely block Ftp access on the server:<\/p>\n<p># iptables -A INPUT -p tcp &#8211;dport 21 -j DROP<\/p>\n<p>Block Ftp access for a specific IP address, say 11.12.13.14<\/p>\n<p># iptables -A INPUT -p tcp -s 11.12.13.14 &#8211;dport 21 -j DROP<\/p>\n<p>Block Ftp access for a specific subnet<\/p>\n<p># iptables -I INPUT -p tcp -s 11.12.13.0\/24 &#8211;dport 21 -j DROP<\/p>\n<p>The rules need to be [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[1005,1003,1004,1001,1002,1006,1007],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1020"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=1020"}],"version-history":[{"count":9,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1020\/revisions"}],"predecessor-version":[{"id":2229,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1020\/revisions\/2229"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=1020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=1020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=1020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}