About Linux FAQ

Browse More FAQs:

Advertisements

How to: Allow telnet and ssh through iptables under Linux

Posted by Vivek Gite [Last updated: November 1, 2007]

Q. I run both RHEL / CentOS Linux server and by default firewall blocked out everything including telnet / ssh access. How do I allow telnet - port 23 and ssh port 22 thought Linux iptables firewall ?

A.By default firewall rules stored at /etc/sysconfig/iptables location / file under CentOS / RHEL. All you have to do is modify this file to add rules to open port 22 or 23.

Login as the root user.

Open /etc/sysconfig/iptables file, enter:
# vi /etc/sysconfig/iptables
Find line that read as follows:
COMMIT
To open port 22 (ssh), enter (before COMMIT line):

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

To open port 23 (telnet), enter (before COMMIT line):

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT

Save and close the file. Restart the firewall:
# /etc/init.d/iptables restart

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Other Helpful FAQs:

Discussion on This FAQ

  1. X-Modius Says:

    To get fancy with iptables and block repeated failed connection attempts, check out this article:

    http://www.itwire.com/content/view/13841/53

  2. Shiva Says:

    send me code of linux firewall in C.

  3. vivek Says:

    http://www.netfilter.org/

  4. Liju Says:

    Hi,

    I don’t think this is not a good idea to allow telnet access nowaday.nobody is using telnet on linux box. Disable this service first

    Also it is not a good idea to allow ssh access to everyone over the net
    # Permitt SSH access to my ip and my network
    /sbin/iptables -A INPUT -s 8.23.2.11 -p tcp –dport ssh -j ACCEPT
    /sbin/iptables -A INPUT -s 4.3.8.0/24 -p tcp –dport ssh -j ACCEPT

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.