{"id":32,"date":"2017-10-08T07:02:00","date_gmt":"2017-10-08T07:02:00","guid":{"rendered":"https:\/\/linuxadmin.melberi.com\/uncategorized\/iptables-enable-ss"},"modified":"2017-10-08T16:27:44","modified_gmt":"2017-10-08T16:27:44","slug":"iptables-ssh","status":"publish","type":"post","link":"https:\/\/www.melberi.com\/linuxadmin\/iptables\/iptables-ssh","title":{"rendered":"How to Allow ssh port in iptables"},"content":{"rendered":"<p>How to Allow Deny iptables inbound outbound access for ssh port on Interface IP Based MAC Based etc<\/p>\n<h3><span style=\"text-decoration: underline;\"><strong>IPTables Allow SSH on any Interface<\/strong><\/span><\/h3>\n<p>Below command will enable SSH port in all the interface.<br \/>\n<strong># iptables -A INPUT -p tcp &#8211;dport 22 -j ACCEPT<\/strong><\/p>\n<h3><span style=\"text-decoration: underline;\"><b>IPTables Allow SSH on specific IP<\/b><\/span><\/h3>\n<p>Run the following\u00a0command in the Linux Shell<\/p>\n<p><b># iptables -A INPUT -d 10.5.0.1\/32 -p tcp &#8211;dport 22 -j ACCEPT<\/b><\/p>\n<p><strong>Or<\/strong><\/p>\n<p>Edit \/etc\/sysconfig\/iptables and add the following lines<\/p>\n<p><strong>#vim \/etc\/sysconfig\/iptables<\/strong><\/p>\n<p><span style=\"color: #808080;\">*filter<\/span><br \/>\n<span style=\"color: #808080;\"> :INPUT ACCEPT [0:0]<\/span><br \/>\n<span style=\"color: #808080;\"> :FORWARD ACCEPT [0:0]<\/span><br \/>\n<span style=\"color: #808080;\"> :OUTPUT ACCEPT [1888:534373]<\/span><br \/>\n<span style=\"color: #808080;\"> -A INPUT -i lo -j ACCEPT<\/span><br \/>\n<span style=\"color: #808080;\"> -A INPUT -m conntrack &#8211;ctstate RELATED,ESTABLISHED -j ACCEPT<\/span><br \/>\n<span style=\"color: #808080;\"> <b>-A INPUT -d 10.5.0.1\/32 -p tcp -m tcp &#8211;dport 22 -j ACCEPT<\/b><\/span><br \/>\n<span style=\"color: #808080;\"> -A INPUT -j DROP<\/span><br \/>\n<span style=\"color: #808080;\"> COMMIT<\/span><\/p>\n<p>replace x.x.x.x with your server interface ip<\/p>\n<h3><span style=\"text-decoration: underline;\"><b><u>IPTables Allow SSH on Specific interface<\/u><\/b><\/span><\/h3>\n<p><strong># iptables -A INPUT -i eth0 -p tcp &#8211;dport 22 -j ACCEPT<\/strong><\/p>\n<p>Or<\/p>\n<p>Edit \/etc\/sysconfig\/iptables and add the following lines<\/p>\n<p><span style=\"color: #808080;\">*filter<\/span><br \/>\n<span style=\"color: #808080;\"> :INPUT ACCEPT [0:0]<\/span><br \/>\n<span style=\"color: #808080;\"> :FORWARD ACCEPT [0:0]<\/span><br \/>\n<span style=\"color: #808080;\"> :OUTPUT ACCEPT [1888:534373]<\/span><br \/>\n<span style=\"color: #808080;\"> -A INPUT -i lo -j ACCEPT<\/span><br \/>\n<span style=\"color: #808080;\"> -A INPUT -m conntrack &#8211;ctstate RELATED,ESTABLISHED -j ACCEPT<\/span><br \/>\n<span style=\"color: #808080;\"> <strong>-A INPUT -i eth0 -p tcp -m tcp &#8211;dport 22 -j ACCEPT<\/strong><\/span><br \/>\n<span style=\"color: #808080;\"> -A INPUT -j DROP<\/span><br \/>\n<span style=\"color: #808080;\"> COMMIT<\/span><\/p>\n<p><strong>Restart iptables service<\/strong><\/p>\n<div><b>#service iptables restart<\/b><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Allow Deny iptables inbound outbound access for ssh port on Interface IP Based MAC Based etc IPTables Allow SSH on any Interface Below command will enable SSH port&#8230; <a href=\"https:\/\/www.melberi.com\/linuxadmin\/iptables\/iptables-ssh\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[104,110],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/posts\/32"}],"collection":[{"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":5,"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":486,"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/posts\/32\/revisions\/486"}],"wp:attachment":[{"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.melberi.com\/linuxadmin\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}